Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose the list has an even number of items say 16 at what positions are the tw

ID: 3784768 • Letter: S

Question


Suppose the list has an even number of items say 16 at what positions are the two"middle" items? Using sequential search, how many comparisons are required to find each of these? What is the average of these two numbers? Repeat this exercise with a few more even numbers until you can do the following: If there are n items in the list and n is an even number, write an expression for the average number of comparisons required to find the two middle items Noting that half the items in a list fall before the midpoint and half after the midpoint, use your answer to parts a and b to write an exact expression for the average number of comparisons done using sequential search to find a target value that occurs in an n-element

Explanation / Answer

b) list has an even number of items. so two middle items will be found after 16*4 comparisons. that is after 64 comparisons.

Expression to find the average number of comparisons= n*log n, because to find an element we need to first sort the elemnts in the array and when the elementsa are sorted then to find the middle element and calculate the average will take O (1) time.

c) Now for searching the target value here average number of comparison would be (n+1)/2. If there are n number of elements in the array.

if you like this answer, please give a thumbs up and if you have some doubt just ask in the comment section below. I will try to help. Cheers

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote