What are the updated values of high and low in the array if the element being searched is greater than the value at calculated index in

thanhthao

New member
What are the updated values of high and low in the array if the element being searched is greater than the value at calculated index in interpolation search? (pos = current position)
A. low = pos + 1, high remains unchanged
B. high = pos – 1, low remains unchanged
C. low = low +1, high = high – 1
D. low = pos +1, high = pos – 1
 
Answer: a
Explanation: When the element being searched is greater than the value at the calculated position then in that case we update low and high remains unaltered. Updated value of low is low = pos + 1.
 

Tìm kiếm

Back
Top