Question discussion

Consider a singly linked list containing n elements in which A is the address of the starting node of the linked list. If we first convert…

358853Medium DSSSB TGT Computer Science 0 replies 0 views
0
Consider a singly linked list containing n elements in which A is the address of the starting node of the linked list. If we first convert the linked list to an array, then sort the array elements, and then create a new linked list from the elements of the sorted array, what is the number of operations required to traverse the linked list and store its data values ​in an additional array before applying sorting?
  • AOption A
  • BOption B
  • COption C
  • DOption D
Correct answer: C

Explanation

To copy all n elements of the linked list into an array we visit each node once, so the traversal takes O(n) operations.

Discussion 0

Nobody has replied yet. Start the discussion!