900 views
0 votes
0 votes
With regard to linked list, which of the following statement is false ?

(A) An algorithm to search for an element in a singly linked list requires 0(n)
operations in the worst case.
(B) An algorithm for deleting the first element in a singly linked list requires 0(n)
operations in the worst case.
(C) An algorithm for finding the maximum value in a circular linked list requires 0(n)
operations.
(D) An algorithm for deleting the middle node of a circular linked list requires 0(n)
operations.

2 Answers

Best answer
1 votes
1 votes
Option b:

We know that inorder to search for an element we have to compare each element until not found and in worst case it would be last so o(n)is true (we cannot apply binary search on linked list /unsorted list so complexity cannot be reduced).

Now in order to delete first element we have to modify head(start) and it will only take some constant time so o(1).

Again for option c we have to search for maximum element and that will take o(n).

Again for going to middle we will have go one after to other node to reach middle and for large value of n we assume complexity o(n).

So option b is false
selected by
0 votes
0 votes

Option (b). An algorithm for deleting the first element in a singly linked list requires O(1) operations. The start pointer needs to point to the second element in the list. The first element is to be freed afterwards. 

Related questions

–1 votes
–1 votes
0 answers
1
Pawan Kumar 2 asked Dec 21, 2017
314 views
Insertion at beginning and end ....both require theta(n) ?
0 votes
0 votes
1 answer
2
cse23 asked Sep 9, 2016
566 views
To insert a node at the end of double linked list we need to modify two pointers right??But answer given is one pointer.can someone clarify?
2 votes
2 votes
0 answers
3