Computer Science, asked by mounikatv8028, 1 month ago

write the algorithm to find the middle of a linked list.​

Answers

Answered by ItzMrAlcohol
3

Answer:

Create a pointer p , pointing to the head.

Iterate over the linked list until p reaches to the end of the linked list, thereby find the length of the list.

Set p to head again. Now, increment p length/2 times. Now, the p is at the middle of the linked list node. Return the value at p.

Explanation:

Similar questions