InterviewSolution
Saved Bookmarks
| 1. |
In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is?(a) log2 n(b) ^n⁄2(c) log2 n – 1(d) nThe above asked question is from Singly Linked List Operations topic in portion Abstract Data Types of Data Structures & Algorithms IThe question was asked in quiz. |
|
Answer» CORRECT answer is (d) n The BEST I can explain: The worst-case happens if the REQUIRED ELEMENT is at last or the element is absent in the list. For this, we need to compare every element in the linked list. If n elements are there, n COMPARISONS will happen in the worst case. |
|