The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
0 votes
Why linked list not suitable for binary search?
asked in DS by (25 points) | 205 views

2 Answers

+2 votes
Best answer
There is no way to index the elements in the linked list which makes it unsuitable for binary search.
answered by Active (1.6k 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)$.
+1 vote
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 (35 points)

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true

29,017 questions
36,844 answers
34,721 users