Suppose the list has an even number of items say 16 at what positions are the tw
ID: 3784768 • Letter: S
Question
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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.