Download presentation
Presentation is loading. Please wait.
Published byAlvin Wood Modified over 9 years ago
1
Counting the Cost Recall linear search & binary search Number of items Worst CaseExpected Case Number of probes (comparisons) LinearBinary Linear Binary 11111 7733.53 63 8318 1000 1050010 NNlog 2 NN/2log 2 N
2
Algorithm to find the maximum Consider 8 numbers. abcdefgh max of a & b max of c & d max of e & f max of g & h max of a - d max of e - h max of a - h comparisons Total number of comparisons?
3
Sorting Algorithms Sorting algorithms rearrange items from smallest to largest (or largest to smallest). One sorting algorithm: - repeatedly find the maximum and move it immediately ahead of all prior maximums. Example (sort 100 values) Step 1 - find the maximum of 100 values 99 comparisons Step 2 - find the maximum of 99 values 98 comparisons Step 3 - find the maximum of 98 values 97 comparisons Total comparisons for sorting 100: 99+98+97+...+1 Total comparisons for sorting N: (N-1)+(N-2)+(N-3)+...+1
4
Comparing Algorithm Performance binary search linear search sorting algorithm
5
Functional Growth 10194 421678074896 83646 x 10 15 123.6144(note 1) 164256(note 2) 204.3400 244.6576 284.8784 3251024 nlog 2 nn2n2 94 n note 1 - note 2 - linear search binary search sort password cracker
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.