Skip to content
Related Articles

Related Articles

Save Article
Improve Article
Save Article
Like Article

GATE | GATE CS 1996 | Question 38

  • Difficulty Level : Medium
  • Last Updated : 03 Jul, 2020

The average number of key comparisons done in a successful sequential search in a list of length it is
(A) log n
(B) (n-1)/2
(C) n/2
(D) (n+1)/2

Answer: (D)

Explanation: If element is at 1 position then it requires 1 comparison.
If element is at 2 position then it requires 2 comparison.
If element is at 3 position then it requires 3 comparison.
Similarly , If element is at n position then it requires n comparison.

Total comparison 
= n(n+1)/2

For average comparison 
= (n(n+1)/2) / n 
= (n+1)/2 

Option (D) is correct.

Quiz of this Question

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

My Personal Notes arrow_drop_up
Recommended Articles
Page :