13 views
LIST-SEARCH’(L, k)
1     x = L.nil.next
2     while x != L.nil and x.key != k
3     x = x.next
4     return x

As written, each loop iteration in the LIST-SEARCH’ procedure requires two tests: one for $x\neq L.nil$ and one for $x.key\neq k$. Show how to eliminate the test for $x\neq L.nil$ in each iteration.

| 13 views