DATA STRUCTURES EXAM 2 REVIEW
QUESTIONS WITH CORRECT
ANSWERS
What is an array? - Correct Answers -A collection of elements stored in contiguous
memory locations
What is a linked list? - Correct Answers -A list of nodes or elements of a data connected
by pointers
What is a stack? - Correct Answers -A data structure that follows LIFO (Last In, First
Out).
What is a binary tree? - Correct Answers -hierarchical structure where each node has at
most two children.
Quick Sort - Correct Answers -O(nlogn) ; worst case O(n^2); choice of pivot; divide and
conquer method
Bubble Sort - Correct Answers -O(n^2); best case O(n); easy code; any size; stable; in-
place; compares 2 elements and swaps if they are in the wrong order
Insertion Sort - Correct Answers -O(n^2); best case O(n); good best case for small;
small or almost sorted sequences O(n+s); stable; in-place; divides the sequence
between sorted and unsorted
What is a binary search tree (BST)? - Correct Answers -A binary tree where the left
child contains values less than the parent, and the right child contains values greater.
What is a heap? - Correct Answers -A complete binary tree that maintains a specific
order (min-heap or max-heap).
Merge Sort - Correct Answers -O(nlogn) ; sorts the left and right half separately, then
merges them; divide and conquer method
Selection Sort - Correct Answers -O(n^2); best for small sequences; stable; in-place
QUESTIONS WITH CORRECT
ANSWERS
What is an array? - Correct Answers -A collection of elements stored in contiguous
memory locations
What is a linked list? - Correct Answers -A list of nodes or elements of a data connected
by pointers
What is a stack? - Correct Answers -A data structure that follows LIFO (Last In, First
Out).
What is a binary tree? - Correct Answers -hierarchical structure where each node has at
most two children.
Quick Sort - Correct Answers -O(nlogn) ; worst case O(n^2); choice of pivot; divide and
conquer method
Bubble Sort - Correct Answers -O(n^2); best case O(n); easy code; any size; stable; in-
place; compares 2 elements and swaps if they are in the wrong order
Insertion Sort - Correct Answers -O(n^2); best case O(n); good best case for small;
small or almost sorted sequences O(n+s); stable; in-place; divides the sequence
between sorted and unsorted
What is a binary search tree (BST)? - Correct Answers -A binary tree where the left
child contains values less than the parent, and the right child contains values greater.
What is a heap? - Correct Answers -A complete binary tree that maintains a specific
order (min-heap or max-heap).
Merge Sort - Correct Answers -O(nlogn) ; sorts the left and right half separately, then
merges them; divide and conquer method
Selection Sort - Correct Answers -O(n^2); best for small sequences; stable; in-place