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

What is different between array and list?

495


Are collections thread safe?

468


Why do we use sorting?

476


Can we extend an array after initialization?

580


What is the space complexity of bubble sort?

524






Explain what do you mean by insertion sort, bubble sort and selection sort? Also, explain the differences among the functionalities of the three sorts.

588


Is array immutable?

507


What is unbounded queue?

491


Define a path in a tree?

528


How is hashmap o 1?

486


Define separate chaining?

545


Is arraylist a collection?

520


How would you swap the Kth node from beginning with Kth node from end in a Linked List.

565


How can avl tree be useful in all the operations as compared to binary search tree?

476


Can you tell me the differences between Array and ArrayList?

602