Question

1.For a sorted list of 512 elements, a binary search takes at most _______ comparisons? 11...

1.For a sorted list of 512 elements, a binary search takes at most _______ comparisons?

11

9

10

100

0 0
Add a comment Improve this question Transcribed image text
Answer #1
For a sorted list of 512 elements
Number of comparisons a binary search takes
= log2(512)+1
= 9+1
= 10

10

Add a comment
Know the answer?
Add Answer to:
1.For a sorted list of 512 elements, a binary search takes at most _______ comparisons? 11...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Language = c++ Write a program to find the number of comparisons using the binary search...

    Language = c++ Write a program to find the number of comparisons using the binary search and sequential search algorithms as follows: o Suppose list is an array of 1000 elements. o Use a random number generator to fill the list. o Use the function insertOrd to initially insert all the elements in the list. o You may use the following function to fill the list: void fill(orderedArrayListType& list) {       int seed = 47; int multiplier = 2743;                                ...

  • About how many comparisons would the binary search makes if the list is of length 1...

    About how many comparisons would the binary search makes if the list is of length 1 million and the search item is not in the list? 500,000 comparisons 1 million comparisons 20 comparisons None of these 1 thousands comparisons D Question 18 2 pts The time complexity of the merge sort is in the worst case and in the average case (1), () Orlogan), Oorlog) Orlogo"). (1) 001), O(nlogon) (r). (1)

  • Discrete Mathematics Unsorted and Sorted Lists For linear search there was no requirement for the list...

    Discrete Mathematics Unsorted and Sorted Lists For linear search there was no requirement for the list to be organized in any manner. The linear search works for lists that are "unsorted." But what if the values in the list are given in ascending order? This would be a sorted list. With a sorted list, is there a more efficient way to find the target? Unsorted Lists (4 pts) Assume there is a sorting algorithm with order of growth O(n), where...

  • We know that binary search on a sorted array of size n takes O(log n) time....

    We know that binary search on a sorted array of size n takes O(log n) time. Design a similar divide-and-conquer algorithm for searching in a sorted singly linked list of size n. Describe the steps of your algorithm in plain English. Write a recurrence equation for the runtime complexity. Solve the equation by the master theorem.

  • Which of the following is the main requirement for a binary search algorithm? a. The list...

    Which of the following is the main requirement for a binary search algorithm? a. The list must have an odd number of elements. b. The list must be sorted in ascending order. C. The list must be sorted in descending order. d. The list must have an even number of elements.

  • Write a C++ function binsearch that carries out the binary search algorithm on a sorted array...

    Write a C++ function binsearch that carries out the binary search algorithm on a sorted array of integers. Your function takes as parameters an array of integers (sorted in increasing order), the size of the array, and a target integer to search for. The function returns the index of the target in the array, and returns -1 if the target is not in the array. The file main1.txt on the webpage contains code that generates a specific array of integers...

  • JAVA question: Suppose we are performing a binary search on a sorted array called numbers initialized...

    JAVA question: Suppose we are performing a binary search on a sorted array called numbers initialized as follows: // index 0 1 2 3 4 5 6 7 8 9 10 11 12 13 int[] numbers = {-30, -9, -6, -4, -2, -1, 0, 2, 4, 10, 12, 17, 22, 30}; ​ // search for the value -5 int index = binarySearch(numbers, -5); Write the indexes of the elements that would be examined by the binary search (the mid values...

  • Implement a binary search function that takes an integer query key and determines whether it is...

    Implement a binary search function that takes an integer query key and determines whether it is in a sorted array of n integers. It should return the index of the key, if found, otherwise it should return a negative number. You should implement the function both iteratively and recursively to be sure you really understand the algorithm. Just for the fun of it, you might want to verify the O(log(n)) complexity of your function by counting the number of comparisons...

  • Approximately how many comparisons in the worst case would need to be made on a sorted...

    Approximately how many comparisons in the worst case would need to be made on a sorted list of size 290 if we used a binary searching algorithm? a. between 0 and 10 b. between 10 and 50 c. between 50 and 100 d. between 100 and 1000 e. more than 1000

  • How many comparisons will it take for the binary search to find the number 17 in...

    How many comparisons will it take for the binary search to find the number 17 in the list of numbers 1 4 5 7 8 17 21 24 28 29 31 37 39?

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT