Computer Programming: Data Structures 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 Computer Programming: Data Structures flashcards as text
Which graph traversal visits all vertices at the current depth before moving to the next depth level?
Answer: BFS
BFS (Breadth-First Search) uses a queue to visit all neighbors of a vertex before moving to the next level.
What is the worst-case time complexity of QuickSort?
Answer: O(n squared)
QuickSort's worst case is O(n squared) when the pivot is always the smallest or largest element.
A min-heap stores elements such that:
Answer: The root is the smallest element
In a min-heap, every parent is less than or equal to its children, so the root contains the minimum element.
What happens when you enqueue an element into a full circular queue?
Answer: Queue overflow occurs
In a fixed-size circular queue, attempting to enqueue when full results in an overflow condition.
Which algorithm is used to detect a cycle in a linked list efficiently?
Answer: Floyd's Cycle Detection (Tortoise and Hare)
Floyd's algorithm uses two pointers. If there is a cycle, the slow and fast pointers will eventually meet.
What is the time complexity of inserting an element at the beginning of a singly linked list?
Answer: O(1)
To insert at the beginning: create a new node, set its next to current head, update head. This is O(1).