diff --git a/01-stacks/.idea/vcs.xml b/01-stacks/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/01-stacks/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/03-lists/LinkedList.cpp b/03-lists/LinkedList.cpp index 1e3dead..8168b90 100644 --- a/03-lists/LinkedList.cpp +++ b/03-lists/LinkedList.cpp @@ -118,12 +118,13 @@ bool LinkedList::searchList(string target, Park &dataOut) const { pCur = head->next; // While pCur points to a node, traverse the list. - while (pCur && pCur->park.getCode() != target) { + // Since the list is sorted, we can stop when the target is less than the current node. + while (pCur && pCur->park.getCode() < target) { pCur = pCur->next; } // If the target was found, copy the data - if (pCur) { + if (pCur && pCur->park.getCode() == target) { dataOut = pCur->park; found = true; }