Educational Cards
Learn from video content, text, and interactive tasks
Filters
equals and hashCode contract
The Contract: if a.equals(b) , then a.hashCode() and b.hashCode() must be equal. equals must be...
ArrayList vs LinkedList
ArrayList stores elements in an array: get(i) is O(1), inserting/deleting in the middle is O(n) due...
Insertion and Deletion at Positions
Inserting after a known node p : the new node takes p.next , and then p.next points to the new...
Doubly Linked List
A doubly linked list stores prev and next . This makes insertions and deletions O(1) once the node...
Sorted List and compareTo
A sorted list maintains the invariant that consecutive elements are in non-decreasing order with...
Singly Linked List and Nodes
In a singly linked list, each node has a value and a reference next to its successor. The list head...
Iterator over Lists
An iterator encapsulates the current position in the list. hasNext and next traverse node by node...
ArrayStack in Java
An ArrayStack stores elements in an array and maintains the index top . push writes at top and...
Stack: LIFO and Typical Errors
A stack stores elements according to the LIFO principle: the last element added is the first one...
Euclidean Algorithm and Runtime
The Euclidean algorithm calculates the greatest common divisor (GCD) of a and b. The modulo variant...
When Stack, When Queue?
Stack and Queue solve different ordering problems. If the most recent element is needed first...
Queue: FIFO and Capacity
A queue stores elements in a FIFO manner: the first inserted element is the first to leave the...