What is the average number of comparisons needed in a
sequential search to determine the position of an element in
an array of 100 elements, if the elements are ordered from
largest to smallest?
Answer Posted / nilavalagan
The element may be found at any place in the array.
Supposing that the element is in 1st position, no.of comparison = 1;
Element is in 2nd position, no.of comparison = 2;
In the same way,
for the element present in 100th positionn no.of comparison = 100;
Total no.of comparison = 1+2+3+....+100
Average no.of comparison = (1+2+3+..+100)/100
= (100*101)/2*100
(Remember n(n+1)/2)
=101/2 = 50.5
In general = (n+1)/2; if there are n elements.
| Is This Answer Correct ? | 15 Yes | 0 No |
Post New Answer View All Answers
Which sorting is stable?
What is collision in data structure?
Is linkedlist thread safe?
What is meant by deque?
Mention some drawbacks of the linked list.
What is storage structure in data structure?
Which is faster hashmap or treemap?
Why is sorting important?
What do you mean by balanced trees?
How do you perform a merge sort?
What is data structure and why we need it?
How do hash tables work?
Sorting is not possible by using which of the methods?
What is structure of data type?
Construct a doubly linked list using a single pointer in each node?