Data Structure and Algorithm II Flashcards
What are the key steps in problem solving?
Understand the problem.
Break it down.
Make a plan.
Execute the solution.
Look back to refine.
What is an algorithm?
A step-by-step set of instructions to solve a problem or perform a task.
What is pseudocode?
A high-level, human-readable description of an algorithm.
What is Bubble Sort?
A sorting algorithm that repeatedly swaps adjacent items if they’re in the wrong order.
Time Complexity: O(N²).
What is Selection Sort?
Finds the smallest item in the unsorted section and swaps it with the first unsorted item.
Time Complexity: O(N²).
What is Insertion Sort?
Builds a sorted section by inserting items one at a time.
Time Complexity: O(N²) average, O(N) best case (sorted array).
What is Merge Sort?
A divide-and-conquer algorithm that splits, sorts, and merges halves.
Time Complexity: O(N log N).
What is a Binary Search Tree (BST)?
A tree where:
Left child < Parent < Right child.
What are BST operations?
Insertion: Place value in the correct position.
Search: Traverse left or right to find the value.
Traversal Orders:
In-Order: Left → Root → Right (sorted order).
Pre-Order: Root → Left → Right.
Post-Order: Left → Right → Root.