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 / nishant singh

Binary search is faster because we traverse the elements by
using the policy of Divide and Conquer.
we compare the key element with the approximately center
element, if it is smaller than it search is applied in the
smaller elements only otherwise the search is applied in the
larger set of elements.
its complexity is as we all know is log n as compared to the
sequential one whose complexity is n.

Is This Answer Correct ?    30 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When would you use a tuple?

484


Complete structure of hashmap, very detail description, along with the basic coding of the hashmap internal implementation.

636


Can you override methods of arraylist?

501


What is data structure definition?

500


How is the front of the queue calculated ?

724






Why merge sort is better than insertion sort?

478


How many passes does bubble sort need?

494


Define a Deque?

610


Can we store null in arraylist?

473


Differentiate file structure from storage structure?

514


What is the use of sorting the data?

557


Is list a data type?

502


How can a binary tree be represented using the rotation?

542


Is treemap synchronized?

532


What actions are performed when a function is called?

573