Fundamental Data Structures Flashcards
What are the three fundamental linear data structures?
Lists, Stacks, and Queues.
What is the main difference between an array and a linked list?
Arrays have fixed size and contiguous memory allocation, while linked lists have dynamic size with non-contiguous memory allocation.
What are the operations on a linked list?
Insert, Delete, Search, Traverse.
What is a stack?
A LIFO (Last In, First Out) data structure with operations push, pop, and peek.
What is a queue?
A FIFO (First In, First Out) data structure with enqueue and dequeue operations.
What is a priority queue?
A queue where elements are dequeued based on priority rather than order of arrival.
What is a deque (double-ended queue)?
A queue where insertions and deletions can occur at both ends.
What are the advantages of linked lists over arrays?
Dynamic size, efficient insertions/deletions, no need for contiguous memory.
What is the downside of using a linked list?
Higher memory usage (extra pointers), slower random access (O(n) lookup).
What is an application of a Stack?
Function calls in recursion (call stack), undo feature in text editors.
What is an application of a Queue?
Task scheduling (CPU process scheduling, print queue).