Searching a linked list?



I a trying to understand this pseducode:

L = {9,16,4,1}

LIST-SEARCH(L,k)
1 x <- head[L]
2 while x != NIL and key[x] != k
3 do x <- next[x]
4 return x

head[L] points to the head.

In line 1 head[L] gets assigned to x.

Does x equal 9 or 1 (if we assume that the first element in a list starts a
index 1) after this assignment?

.



Relevant Pages