Free Online Flashcard Deck

04 Stacks and Queues Free Online FlashCards

Study 04 Stacks and Queues with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What does an abstract data type specify?

Back

An abstract data type specifies how data may be accessed and which operations are supported, without requiring a particular implementation.

02
Front

What access rule does a stack follow?

Back

A stack follows last-in, first-out (LIFO): the most recently inserted item is removed first.

03
Front

What are the fundamental stack operations?

Back

The fundamental stack operations are push, which adds an item, and pop, which removes and returns the top item.

04
Front

What are stack underflow and overflow?

Back

Underflow occurs when pop or peek is attempted on an empty stack. Overflow occurs when a fixed-capacity array stack receives a push while full.

05
Front

What is the time cost of an array-based stack?

Back

With available capacity, array-based push, pop, and peek take O(1) time. Resizing can make one push O(n), but geometric resizing gives amortized O(1) pushes.

06
Front

Why are linked-list stack push and pop operations O(1)?

Back

A linked-list stack keeps its top at the list head, so push and pop modify only the first node and take O(1) time.

07
Front

What access rule does a queue follow?

Back

A queue follows first-in, first-out (FIFO): the earliest inserted item is removed first.

08
Front

Which state variables manage a circular array queue?

Back

A circular array queue uses front for the next item to remove, rear for the next insertion position, and size for the item count.

09
Front

Why is a circular array better than a naïve array queue?

Back

A circular array avoids shifting remaining elements after dequeue, so enqueue, dequeue, and front can each take O(1) time.

10
Front

Why should a linked-list queue keep front and rear references?

Back

A linked-list queue should maintain both front and rear references, allowing enqueue and dequeue to take O(1) time.

11
Front

What must happen after the final linked-list queue dequeue?

Back

After removing the final node, a linked-list queue must set both front and rear to null so the empty state is represented correctly.

12
Front

Why can a stack support depth-first search?

Back

A stack is suitable for depth-first search because it restores and processes the most recently chosen unfinished path first.