Which one is faster?
A binary search of an orderd set of elements in an array
or
a sequential search of the elements.

Answer Posted / ujjwal dave

binary search is faster and more useful in case we need to
perform search a number of times, complexity of sequential
search will be n each time where in binary search will take
more time only at first time when data is not sorted once
the data is sorted......it will take only only log n
attempts to search each element.......so the decision also
depends on frequency of the data beign searched

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can array store heterogeneous data?

463


What are the applications of priority queues?

524


Why do we use dynamic arrays?

466


How many types of lists are there?

524


Why hashmap is faster than hashset?

496






What is a minimum spanning tree?

556


Define shortest path?

571


What is mean by selection sort?

495


What is stable sort example?

506


What is stack algorithm?

471


What is difference between hashtable and hashmap?

512


We know that Arrays are objects so why cannot we write strArray.length()?

1107


What is rule regarding overriding equals and hascode method?

506


What is a map in programming?

449


Can arraylist contain null?

468