retagged by
292 views
0 votes
0 votes

https://gateoverflow.in/840/gate2002-2-10

SUPPODE IN THIS QUESTION I TAKE A EXAMPLE LIKE 

UNSORTED ARRAY 3   1    2     4

INDEX                       0    1   2     3            and we need to find element x=4 

NOW SUPPOSE I AM APPLY ABOVE ALGO let i=2 checking A[i] with x not matched 

so go to step 1 again we choose any random i then suppose again unmatched 

so my doubt is that how we are ensuring that i will be different in each iteration ...and scond doubt is that at each iteration the number of comparision is only one so how expected comparision is n

retagged by

Please log in or register to answer this question.

Related questions

0 votes
0 votes
1 answer
1
tusharb asked Feb 18, 2022
713 views
As we know the time complexity of solving the greedy knapsack algorithm depends mainly on the sorting algorithm used, Can we use counting sort as the sorting algorithm to...
1 votes
1 votes
1 answer
2
afroze asked Nov 4, 2021
588 views
what is significance of loop Invariant?when we use a loop in an algo we check it , if it properly runs then fix it in that, then why do check separately loop invariant ?
1 votes
1 votes
1 answer
3
kumar.dilip asked Jan 19, 2019
701 views
The average no. of comparisons performed by the merge sort algorithm, in merging 2 sorted lists of length 2 is___________.Ans: $\frac{8}{3}$
0 votes
0 votes
1 answer
4
Prince Sindhiya asked Jan 19, 2019
350 views
When relative ordering of equal keys is preserved after sorting then it is called stable. Quick sort and heap sort is not a stable sorting algorithm . Doubt -IS Select...