Question: Write invariants at the indicated space in the following functions.
bool
sequentialSearch(ListNode *head, int key) {
for(ListNode *n = head; n; n = n->next) {
// INVARIANT: ??
if(n->data == key) return true;
}
return false;
}
Answer: The key is not in any of the nodes in the list prior to n.