GATE CSE
First time here? Checkout the FAQ!
x
0 votes
135 views
Why linked list not suitable for binary search?
asked in DS by (25 points)   | 135 views

2 Answers

+1 vote
Best answer
There is no way to index the elements in the linked list which makes it unsuitable for binary search.
answered by Junior (603 points)  
selected by
We use binary search to reduce the search complexity to $O(\log n)$ but in a linked list to find the middle element itself takes $O(n)$.
Thanku
0 votes
Because nodes of linked list may or may not be present in the continuous memory location, so we can only use linear search while array occupies continuous memory location, so a binary search is possible.
answered by (17 points)  


Top Users May 2017
  1. akash.dinkar12

    3338 Points

  2. pawan kumarln

    2108 Points

  3. Bikram

    1922 Points

  4. sh!va

    1682 Points

  5. Arjun

    1614 Points

  6. Devshree Dubey

    1272 Points

  7. Debashish Deka

    1208 Points

  8. Angkit

    1056 Points

  9. LeenSharma

    1018 Points

  10. Arnab Bhadra

    812 Points

Monthly Topper: Rs. 500 gift card
Top Users 2017 May 22 - 28
  1. Bikram

    1008 Points

  2. pawan kumarln

    734 Points

  3. Arnab Bhadra

    726 Points

  4. Arjun

    342 Points

  5. bharti

    328 Points


22,893 questions
29,196 answers
65,302 comments
27,695 users