Elements bubble to the end of the list by comparing and swapping adjacent elements
Bubble Sort
You are given an almost sorted array where each element is at most 2 positions away from its correct position. What is the most efficient sorting algorithm to use?
Insertion Sort
Which linked list allows bidirectional traversal?
Doubly Linked List
Which algorithmic method solves problems by storing and reusing the solutions to the subproblems?
Dynamic Programming
What is the time complexity of the second line of this program?
O(1)
First in, first out logic
Queue
Given an array of integers, find the maximum product of two elements in that array. What type of sorting algorithm would you use?
Answer choices: Merge Sort, Quick Sort, Heap Sort, Bubble Sort, Selection Sort
Bubble Sort
What is the main advantage of using a linked list compared to an array?
Size does not need to be known at compile time.
What technique or pattern is used by two pointers to process contiguous segments of an array efficiently?
Sliding Window
What is the time complexity of printing all elements in an array?
O(n)
At most 2 child nodes per parent node, left child less than parent node, and right child greater than parent node.
You need to sort a list of student records based on their names while maintaining the relative order of students with the same name. Which sorting algorithm would be best for this stable sorting requirement?
Answer choices: Merge Sort, Quick Sort, Heap Sort, Bubble Sort, Selection Sort
Merge Sort
What is the main disadvantage of a double linked list compared to a singly linked list?
Increased memory use.
What are the two data elements used in the implementation of a sliding window algorithm?
A start pointer and an end pointer.
What is the worst time complexity for an insertion sort function and a bubble sort function?
O(n2)
Solving a problem by making the best choice at each step, or in other words, making the locally optimal decision.
Greedy Algorithm
You are given an unsorted array of integers and need to find a pair of numbers that sum up to a target value efficiently. Sorting the array first can help optimize the solution. What sorting algorithm would be most efficient?
Answer choices: Insertion Sort, Bubble Sort, QuickSort, Selection Sort, Heap Sort
Quick Sort
What is the extra node that’s added to the linked list to simplify handling edge cases during insertions and deletions?
Dummy Node
How does an O(n2) time complexity naive algorithm change after implementing the sliding window algorithm?
Changes to O(n).
What is the time complexity of a program that finds the greatest common divisor?
O(logn)
Classic problem where you maximize the total value of items in a container with limited weight capacity.
The Knapsack Problem
You need to find the top k largest elements in an unsorted array of size n. Which sorting algorithm would be most efficient for this task?
Answer choices: Insertion Sort, Bubble Sort, QuickSort, Selection Sort, Heap Sort
Heap Sort
How can you check if a singly linked list is palindrome in O(1) extra space?
Reverse the second half and compare it with the first half
How can you optimize a dynamic programming solution that relies on a range of previous states using a sliding window?
By using a deque to maintain and query candidate states efficiently.
What is the time complexity of this function?
O(2n)