Question

Explain Binary Search Algorithm to search for V = 75, using the data given below                ...

Explain Binary Search Algorithm to search for V = 75, using the data given below

                5, 10, 25, 35, 45, 50, 60, 70, 75, 80, 85

   How many searches will be needed?

Homework Answers

Answer #1


Searching for 75 in list [5, 10, 25, 35, 45, 50, 60, 70, 75, 80, 85]
   left = 0, right = 10, mid = 5, arr[mid] = 50
   > Middle element in this list is 50
   > Compare Target (75) with middle element (50) of this list
   > Target value (75) is larger than this middle element 50
   > so, we have to search in right part of the list([60, 70, 75, 80, 85])
Searching for 75 in list [60, 70, 75, 80, 85]
   left = 6, right = 10, mid = 8, arr[mid] = 75
   > Middle element in this list is 75
   > Compare Target (75) with middle element (75) of this list
   > They are the same. Target element (75) is found. so, binary search ends here.
It took a total of 2 comparisons using binary search

Know the answer?
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
Similar Questions
Construct a Binary Search Tree using the following data:   (5 pts)                 54           37   &nb
Construct a Binary Search Tree using the following data:   (5 pts)                 54           37           47           28           44           71           40           60 (Make sure to show dummy nodes) b) Illustrate how will you search for V = 39 from the above tree and how many searches will be needed. (5 pts) c) Illustrate how you will delete the root from the above tree, redraw the tree after deletion. (5 pts). Redraw the tree.
All necessary steps much show for these problems, please. The binary search algorithm is used with...
All necessary steps much show for these problems, please. The binary search algorithm is used with the following list; x has the value “flour.” Name the elements against which x is compared. Work shown should include which half of the list is searched after the midpoint is determined. butter, chocolate, eggs, flour, shortening, sugar How many different bit strings of length seven are there? A survey of 160 college students reveals that 85 own automobiles, 101 own bikes, 25 own...
A doctor that works in the hospital thinks that based on her prior experience, the average...
A doctor that works in the hospital thinks that based on her prior experience, the average ease of intubation in obese patients is around 45. Conduct a randomization test for a mean to assess whether the doctor’s hypothesis is plausible.Report the p-value. Interpret the p-value in terms of rejecting the null hypothesis or failing to reject the null hypothesis. Data collected: ease 5 20 80 80 20 2 10 60 15 0 70 85 10 15 60 70 60 30...
You are asked to write an efficient algorithm to search a given key within a given...
You are asked to write an efficient algorithm to search a given key within a given 2D array, where every row and column is sorted in an ascending order. For example consider a 2D arrary. Every row and column is sorted. You are searching the 2D array for key 36. 3 7 11 23 45 5 9 13 25 50 7 14 15 30 55 10 18 22 34 62 16 24 29 38 88 Present pseudocode of an efficient...
You are asked to write an efficient algorithm to search a given key within a given...
You are asked to write an efficient algorithm to search a given key within a given 2D array, where every row and column is sorted in an ascending order. For example consider a 2D arrary. Every row and column is sorted. You are searching the 2D array for key 36.   3 7 11 23 45 5 9 13 25 50 7 14 15 30 55 10 18 22 34 62 16 24 29 38 88 Present pseudocode of an efficient...
Create a binary search tree (ASCII text representation is OK) from the following data: 31 16...
Create a binary search tree (ASCII text representation is OK) from the following data: 31 16 5 24 36 45 17 25 33 10
Does this data come from a normal distribution? Discuss and do an appropriate calculation. result 82.5...
Does this data come from a normal distribution? Discuss and do an appropriate calculation. result 82.5 62.5 47.5 85 62.5 57.5 72.5 55 70 42.5 52.5 22.5 52.5 35 32.5 87.5 87.5 72.5 70 70 87.5 57.5 95 70 67.5 60 35 35 77.5 87.5 97.5 75 50 52.5 60 45 80 65 62.5 35 95 37.5 30 50 95 85 70 80 50 80 92.5 65 60 27.5 62.5 35
Given the list of values below, create a Binary Search Tree for the list, Use the...
Given the list of values below, create a Binary Search Tree for the list, Use the first value in the list as the root of the tree, add the nodes to BST in the order they appear in the list.[50, 44, 82, 39, 35, 98, 87, 100, 74, 23, 34, 14, 94] What is the minimum height of a Binary Tree that contains 24nodes? What is the minimum height of a Binary Tree that contains 64nodes? What is the minimum...
The data collection is conducted by randomly selecting 51 persons whose ages are between 25-30 and...
The data collection is conducted by randomly selecting 51 persons whose ages are between 25-30 and interviewing the average time they spend on Instagram in a day. What is the probability that people ages between 25-30 spend time using Instagram for more than one hour in a day? I need a PMF equation The collected data: Number of Person Time Number of Person Time Number of Person Time Number of Person Time 1 120 14 90 26 120 39 70...
Using the given data set to answer the following questions80 60 100 40 40 50 80...
Using the given data set to answer the following questions80 60 100 40 40 50 80 90 100 60 10 80 45 60 30 80 30 90 100 60 50 75 a. find Mean, Median, Mode, Standard Deviation, and Variance: b. find First quartile and Third Quartile c. Find the number which represents the 33th percentile. d. find the percentile of 45 e. find the range and midrange f. construct a box-plot g. Construct a frequency distribution with 5 classes....
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT