Skip to content

Commit 6e39000

Browse files
fix(datastructures): prevent null dereference in SelfOrganizingLinkedList
1 parent 88d9ba2 commit 6e39000

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/main/java/com/thealgorithms/datastructures/lists/SelfOrganizingLinkedList.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public boolean search(E key) {
6868
return true;
6969
}
7070

71-
LinkedList<E> prev = null;
72-
LinkedList<E> curr = head;
71+
LinkedList<E> prev = head;
72+
LinkedList<E> curr = head.next;
7373

7474
while (curr != null && !Objects.equals(curr.value, key)) {
7575
prev = curr;

0 commit comments

Comments
 (0)