The Student Room Group

What does the following pseudocode do with list? Singly linked list

Assume that list is a singly linked list with more than 1 element and identified by a pointer to its head.
What does the following pseudocode do with list?

Function foo( head, x ):
p <- head
IF NOT(p = NULL) AND p.info = x THEN
head = p.next
WHILE NOT (p = null OR p.next = NULL)
IF p.next.info = x
p.next = p.next.next
ELSE p = p.next

Quick Reply

Latest

Trending

Trending