Skip to main content
2 of 2
added 6 characters in body; edited tags
fade2black
  • 9.9k
  • 2
  • 25
  • 36

How do I find maximum and minimum number of times the search loop will execute when searching through an array of 1,048,576 integers

I have tried to calculate the maximum number of times the loop will search through this large array, but I am not sure if I have that correct and I also need help with or pointers of how I can calculate the number of minimum times it will search through the array using both the binary search and sequential search. Here is what I have done so far.

Maximum Number of Times with Binary Search: Maximum: $\log_2(1,048,576)= 20$ times Maximum Number of Times with Sequential Search: Maximum: $1,048,576 + 1 ÷ 2= 524,289$ times

But I am confused about how I can obtained a solution with Minimum number for each algorithm. Any suggestions?