Searching through a sorted list of size n for a desired item with can be done faster than searching through an unsorted list. What's the Big-Oh complexity you can achieve with a smarter algorithm?
Added by Alexis F.
Step 1
We need to search for a desired item in a sorted list of size \( n \). Show more…
Show all steps
Your feedback will help us improve your experience
Akash M and 69 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Questions What is the typical asymptotic complexity (Big O) of binary search? What is the best way of guessing a number from range of 0 to 1000 by using binary search? What is the maximum number of guesses needed to guess the number? Which are the O(n²) sorting algorithms we have learnt? Which are the O(nlog₂ n) sorting algorithms we have learnt? The asymptotic complexity (Big O) of radix sort is O(kn). What does k mean and what does n mean? Does O(kn) always better than O(nlog₂ n) sorting? If there are 8 3 digits numbers needs to be sort, would you use radix sort? How about 8 4 digits numbers? How about 8 2 digits numbers? How about Assignment 2 question 2, would you use radix sort to find the median value from 9 pixels? What is the asymptotic complexity (Big O) of bin sort? Would you use bin sort to find the median value from 9 pixels in Assignment 2 question 2?
Akash M.
The following are examples of computing times in algorithm analysis. To make the difference clearer, let's compare based on the execution time where n = 1,000,000 and time = 1 millisecond: Big-Oh Description Algorithm Running Time Sample Code Implementation O(1) Constant return n (n+1)/2 O(log2 n) Logarithmic Binary Search 19.93 microseconds while n > 1 count < count + 1 n = n / 2 O(n) Linear Sequential 1.00 seconds for i = 1 to n search sum < sum + i O(n log2 n) Heapsort 19.93 seconds O(n^2) Quadratic Insertion Sort 11.57 days for i = 1 to n for j = 1 to n sum = sum + i O(n^3) Cubic Floyd's Algorithm O(2^n) Exponential 317.10 centuries O(n^n) Eternity O(log2 log2 n) Operations on the O-Notation: Rule for Sums Suppose that T(n) = O(f(n)) and Tz(n) = O(g(n)): Then, t(n) = Ti(n) + Tz(n) = O(max(f(n), g(n))).
Madhur L.
You are looking for an item in an ordered list 450,000 items long (the length of Webster. Third New International Dictionary). How many steps might it take to find the item with a sequential search? A binary search?
Transcendental Functions
Relative Rates of Growth
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
18,000,000+
Students on Numerade
Trusted by students at 8,000+ universities
Watch the video solution with this free unlock.
EMAIL
PASSWORD