I need a solution verification. I could not find the tag so if anyone could assist me on that. Question is below.
Let A [1..n] be a max-heap with n elements. Assuming there are no duplicate keys.
Write pseudocode for finding the smallest element in A. Then find the RT using O-notation
My attempt:
minIndex=1
min=A[1]
i=0
while(i <= n)
if A[i]<min
min=A[i]
minIndex = i
i+=1
Assuming that the pseudocode is correct. Does the max-heap change anything?
The running time is O(n).