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
Is hashmap faster than arraylist?
What is the difference between hashmap and linkedhashmap?
What are the drawbacks of array implementation of queue?
an array t[100] which contains numbers between 1..99. Return the duplicated value. Try both O(n) and O(n-square).
Explain the priority queue?
Explain different methods in which you can traverse a tree?
How will you check the validity of an expression containing nested parentheses?
Why is arraylist faster than linkedlist?
Why quicksort is better than merge sort?
Why do we use arrays?
If you are using c language to implement the heterogeneous linked list, explain what pointer type will you use?
How would you implement two stacks using a single array?
Why null is allowed in hashmap?
Name some applications which use linked lists.
What is meant by deque?