The element being searched for is not found in an array of
100 elements. What is the average number of comparisons
needed in a sequential search to determine that the element
is not there, if the elements are completely unordered?

Answers were Sorted based on User's Feedback



The element being searched for is not found in an array of 100 elements. What is the average number..

Answer / anirban lahiri

Allmost 50 comparison's are required. Because if we use
double pointer instead of single pointer and we run the
algo. untill we get that element. But that ele. is not in
that unordered list then the algo will stop and produces
"No match is found", when the pointers are superimpossed to
each other. That is we set an algo. of two pointer's in the
front and rear end and when each time the matching is not
found then one pointer is go on increasing and the other
one is go on decreasing( in location ).

Is This Answer Correct ?    6 Yes 24 No

Post New Answer

More Data Structures Interview Questions

What is linked list in data structure?

0 Answers  


Is treemap thread safe?

0 Answers  


how to search an element in sorted linked list with time complexity is O(log n).

3 Answers   Wipro,


Convert following infix expression to the prefix expression. a - b + c * (d / e - (f + g))

33 Answers   Amazon, Microsoft, Star Technologies, Sun Microsystems, Wipro,


How do you sort an array in descending order?

0 Answers  






What is breadth first tree?

0 Answers  


Why do we need to recycle?

0 Answers  


What do you mean by double hashing?

0 Answers  


What is difference between map and hashmap?

0 Answers  


Explain in brief a linked list.

0 Answers  


Which data structure is used in arraylist?

0 Answers  


1) Program A and B are analyzed and found to have worst- case running times no greater than 150nlog2n and n2 respectively.Answer the folloWing questions if possible.. i) which program has the better guarantee on the running time,for larger values of n(n>10000) ? ii) which program has the better guarantee on the running time,for small values of n(n<100) ? iii) which program will run faster on average for n =1000 2) wRite a program to compute the number of collisions required in a long random sequence of insertions using linear probing ,quadratic probing and double hashing 3) what is the optimal way to compute A1 A2 A3 A4 A5 A6 where the dimensions of the matrices are A1:10*20 A2 : 20 * 1 A3 : 1 * 40 A4 : 40*5 A5 : 5 * 30 A6 : 30 X 15

5 Answers   KPIT,


Categories