CS2004_Data_Structures_Flashcards
(10 cards)
What is a stack?
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.
What is a queue?
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.
What is a linked list?
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.
What is an array?
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.
What is a hash table?
A hash table is a data structure that maps keys to values using a hash function to compute the index.
✅ Example: Dictionary in Python.
What is a graph in computer science?
A graph is a collection of nodes (vertices) connected by edges. It can be directed or undirected.
✅ Example: Social network connections.
What is the difference between a directed and undirected graph?
In a directed graph, edges have a direction (A → B). In an undirected graph, edges are bidirectional (A — B).
What is a tree?
A tree is a type of graph with no cycles, where each node has exactly one parent (except the root).
✅ Example: File directory structure.
What is a binary search tree (BST)?
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.
What is a complete graph?
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.