Question

Please show explanation on how you got answer (Question 1 )How many best and worst case...

Please show explanation on how you got answer

(Question 1 )How many best and worst case for a binary search on sorted array of 4 elements

A: Worst - 2 , Best - 1

B: Worst - 2 , Best - 0

C: Worst - 6 , Best - 0

D: Worst - 6 , Best - 1

E: Worst - 3 , Best - 1

(Question 2 )How many best and worst case for a binary search on sorted array of 7 elements

0 0
Add a comment Improve this question Transcribed image text
Answer #1

******************************************************************************************
Please Upvote the answer as it matters to me a lot :)
*****************************************************************************************
As per HomeworkLib expert answering guidelines,Experts are supposed to answer only certain number of questions/sub-parts in a post.Please raise the remaining as a new question as per HomeworkLib guidelines.
******************************************************************************************

if the size of the array is x then In the best case a binary search on sorted elements takes

only 1 comparison

if the size of the array is x then In the worst case a binary search on sorted elements takes

only ceil(log n) comparison

so when x=3 = ceil(log3) = 2

when x= 7 = ceil(log7) = 3

Add a comment
Know the answer?
Add Answer to:
Please show explanation on how you got answer (Question 1 )How many best and worst case...
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
  • Using the binary search, at worst case how many times do you need to query a...

    Using the binary search, at worst case how many times do you need to query a sorted array with data size 750 to determine if the target is in the list or not? 4-5 9-10 13-14 100 - 101 201 or more

  • 1. What is the worst case time complexity of insertion into a binary search tree with...

    1. What is the worst case time complexity of insertion into a binary search tree with n elements? You should use the most accurate asymptotic notation for your answer. 2. A binary search tree is given in the following. Draw the resulting binary search tree (to the right of the given tree) after deleting the node with key value 8. 10 3. You have a sorted array B with n elements, where n is very large. Array C is obtained...

  • Please give little explanation, I'm trying to understand why. 2. List appropriate Worst Case Big O...

    Please give little explanation, I'm trying to understand why. 2. List appropriate Worst Case Big O Notation under the different algorithms or data structure operations. O(1) O(n) O(n ^ 2) O(log n) A. Directly Accessing value in a 2-dimensional by [row][column] B. Selection Sort then Binary Search on a 1,000,000 element array C. Binary Search D. Highest element algorithm for 10,000 element array. E. Traversal of 6 character string O(n) 3. Give examples of Implicit declarations for Python and C++....

  • 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

  • Find the best case, worst case and average case complexity for numbers of comparison and assignment...

    Find the best case, worst case and average case complexity for numbers of comparison and assignment operations for the following code. Indicate when there is no best or worst case. Comparisons Assignments Given 2-D array of integer map[n][n]: Best: Best: worst: worst: for (i0; 1 <n; i++) for(j = 0j <n; j++) If (map 10] < 0) map[001-mapli01: average: average: For ease of analysis, assume half of the elements in map are negative.

  • S1I Summer 09 Page 7 Practice Final Exam (30 points) Fill in the blanks to complete...

    S1I Summer 09 Page 7 Practice Final Exam (30 points) Fill in the blanks to complete the following recursive program It should print a pattern like the one below, using System.out.printin. The argument, lines, says how many lines long the pattern should be. Assume you have a method String nspaces(n) which returns a string containing n spaces. CYou should not write nspaces.) Here is the pattern when lines is 4. The first line VI. name has one space before the...

  • 1. (10 pts) What is the order of each of the following tasks in the worst...

    1. (10 pts) What is the order of each of the following tasks in the worst case (the worst case of the best algorithm for the task) (in Big-Oh notation)? • Searching a pointer-based link listed of n integers for a particular value. Answer: Searching a sorted array of n integers for a particular value. Answer: • Searching an unsorted array of n integers for a particular value. Answer: • Inserting a new value into a sorted array of n...

  • please check my answers if it wrong answer me a) (25 points) Suppose that you are...

    please check my answers if it wrong answer me a) (25 points) Suppose that you are asked to analyze the performance. Algorithms operate on 1D array of size nor 2D a of the algorithms below, write down the Big O or order of grow terms of n. If the algorithm cannot be applied to the array, write 0(1), O(log n), O(n), O(n logn), 90), O(n"), O(n!). The will only be given for reasonable Big O answers. & algorithms for their...

  • 1) (10 pts) What are the worst case run times of each of the following operations?...

    1) (10 pts) What are the worst case run times of each of the following operations? Make sure to list your answer in terms of the appropriate variables in the prompt. Note that on occasion, some of the run times won't be dependent on some of the variables listed in the prompt. (a) Inserting an item to the front of a linked list of n elements. (b) Sorting n integers using Quick Sort. (c) Merging a sorted list of a...

  • JH: Student Name: 4) Given the following array, do the following (show all the work). A...

    JH: Student Name: 4) Given the following array, do the following (show all the work). A (56, 89, 23, 58, 22, 11, 45, 48, 90) (a - 5 pts) Construct a hash table for the given array using the hash function H(K)- K mod 5 (b- 4 pts) Determine the average number of comparisons for a successful search using the hash table of (c -3 pts) What is the worst case number of comparisons for an unsuccessful search in the...

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
ADVERTISEMENT