🌍 Data Structures & Algorithms · flashcards

Data Structures & Algorithms Linear Data Structures Flashcards

50 question-and-answer cards covering Linear Data Structures as it is examined in Data Structures & Algorithms. 24 of them are printed below, taken from across the deck — no signup, no paywall on the preview.

50Cards in deck
24Free preview
14Syllabus topics
~149Chars per answer
FreePrice

24 sample cards from the Linear Data Structures deck

Sampled from the end of the deck, so these are different cards from the ones shown on the syllabus page.

  1. How do you delete a node given only a pointer to it (not the head) in a singly linked list?

    Copy the next node's data into the current node, then bypass the next node by setting current.next = current.next.next. This fails only for the tail node.

  2. What is a sentinel (dummy) node and why is it useful in linked lists?

    A placeholder node before the head that removes special-case handling of empty lists or head insertions/deletions, simplifying code.

  3. How do you merge two sorted linked lists into one sorted list?

    Use a dummy head and repeatedly attach the smaller of the two current nodes, advancing that pointer, until one list is exhausted; append the remainder. Time $O(n + m)$.

  4. Define the Stack ADT and its ordering discipline.

    A stack is a linear collection with Last-In-First-Out (LIFO) order: the most recently added element is the first removed.

  5. Name the core stack operations and their time complexities.

    push (add to top), pop (remove top), peek/top (view top), isEmpty — all $O(1)$.

  6. What error conditions are associated with stack operations?

    Stack overflow (push onto a full fixed-capacity stack) and stack underflow (pop or peek on an empty stack).

  7. Compare array-based and linked-list-based stack implementations.

    Array-based: cache-friendly, may need resizing, possible fixed capacity. Linked-list-based: grows dynamically with no resizing, but uses extra memory per node and has poorer locality. Both give $O(1)$ push/pop.

  8. How is a stack used to check balanced parentheses?

    Push each opening bracket; on a closing bracket, pop and verify it matches. The string is balanced if every close matches and the stack is empty at the end.

  9. Which traversal order does the call stack impose, and name one stack application in expression handling.

    LIFO. Applications include evaluating postfix expressions, converting infix to postfix, and function call management / recursion unwinding.

  10. How do you evaluate a postfix (RPN) expression with a stack?

    Push operands; on an operator, pop the top two operands, apply it, and push the result. The final remaining value is the answer. Time $O(n)$.

  11. Define the Queue ADT and its ordering discipline.

    A queue is a linear collection with First-In-First-Out (FIFO) order: the earliest added element is the first removed.

  12. Name the core queue operations and their time complexities.

    enqueue (add at rear), dequeue (remove from front), front/peek, isEmpty — all $O(1)$ with a proper implementation.

  13. Why is a circular array preferred over a plain array for queue implementation?

    A circular array reuses freed front slots by wrapping indices with modulo, giving $O(1)$ enqueue/dequeue without shifting elements or wasting space.

  14. In a circular queue of capacity $C$, how are the rear and front indices advanced?

    Using modular arithmetic: $\text{rear} = (\text{rear} + 1) \bmod C$ and $\text{front} = (\text{front} + 1) \bmod C$.

  15. What is a deque (double-ended queue)?

    A linear structure allowing insertion and removal at both the front and the rear, each in $O(1)$. It generalizes both stacks and queues.

  16. What is a priority queue and how does it differ from an ordinary queue?

    A priority queue dequeues the element with the highest priority rather than the earliest inserted. It is typically backed by a heap, giving $O(\log n)$ insert and extract.

  17. What is a circular queue and one problem it solves?

    A queue whose storage wraps around a fixed-size array. It avoids the wasted-space problem of a linear array queue where front advances but freed slots cannot be reused.

  18. What is a monotonic queue and what invariant does it maintain?

    A deque that keeps its elements in strictly increasing or decreasing order by discarding elements that violate the order before inserting a new one, enabling $O(1)$ min/max queries.

  19. How does a monotonic deque compute the maximum of every sliding window of size $k$?

    Maintain a decreasing deque of indices: pop smaller values from the back before pushing, pop the front if it falls outside the window; the front holds the window max. Total time $O(n)$.

  20. Why does the sliding-window-maximum monotonic-queue algorithm run in $O(n)$ despite nested pops?

    Each element is pushed and popped from the deque at most once, so the total number of operations is bounded by $2n$, giving amortized $O(1)$ per element.

  21. How do you implement a queue using two stacks?

    Use an 'in' stack for enqueue. For dequeue, if the 'out' stack is empty, pop all elements from 'in' into 'out' (reversing order), then pop from 'out'. Amortized $O(1)$ per operation.

  22. How do you implement a stack using two queues (making push costly)?

    On push, enqueue the new element into the empty queue, then move all elements from the other queue behind it, so the newest is always at the front. Push is $O(n)$; pop/top are $O(1)$.

  23. Compare LIFO and FIFO structures with a real-world example of each.

    LIFO (stack): browser back button / undo history. FIFO (queue): a printer job queue or people waiting in line. Stack removes newest first; queue removes oldest first.

  24. Summarize the average time complexities for array, linked list, stack, and queue on their primary operations.

    Array: access $O(1)$, insert/delete $O(n)$. Linked list: access $O(n)$, head insert/delete $O(1)$. Stack: push/pop/peek $O(1)$. Queue: enqueue/dequeue $O(1)$.

What this deck covers

The Linear Data Structures deck follows the Data Structures & Algorithms Linear Data Structures syllabus — 4 chapters and 14 topics — so questions land on material that is genuinely examinable rather than trivia around it. That works out to roughly 12.5 cards per chapter.

Answers are written to be recallable, not just readable — averaging about 149 characters, which is long enough to carry the reasoning and short enough to say out loud.

A deck like this earns its keep on the second and third pass. Read the syllabus first so you know the shape of the subject, then use the cards to find the specific facts that have not stuck.

Linear Data Structures flashcards FAQ

How many Linear Data Structures flashcards are in this Data Structures & Algorithms deck?

50 cards. This page previews 24 of them, sampled evenly across the deck so you can judge the difficulty before installing anything.

Are these Data Structures & Algorithms flashcards free?

Yes. The preview here is free to read with no signup, and the full 50-card deck is free inside the Examius app.

What do the Linear Data Structures cards cover?

They follow the Data Structures & Algorithms Linear Data Structures syllabus — 4 chapters and 14 topics — so the questions track what is actually examinable.

How should I use these flashcards?

Read the syllabus first so you know the shape of the subject, then drill the deck. Examius schedules each card with spaced repetition, so cards you keep missing come back sooner and ones you know drift further apart.