Download
the fundamentals algorithms integers and matrices n.
Skip this Video
Loading SlideShow in 5 Seconds..
The Fundamentals: Algorithms, Integers, and Matrices PowerPoint Presentation
Download Presentation
The Fundamentals: Algorithms, Integers, and Matrices

The Fundamentals: Algorithms, Integers, and Matrices

174 Views Download Presentation
Download Presentation

The Fundamentals: Algorithms, Integers, and Matrices

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. The Fundamentals: Algorithms, Integers, and Matrices CSC-2259 Discrete Structures Konstantin Busch - LSU

  2. The Growth of Functions Big-Oh: is no larger order than Big-Omega: is no smaller order than Big-Theta: is of same order as Konstantin Busch - LSU

  3. Big-Oh: (Notation abuse: ) There are constants (called witnesses) such that for all : Konstantin Busch - LSU

  4. For : Witnesses: Konstantin Busch - LSU

  5. For : Witnesses: Konstantin Busch - LSU

  6. and and are of the same order Example: and are of the same order Konstantin Busch - LSU

  7. and Example: Konstantin Busch - LSU

  8. Suppose Then for all : Impossible for Konstantin Busch - LSU

  9. Theorem: If then Proof: for Witnesses: End of Proof Konstantin Busch - LSU

  10. Witnesses: Konstantin Busch - LSU

  11. Witnesses: Konstantin Busch - LSU

  12. Witnesses: Konstantin Busch - LSU

  13. Witnesses: Konstantin Busch - LSU

  14. For : Witnesses: Konstantin Busch - LSU

  15. Witnesses: Konstantin Busch - LSU

  16. constant For : Witnesses: Konstantin Busch - LSU

  17. Interesting functions Higher growth Konstantin Busch - LSU

  18. Theorem: If , then Proof: Witnesses: End of Proof Konstantin Busch - LSU

  19. Corollary: If , then Theorem: If , then Konstantin Busch - LSU

  20. Multiplication Addition Konstantin Busch - LSU

  21. Big-Omega: (Notation abuse: ) There are constants (called witnesses) such that for all : Konstantin Busch - LSU

  22. Witnesses: Konstantin Busch - LSU

  23. Same order Big-Theta: (Notation abuse: ) Alternative definition: Konstantin Busch - LSU

  24. Witnesses: Witnesses: Konstantin Busch - LSU

  25. Theorem: If then Proof: We have shown: We only need to show Take and examine two cases Case 1: Case 2: Konstantin Busch - LSU

  26. Case 1: For and Case 2 is similar End of Proof Konstantin Busch - LSU

  27. Complexity of Algorithms Time complexity Number of operations performed Space complexity Size of memory used Konstantin Busch - LSU

  28. Linear search algorithm Linear-Search( ) { while( ) if ( ) return else return } //item found //item not found Konstantin Busch - LSU

  29. Time complexity Comparisons Item not found in list: Item found in position : Worst case performance: Konstantin Busch - LSU

  30. Binary search algorithm Binary-Search( ) { while( ) { if ( ) else } if ( ) return else return } //left endpoint of search area //right endpoint of search area //item is in right half //item is in left half //item found //item not found Konstantin Busch - LSU

  31. Search 19 1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22 1 2 3 5 6 7 8 10 12 13 15 16 18 19 20 22 12 13 15 16 18 19 20 22 18 19 20 22 18 19 Konstantin Busch - LSU

  32. Time complexity Size of search list at iteration 1: Size of search list at iteration 2: Size of search list at iteration : Konstantin Busch - LSU

  33. Size of search list at iteration : Smallest list size: in last iteration : Konstantin Busch - LSU

  34. Total comparisons: Last comparison #iterations Comparisons per iteration Konstantin Busch - LSU

  35. Bubble sort algorithm Bubble-Sort( ) { for ( to ) { for ( to ) if ( ) swap } Konstantin Busch - LSU

  36. First iteration 2 3 4 1 5 2 3 4 5 1 2 3 5 4 1 2 5 3 4 1 5 2 3 4 1 Second iteration Last iteration 5 2 3 4 1 5 2 3 4 1 5 2 4 3 1 5 4 2 3 1 5 4 3 2 1 Konstantin Busch - LSU

  37. Time complexity Comparisons in iteration 1: Comparisons in iteration 2: Comparisons in iteration : Total: Konstantin Busch - LSU

  38. Tractable problems Class : Problems with algorithms whose time complexity is polynomial Examples: Search, Sorting, Shortest path Konstantin Busch - LSU

  39. Intractable problems Class : Solution can be verified in polynomial time but no polynomial time algorithm is known Examples: Satisfiability, TSP, Vertex coloring Important computer science question Konstantin Busch - LSU

  40. Unsolvable problems There exist unsolvable problems which do not have any algorithm Example: Halting problem in Turing Machines Konstantin Busch - LSU

  41. Integers and Algorithms Base expansion of integer : Integers: Example: Konstantin Busch - LSU

  42. Binary expansion Digits: Konstantin Busch - LSU

  43. Hexadecimal expansion Digits: Konstantin Busch - LSU

  44. Octal expansion Digits: Konstantin Busch - LSU

  45. Conversion between binary and hexadecimal half byte Conversion between binary and octal Konstantin Busch - LSU

  46. Base expansion( ) { While ( ) { } return } Konstantin Busch - LSU

  47. Binary expansion of Konstantin Busch - LSU

  48. Octal expansion of Konstantin Busch - LSU

  49. Binary_addition( ) { for to { } return } //carry bit //auxilliary //j sum bit //carry bit //last sum bit Konstantin Busch - LSU

  50. Carry bit: 1 1 1 Time complexity of binary addition: (counting bit additions) Konstantin Busch - LSU