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
Explain multiply linked list in short.
What do you mean by double hashing?
Can we add duplicate keys in a hashmap?
Is a hashmap a dictionary?
What are linear and non linear data structures?
How to initialize Dictionary using collection initialize?
Why do we use hashmap?
What is meant by heap sort?
How to find the missing element in integer array of 1 to 7?
List the basic operations carried out in a linked list?
What do you mean by spanning tree?
Is list an array?
Explain binary searching, Fibonacci search.
Why null is not allowed in treemap?
What are types of Collision Resolution Techniques and the methods used in each of the types?