recategorized by
23,423 views
35 votes
35 votes

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

recategorized by

4 Answers

Best answer
44 votes
44 votes

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.

edited by
28 votes
28 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)$.
13 votes
13 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.

edited by
4 votes
4 votes

Correct Answer would be A) Binary Search

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

Answer:

Related questions

34.2k
views
6 answers
33 votes
Kathleen asked Oct 4, 2014
34,161 views
Which of the following permutations can be obtained in the output (in the same order) using a stack assuming that the input is the sequence $\text{1, 2, 3, 4, 5}$ ... $\text{5, 4, 3, 1, 2}$
29.1k
views
12 answers
78 votes
Kathleen asked Oct 4, 2014
29,068 views
In a compact single dimensional array representation for lower triangular matrices (i.e all the elements above the diagonal are zero) of size $n \times n$, non-zero elements, (i.e elements of ... $i+\frac{j(j-1)}{2}$
4.7k
views
2 answers
1 votes
go_editor asked Jul 20, 2016
4,673 views
The efficient data structure to insert/delete a number in a stored set of number isQueueLinked listDoubly linked listBinary tree
7.7k
views
3 answers
32 votes
Kathleen asked Oct 5, 2014
7,677 views
A queue $Q$ containing $n$ items and an empty stack $S$ are given. It is required to transfer all the items from the queue to the stack, so that the ... Delete, Insert, Push and Pop. Do not assume any implementation of the queue or stack.