Skip to content
Related Articles
Open in App
Not now

Related Articles

Data Structures | Linked List | Question 13

Improve Article
Save Article
  • Difficulty Level : Easy
  • Last Updated : 28 Jun, 2021
Improve Article
Save Article

What are the time complexities of finding 8th element from beginning and 8th element from end in a singly linked list?

Let n be the number of nodes in linked list, you may assume that n > 8.
(A) O(1) and O(n)
(B) O(1) and O(1)
(C) O(n) and O(1)
(D) O(n) and O(n)

Answer: (A)

Explanation: Finding 8th element from beginning requires 8 nodes to be traversed which takes constant time.

Finding 8th from end requires the complete list to be traversed.

Quiz of this Question

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!