CS2004_Data_Structures_Flashcards

(10 cards)

1
Q

What is a stack?

A

A stack is a linear data structure that follows the Last In, First Out (LIFO) principle. Items are added and removed from the top.

✅ Example: Undo operations in a text editor.

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

What is a queue?

A

A queue is a linear data structure that follows the First In, First Out (FIFO) principle. Items are added to the back and removed from the front.

✅ Example: Print job scheduling.

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

What is a linked list?

A

A linked list is a linear collection of nodes, where each node contains data and a pointer to the next node.

✅ Example: Dynamic memory-based list where items can be easily inserted or deleted.

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

What is an array?

A

An array is a fixed-size data structure where elements are stored in contiguous memory and accessed by index.

✅ Example: List of grades stored as integers in memory.

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

What is a hash table?

A

A hash table is a data structure that maps keys to values using a hash function to compute the index.

✅ Example: Dictionary in Python.

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

What is a graph in computer science?

A

A graph is a collection of nodes (vertices) connected by edges. It can be directed or undirected.

✅ Example: Social network connections.

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

What is the difference between a directed and undirected graph?

A

In a directed graph, edges have a direction (A → B). In an undirected graph, edges are bidirectional (A — B).

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

What is a tree?

A

A tree is a type of graph with no cycles, where each node has exactly one parent (except the root).

✅ Example: File directory structure.

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

What is a binary search tree (BST)?

A

A BST is a tree where each node has at most two children, and left < root < right for all nodes.

✅ Example: Used in efficient searching and sorting.

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

What is a complete graph?

A

A complete graph is a graph where every node is connected to every other node with a unique edge.

✅ Example: Distance matrix for TSP where every city connects to every other.

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