The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+15 votes
3.7k views

Linked lists are not suitable data structures for which one of the following problems?

  1. Insertion sort

  2. Binary search

  3. Radix sort

  4. Polynomial manipulation

asked in DS by Veteran (59.8k points)
recategorized by | 3.7k views
0
How is it helpful in case of other algorithms?
0
@Adiaspirant My ans may address ur concern.

3 Answers

+24 votes
Best answer

Linked lists are suitable for:

Insertion sort: No need to swap here just find appropriate place and join the link

Polynomial manipulation: Linked List is a natural solution for polynomial manipulation 

Radix sort: Here we are putting digits according to same position(unit,tens) into  buckets; which can be effectively handled by linked lists.

Not Suitable for:

Binary search: Because finding mid element itself takes $O(n)$ time.

So, Option B is answer.

answered by Boss (23.6k points)
edited by
0
B also because Binary Search requires random access which isn't possible in case of Binary Search.
+20 votes
B. Because in binary search we need to have access to the mid of the list in constant time. and finding the mid itself in a linked list takes $O(n)$ time which makes no sense to Binary search which otherwise takes $O(\log n)$.
answered by Boss (19.9k points)
+8 votes

the answer is B.

 The binary search algorithm is based on the logic of reducing your input size by half in every step until your search succeeds or input  gets exhausted. The important point here is "the step to reduce input size should take constant time". In a case of an array, it's always a simple comparison based on array indexes that take O(1) time.

But in a case of Linked list, you don't have indexes to access items. To perform any operation on a list item, you first have to reach it by traversing all items before it. So to divide list by half you first have to reach the middle of the list then perform a comparison. Getting to the middle of the list takes O(n/2)[you have to traverse half of the list items] and comparison takes O(1).
Total = O(n/2) + O(1) = O(n/2)

So the input reduction step does not take constant time. It depends on list size. hence violates the essential requirement of Binary search.

answered by Junior (903 points)
edited by
0
please edit : answer as b
Answer:

Related questions

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,047 questions
53,188 answers
184,496 comments
70,394 users