1 / 10

Algorithms

Algorithms. Matt Schierholtz. Overview. Method for solving problems with finite steps Algorithm example: Error Check for problem Solve problem Must terminate. Efficiency. Algorithms vary greatly in either memory space or time required Sorted into worst, best and average performance

heidi-sosa
Télécharger la présentation

Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Algorithms Matt Schierholtz

  2. Overview • Method for solving problems with finite steps • Algorithm example: • Error • Check for problem • Solve problem • Must terminate

  3. Efficiency • Algorithms vary greatly in either memory space or time required • Sorted into worst, best and average performance • Big O, Big Θ and Big Ω notation • O(f(x)) is at most f(x)

  4. Algorithm Types • Nested loop • s = 0 • for i = 1 to n • for j = 1 to i • s = s + j(i – j + 1) • next j • next i • Find the number of steps this algorithm takes • Compare efficiency of particular algorithms

  5. Algorithms and Logarithms • Logbx = a is very useful in computer calculations • For example, • Log21024 = 10 and log21048576 = 20 • ⌊a⌋ is the number of bits used to represent a number x in binary, or ternary, or any number base ya want

  6. Binary Search • Takes less time than sequential search • Trades time for organization • Example • While (top >= bot and index = 0) • Mid = ⌊(bot + top) / 2⌋ • If a[mid] = x then index = mid • If a[mid] > x • Then top = mid - 1 • Else bot = mid + 1 • End while

  7. Merge Sort • Easier to write than Binary search • But takes more time • Think recursively • Suppose: • Efficient algorithm for arrays < k known • What if you have array < k?

  8. More Merge Sort • Sort smaller parts! • Then you merge Initial number group Get sorted Merge

  9. Tractable & Intractable Problems • Algorithms with exponential order • Ex: Tower of Hanoi • If it has 64 disks • Number of moves = 264 – 1 • For a computer, moves / second = 109 • This will take 584 years

  10. P vs. NP • Polynomial algorithms are class P • These are tractable • Even if they take a very long time • Problems not solved in polynomial time are… • Intractable • Class NP (nondeterministic polynomial) • $1,000,000, to anyone who proves P=NP • NP-Complete • If one NP problem is solvable, all of them are

More Related