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
What is different between array and list?
Are collections thread safe?
Why do we use sorting?
Can we extend an array after initialization?
What is the space complexity of bubble sort?
Explain what do you mean by insertion sort, bubble sort and selection sort? Also, explain the differences among the functionalities of the three sorts.
Is array immutable?
What is unbounded queue?
Define a path in a tree?
How is hashmap o 1?
Define separate chaining?
Is arraylist a collection?
How would you swap the Kth node from beginning with Kth node from end in a Linked List.
How can avl tree be useful in all the operations as compared to binary search tree?
Can you tell me the differences between Array and ArrayList?