Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please respond if you are familiar with this problem Thanks Describe an algorith

ID: 3553835 • Letter: P

Question

please respond if you are familiar with this problem


Thanks


Describe an algorithm to find the middle node (or element) of a singly Iinked Iist in one pass, is, your algorithm will traverse the list starting from the head of the list and ending at the last node with the answer. You can use temporary variable in your algorithm What would be the run-time complexity and space complexity of your algorithm representing in BIG-O notation Describe the best case and the worst case scenarios and their run-time complexity of your algorithm above

Explanation / Answer

1.for the function to find the mid of a linked list.

Initialize 2 pointer both pointing to the head of the list initially.
Now increment the first one by 2 places and keep the second one at rest. Keep moving the first pointer by 2 places and for each move of first pointer move the second pointer by one position. When the first pointer reaches to the end of linked list, second pointer will be pointing to the mid node.