Data Structures and Algorithms Flashcards
6 cards from real AMCAT practice questions. Tap to flip, then mark Knew It or Still Learning โ missed cards come back until you master them.
Read the first 6 Data Structures and Algorithms flashcards as text
What is the space complexity of a recursive Fibonacci function (without memoization)?
Answer: O(n)
The call stack depth is proportional to n, giving O(n) space complexity.
Which graph traversal algorithm uses a queue?
Answer: Breadth-First Search
Breadth-First Search uses a queue to explore neighbors level by level.
What is the time complexity of inserting an element at the beginning of a singly linked list?
Answer: O(1)
Inserting at the head of a linked list only requires updating two pointers, which is O(1).
Which algorithm is used to find the shortest path in a weighted graph with non-negative weights?
Answer: Dijkstra's
Dijkstra's algorithm finds the shortest path in graphs with non-negative edge weights using a priority queue.
A hash table with chaining resolves collisions by:
Answer: Maintaining a linked list at each bucket
In chaining, each bucket holds a linked list of all keys that hash to the same index.
What property must a graph satisfy to have a valid topological sort?
Answer: It must be a directed acyclic graph (DAG)
Topological sort is only defined for Directed Acyclic Graphs (DAGs) with no cycles.