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.
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...
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...
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
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....
Sixty students were given a history exam. Their scores are shown below, sorted from smallest to...
Sixty students were given a history exam. Their scores are shown below, sorted from smallest to largest. 13 30 35 35 35 38 38 38 38 39 40 41 42 45 47 51 53 65 66 72 74 74 75 75 75 75 76 76 76 76 77 77 78 78 78 78 78 78 79 79 79 80 80 80 80 80 81 81 81 81 81 82 82 82 85 85 86 86 88 94 1) Compute the...
Q7. Use the table below to answer the questions that follow: Quantity supplied                    Quantity Demanded     ...
Q7. Use the table below to answer the questions that follow: Quantity supplied                    Quantity Demanded      Thousands              price        Thousands               60                 $25                     80               60                  35                      75               60                  45                      70               60                  55                      65               60                  65                      60               60                  75                      55               60                  85                      50 a. If this table reflects the supply of and demand for tickets to a particular World Cup soccer game, what is the stadium capacity ? b. If the preset ticket price is $45,...
A mathematics achievement test consisting of 100 questions was given to 50 sixth grade students at...
A mathematics achievement test consisting of 100 questions was given to 50 sixth grade students at maple Elementary School. The following data show the number of questions answered correct by each student. 75 48 46 65 71 49 61 51 57 49 84 85 79 85 83 55 69 88 89 55 61 72 64 67 61 77 51 61 68 54 63 94 54 53 71 84 79 75 65 50 45 65 77 71 63 67 57 63...
Given the data below for the oil market, show a supply and demand diagram, determine the...
Given the data below for the oil market, show a supply and demand diagram, determine the linear equations for demand and for supply, and find the equilibrium price and quantity in the market. Find both sets of equations for Q = f(P), and P = f(Q). QD P QS 83 60 80 82 70 82 81 80 83 80 90 83 79 100 84 78 110 85 77 120 86 76 130 86 76 140 87 75 150 88 Would...