Data Structures Flashcards
(70 cards)
What is a data structure?
A data structure is a way of organizing and storing data so that it can be accessed and modified efficiently.
True or False: A stack follows the Last In First Out (LIFO) principle.
True
Fill in the blank: A _______ is a linear data structure that allows insertion and deletion of elements from both ends.
deque
What is a queue?
A queue is a linear data structure that follows the First In First Out (FIFO) principle.
What type of data structure is a binary tree?
A hierarchical data structure.
Multiple Choice: Which of the following is NOT a type of tree data structure? A) Binary Tree B) AVL Tree C) Hash Table D) B-Tree
C) Hash Table
What is the purpose of a hash table?
A hash table is used to implement an associative array, mapping keys to values for efficient data retrieval.
True or False: In a binary search tree, the left child is always less than the parent node.
True
Fill in the blank: In a graph, a _______ is a collection of nodes and edges.
vertex
What is the difference between a directed and an undirected graph?
In a directed graph, edges have a direction, while in an undirected graph, edges do not have a direction.
Multiple Choice: What is the time complexity of searching in a balanced binary search tree? A) O(log n) B) O(n) C) O(n log n) D) O(1)
A) O(log n)
What is a vector in computer science?
A vector is a dynamic array that can grow in size and is used to store a sequence of elements.
True or False: A stack can be implemented using an array or a linked list.
True
Fill in the blank: The _______ operation in a stack removes the top element.
pop
What traversal methods are commonly used for trees? [3]
In-order, pre-order, and post-order traversals.
Multiple Choice: Which of the following is a characteristic of a hash function? A) It is reversible B) It produces a fixed-size output C) It can have collisions D) Both B and C
D) Both B and C
What is the primary use of a priority queue?
A priority queue is used to manage a collection of elements where each element has a priority, allowing for the retrieval of the highest (or lowest) priority element.
True or False: In a binary tree, each node can have at most two children.
True
Fill in the blank: The _______ of a graph is a way to visit all the vertices.
traversal
What is the difference between depth-first search (DFS) and breadth-first search (BFS)?
DFS explores as far down a branch as possible before backtracking, while BFS explores all neighbors at the present depth before moving on.
Multiple Choice: Which data structure is best for implementing a recursion? A) Stack B) Queue C) Linked List D) Array
A) Stack
True or False: A hash table can achieve average case time complexity of O(1) for search operations.
True
Fill in the blank: The _______ data structure allows for fast random access to elements.
array
[because their memory location is fixed]
What is a balanced tree? change
A balanced tree is a tree where the height of the left and right subtrees of any node differ by no more than one.