why binary search does not work for linked list even when it

why binary search does not work for linked list, even when it is sorted?

Solution

1.Binary search is unable to acess strightly for a linkedx list since the memory is adjoining.

2.To contrast the item through the central element in sorted linked list it is necessary to traverse the selected segment of a linked list,Because the linked list is an sequential manipulation.

3.Hence the total manipulation needs O(n^2):O(n) duration to know the central element and further O(n) to contrast.

4.It leads the total usage of binary search to decrease the current searching duration in half in every step for a constant time.so it is good and highly efficient to utilize the linear search.

.

why binary search does not work for linked list, even when it is sorted?Solution1.Binary search is unable to acess strightly for a linkedx list since the memory

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site