Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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?

Answers were Sorted based on User's Feedback



What is the average number of comparisons needed in a sequential search to determine the position o..

Answer / abhishek chakladar

though average number of comparison of sequential search is (N+1)/2 then in the question N=100 so that the answer will be (100+1)/2
=101/2
=50.5

Is This Answer Correct ?    1 Yes 0 No

What is the average number of comparisons needed in a sequential search to determine the position o..

Answer / ruchi baghel

it require n comparison where n=position of the element


if element is on 50th position
we just require 50 comparison bcz it is sequential search
one by one

Is This Answer Correct ?    1 Yes 0 No

What is the average number of comparisons needed in a sequential search to determine the position o..

Answer / gianni

sorry, the reduced formula should have been

n(1-p/2)+p/2

I forgot a space between the "to" and the "n"

Is This Answer Correct ?    0 Yes 0 No

What is the average number of comparisons needed in a sequential search to determine the position o..

Answer / sandep

all are correct

Is This Answer Correct ?    0 Yes 0 No

What is the average number of comparisons needed in a sequential search to determine the position o..

Answer / mohit0749

I think it we can apply binary search which requires only logn comparison becoz elements are ordered (largest to smallest).

Is This Answer Correct ?    0 Yes 0 No

What is the average number of comparisons needed in a sequential search to determine the position o..

Answer / ranjit

Gianni, Your answer would be correct if the list was unordered. Since it is a sorted list (descending order), one does not have to go through the whole list in order to determine that the element is not present. Thus, the problem is to simply traverse the list until you find a number <= the number, x, you are looking for. This can be done with (n+1)/2 comparisons on average. Probability of x being present in the list is not a factor.

Shyam, as I explained in the above para, the fact that the list is sorted is relevant. If it was unsorted, Gianni would be absolutely right.

Is This Answer Correct ?    0 Yes 1 No

What is the average number of comparisons needed in a sequential search to determine the position o..

Answer / gianni

the above answer of n+1/2 is correct if you assume it will
always be a successful search. you also need to take into
account the probability of the item NOT being in the list.
as such your final formula is actually

p/n * n(n+1)/2 + n(1-p) where p is the probability that the
item is in the list. That formula can be reduced ton(1-p/2)+p/2
assuming a probability of .5, you wind up with an answer of
(3n+1)/4 or ~3/4 of the list will be searched on average.

Is This Answer Correct ?    0 Yes 2 No

What is the average number of comparisons needed in a sequential search to determine the position o..

Answer / malli

i think data is insufficient.

Is This Answer Correct ?    3 Yes 11 No

What is the average number of comparisons needed in a sequential search to determine the position o..

Answer / prasad

n comparisons.

Is This Answer Correct ?    9 Yes 25 No

Post New Answer

More Data Structures Interview Questions

What is binary tree and its properties?

0 Answers  


What is stack in geography?

0 Answers  


Write a program for reversing the Single Linked List?

0 Answers   Honeywell, Zomato,


What are data and data types?

0 Answers  


Why do we need sorting?

0 Answers  


Which is the parent class of printerstatereasons class?

0 Answers  


“int a[] = new int[3]{1, 2, 3}” – This a legal way of defining the arrays?

0 Answers  


Why is hashmap used?

0 Answers  


Why do we use a multidimensional array in data structure?

0 Answers  


What is a static structure?

0 Answers  


an array of size N in which every number is between 1 and N, determine if there are any duplicates in it. You are allowed to destroy the array if you like. [ I ended up giving about 4 or 5 different solutions for this, each supposedly better than the others ].

0 Answers  


Is list same as array?

0 Answers  


Categories