Category

Linear structures

These articles are about values kept in a line, where the useful end matters more than a random index. A linked list is walked by following pointers. A stack, and the call stack, give back the latest value first. A queue gives back the earliest. A deque uses both ends.

  1. What Is a Linked List? Pointers Instead of Indexes

    A linked list stores each value in a node with a pointer to the next node. You cannot jump to an index, but rewiring a pointer you already hold is O(1).

  2. What Is a Stack? Last-In First-Out and Bracket Matching

    A stack is last in, first out: push and pop touch only the most recent item, both O(1) at the end of an array. Bracket matching uses that order, because a counter cannot remember which opener is still waiting.

  3. What Is the Call Stack? Frames, Returns, and Recursion

    The call stack is the stack the runtime uses for calls. Each call pushes a frame and each return pops it, which is why recursion without a base case overflows instead of spinning in one loop.

  4. What Is a Queue? FIFO Order, Enqueue, and Dequeue

    A queue is first in, first out: enqueue joins the back and dequeue leaves from the front. Breadth-first search is that rule with vertices as the payload, and Array.shift on the front is O(n).

  5. What Is a Deque? Constant-Time Access at Both Ends

    A deque is a double-ended queue: values can enter or leave at either end. A doubly linked implementation makes all four end operations O(1), supporting sliding windows and both queue and stack behaviour.

  6. What Are the Three Pointers in a Linked-List Reversal?

    Reversing a linked list keeps previous, current, and the next node you are about to lose. You save next before you overwrite current.next.

  7. How Do Slow and Fast Pointers Measure a Linked List?

    Runner pointers turn relative movement into distance: one-and-two-step speeds find a middle, while a fixed head start finds a node from the end.

  8. How Does a Monotonic Stack Find the Next Greater Value?

    A monotonic stack keeps unresolved indexes in decreasing-value order. Each later value resolves every smaller value on top.