Free Online Flashcard Deck

10 Data Structure and Algorithm Trade-offs Free Online FlashCards

Study 10 Data Structure and Algorithm Trade-offs with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What factors guide data-structure selection?

Back

Choose a structure by considering required operations, their frequency, data properties, memory and locality, correctness constraints, and maintainability.

02
Front

What are key dynamic-array operation costs?

Back

A dynamic array provides O(1)O(1) indexing and amortized O(1)O(1) appending, but insertion or deletion in the middle is O(n)O(n) because elements move.

03
Front

What is linked-list access time by position?

Back

Accessing position ii in a linked list is O(n)O(n), because nodes must be followed sequentially from a known starting point.

04
Front

What processing order does a stack enforce?

Back

A stack follows last-in, first-out order: `push` adds an item, `pop` removes the newest item, and `peek` inspects it.

05
Front

What processing order does a queue enforce?

Back

A queue follows first-in, first-out order: `enqueue` adds at the rear, while `dequeue` removes the oldest item from the front.

06
Front

How does balance affect BST operation costs?

Back

A balanced BST typically supports search, insertion, and deletion in O(log⁡n)O(\log n); an unbalanced BST can degrade to O(n)O(n).

07
Front

What is the typical hash-table complexity profile?

Back

A hash table offers expected O(1)O(1) exact-key lookup, insertion, and deletion with a good hash function and controlled load factor, but its worst case is O(n)O(n).

08
Front

What is binary search’s comparison complexity?

Back

Binary search takes O(log⁡n)O(\log n) comparisons by repeatedly halving a sorted search interval.

09
Front

What trade-off does a sorted array create?

Back

A sorted array combines O(log⁡n)O(\log n) binary search with O(n)O(n) insertion, because inserting at the correct position moves elements.

10
Front

What distinguishes merge sort?

Back

Merge sort has O(nlog⁡n)O(n\log n) worst-case time, is stable, and suits linked lists or external data; typical array implementations need extra storage.

11
Front

What three elements make recursion correct?

Back

A recursive function needs a base case, progress toward that case, and a way to combine recursive results.

12
Front

What is the total cost of sorting once and doing mm binary searches?

Back

The total is O(nlog⁡n+mlog⁡n)O(n\log n+m\log n): O(nlog⁡n)O(n\log n) to sort once plus O(mlog⁡n)O(m\log n) for mm binary searches.