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 / ahan

The binary search is faster than the sequential search.The
complexity of binary search is 'log n' where as the
complexity of sequential search is 'n'.Since each time we
are proceeding we have to deal with only half of the
elements of the array than the previous one.So we can easily
get a number from an array of elements through binary search
than sequential search.

Is This Answer Correct ?    12 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What data type is enum?

681


What is best time complexity?

611


What is an algorithm in coding?

595


What is modcount in hashmap?

643


How to compare Two Arrays?

727


How are the elements of a 2d array are stored in the memory?

777


What is difference between capacity and size of arraylist?

789


What’s the difference between enumeration and iterator interfaces?

677


How do you empty an arraylist?

668


What is sorting and classifying?

661


Will hashmap allow null keys?

670


in tree construction which is the suitable efficient data structure? (Array, linked list, stack, queue)

926


Are the expressions arr and &arr same for an array of integers?

757


What are the issues that hamper the efficiency in sorting a file?

759


How do you define a set?

655