Data Structures Flashcards

1
Q

What is a linked list, and what are its key operations?

A

A linked list is a linear data structure with nodes containing data and a pointer to the next node. Key operations: insertion (O(1)), deletion (O(1) with pointer), traversal (O(n)).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a binary search tree (BST)?

A

A tree where each node’s left child has a smaller value, and right child has a larger value. Supports search, insertion, and deletion in O(log n) average case, O(n) worst case if unbalanced.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a hash table, and how does it handle collisions?

A

A hash table maps keys to values using a hash function. Collisions are resolved via chaining (linked lists at each bucket) or open addressing (probing).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the difference between a stack and a queue?

A

Stack is LIFO (Last In, First Out); supports push/pop. Queue is FIFO (First In, First Out); supports enqueue/dequeue.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a heap, and what are its types?

A

A heap is a complete binary tree satisfying the heap property. Max-heap: parent ≥ children. Min-heap: parent ≤ children. Used in priority queues and sorting (heapsort).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly