Data Structures & Algorithms Flashcards
7 cards from real CPA practice questions. Tap to flip, then mark Knew It or Still Learning — missed cards come back until you master them.
Read the first 7 Data Structures & Algorithms flashcards as text
What property must every node in a max-heap satisfy?
Answer: Its value is greater than or equal to its children's values
In a max-heap, each parent node's value must be greater than or equal to the values of its children.
Which sorting algorithm has the best average-case performance of O(n log n) and is commonly used in standard library implementations?
Answer: Quick sort
Quick sort achieves O(n log n) average-case and is favored in practice due to cache efficiency and low constant factors.
In graph theory, a graph with no cycles is called a:
Answer: Acyclic graph
An acyclic graph contains no cycles; a directed acyclic graph (DAG) is a common special case.
What does the 'amortized' cost concept mean in algorithm analysis?
Answer: The average cost per operation over a sequence of operations
Amortized analysis spreads the total cost of a sequence of operations over all operations to give an average per-operation cost.
Which data structure is most appropriate for implementing a browser's back-navigation history?
Answer: Stack
A stack's LIFO property naturally models back navigation — the last page visited is the first retrieved.
The time complexity of accessing an element by index in a dynamic array (ArrayList) is:
Answer: O(1)
Dynamic arrays store elements contiguously, so index-based access requires only a single memory address calculation, giving O(1).
Which of the following is a stable sorting algorithm?
Answer: Merge sort
Merge sort preserves the relative order of equal elements, making it a stable sorting algorithm.