1
You visited us
1
times! Enjoying our articles?
Unlock Full Access!
Byju's Answer
Other
Other
SLL-Traverse and Search
What is the t...
Question
What is the time complexity to count the number of elements in the linked list?
A
O(n)
Right on! Give the BNAT exam to get a 100% scholarship for BYJUS courses
B
O(1)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
C
O(log n)
No worries! We‘ve got your back. Try BYJU‘S free classes today!
D
None of the mentioned
No worries! We‘ve got your back. Try BYJU‘S free classes today!
Open in App
Solution
The correct option is
A
O(n)
To count the number of elements, you have to traverse through the entire list, hence complexity is O(n).
Suggest Corrections
3
Similar questions
Q.
What is the time complexity for searching on element in a doubly linked list and insertion of an element in a sorted linked list with n elements?
Q.
Given a circular doubly linked list whose content are sorted in ascending order, what is the run time complexity for inserting a new element into the list so that it remains correctly sorted? (Including the time required to search for the elements correct position)
Q.
What is the worst case time complexity of inserting a node in a doubly linked list?
Q.
Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What is the worst-case time complexity of the best-known algorithm to delete the node x form the list?
Q.
In the worst case, the number of comparisons needed to search singly linked list of length n for given elements is
View More
Join BYJU'S Learning Program
Grade/Exam
1st Grade
2nd Grade
3rd Grade
4th Grade
5th Grade
6th grade
7th grade
8th Grade
9th Grade
10th Grade
11th Grade
12th Grade
Submit
Related Videos
SLL-Traverse and Search
OTHER
Watch in App
Explore more
SLL-Traverse and Search
Other Other
Join BYJU'S Learning Program
Grade/Exam
1st Grade
2nd Grade
3rd Grade
4th Grade
5th Grade
6th grade
7th grade
8th Grade
9th Grade
10th Grade
11th Grade
12th Grade
Submit
AI Tutor
Textbooks
Question Papers
Install app