The Gateway to Computer Science Excellence

Linked List [closed]

+4 votes
4.2k views
Linked Lists are not suitable for _____.

A.    Binary Search
B.    Polynomial Manipulation
C.    Insertion
D.    Radix Sort
closed as a duplicate of: GATE1994-1.17, UGCNET-Sep2013-II-32
in DS by Junior (563 points)
closed by | 4.2k views

1 Answer

+4 votes
Best answer

Correct Answer would be A) Binary Search

Because, Its will take $O(n/2)$ times for finding the middle element of the Linked list. 

by Boss (35.7k points)
selected by
0
Why can;t we use binary search on a Linked List if all the elements of Linked List are in sorted order ?
+1
In sorted order, still we have to traverse to the middle of linked list which takes O(n/2) which is O(n) only .

but, this can be made O(log n) by augmenting linked list with extra pointers like DLL, called skip list so that we can move in both the directions. which can give O(log n ) but not always, bcoz still worst is O(n).
0
@kapil then why do we use binary search in sorted array ? we use the same concept there rt ? we can apply binary search on sorted array to get down the complexity upto O(logn) .don't we need to traverse there ?
+1
Sir, array uses indexing mechanism, we can directly goto a[ i ] and hence by direct access , we can compare our search element to middle element and then recur for left or right half..
0

@kapil thanks ...this indicates i know nothing about anything laugh

0
@shekhar sir,

your doubts help me very much to revise all the concepts and be up to date...

keep it up sir,,, :)
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
50,737 questions
57,292 answers
198,237 comments
104,919 users