Open In App
Related Articles

ISRO | ISRO CS 2018 | Question 34

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

Consider a singly linked list of the form where F is a pointer to the first element in the linked list and L is the pointer to the last element in the list. The time of which of the following operations depends on the length of the list?

(A)

Delete the last element of the list

(B)

Delete the first element of the list

(C)

Add an element after the last element of the list

(D)

Interchange the first two elements of the list



Answer: (A)

Explanation:

Interchange the first two elements of the list: To interchange the first two elements of the list, we can simply update the head pointer of the list to point to the second element and update the next pointer of the second element to point to the first element. This can be done in constant time, regardless of the length of the list.



Quiz of this Question
Please comment below if you find anything wrong in the above post

Last Updated : 03 Jul, 2018
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads