If the recursive approach of linear search is used to search a key in a linked list of n elements, then what are the time and space complexity to search an…
If the recursive approach of linear search is used to search a key in a linked list of n elements, then what are the time and space complexity to search an element in a linked list?
Show answerHide answer
Correct answer: (D) Time Complexity = O(n), Space Complexity = O(n)
Explanation
Recursive search makes up to n calls, so the time is O(n). Each pending call uses a stack frame, so the space is also O(n).