Algorithms 1 Latest Update 2025-2026 Exam 175
Questions with 100% Verified Correct Answers
Guaranteed A+
A binary tree is complete if: - CORRECT ANSWER: all levels except possibly the last
are completely full, and the last level has all its nodes to the
left side
A binary tree is full if: - CORRECT ANSWER: every node contains 0 or 2 children.
A binary tree is perfect if: - CORRECT ANSWER: if all internal nodes have 2 children
and all leaf nodes are at the same level.
Abstract Data Type (ADT) - CORRECT ANSWER: A data type described by predefined
user operations, such as "insert data at rear," without indicating how each operation is
implemented.
Array - CORRECT ANSWER: A data structure that stores an ordered list of items, with
each item is directly accessible by a positional index.
Array based list - CORRECT ANSWER: A list ADT implemented using an array. An
array-based list supports the common list ADT operations, such as append, prepend,
insert after, remove, and search.
Array in Java - CORRECT ANSWER: generic class that supports different data types.
declared as follows, where T is the data type.
Assignment vs comparison - CORRECT ANSWER: = vs ==
,Bag - CORRECT ANSWER: An ADT for storing items in which the order does not matter
and duplicate items are allowed.
Underlying data structures: Linked list, Array
Bianary Search Tree - CORRECT ANSWER: A data structure in which each node stores
data and has up to two children, known as a left child and a right child.
Big-O Average runtime complexity - CORRECT ANSWER: Selection sort O(N2) Not fast
Insertion sort O(N2) Not fast
Shell sort O(N1.5) No fast
Quicksort O(NlogN) fast
Merge sort O(NlogN) fast
Heap sort O(NlogN) fast
Radix sort O(N) fast (integer only)
Big-O Complexity Chart - CORRECT ANSWER: Best to worst
O(1)
O(log n)
O(n)
O(n log n)
O(n^2)
O(2^n)
O(nl)
,Binary search - CORRECT ANSWER: is an algorithm that searches a SORTED LIST for
a key by first comparing the key to the middle element in the list and recursively
searching half of the remaining list so long as the key is not found.
Binary search tree (BST) - CORRECT ANSWER: An especially useful form of binary
tree, which has an ordering property that any node's left subtree keys ≤ the node's key,
and the right subtree's keys ≥ the node's key. That property enables fast searching for
an item, as will be shown later.
*When searching, search always starts at the root
Binary Tree - CORRECT ANSWER: In a list, each node has up to one successor. In a
binary tree, each node has up to two children, known as a left child and a right child.
"Binary" means two, referring to the two children.
BST inorder traversal - CORRECT ANSWER: Visits all nodes in a BST from smallest to
largest, which is useful for example to print the tree's nodes in sorted order. Starting
from the root, the algorithm recursively prints the left subtree, the current node, and the
right subtree.
Left -> Root -> Right
Bubble sort algorithm - CORRECT ANSWER: **Look for something that swaps so the
result can "bubble" to the top. *best used when the data is small
Sorting algorithm that iterates through a list, comparing and swapping adjacent
elements if the second element is less than the first element. Bubble sort uses nested
loops. Given a list with N elements, the outer i-loop iterates N times.
Because of the nested loops, bubble sort has a runtime of O(N2). Bubble sort is often
considered impractical for real-world use because many faster sorting algorithms exist.
Figure 11.20.1: Bubble sort algorithm.
BubbleSort(numbers, numbersSize) {
, for (i = 0; i < numbersSize - 1; i++) {
for (j = 0; j < numbersSize - i - 1; j++) {
if (numbers[j] > numbers[j+1]) {
temp = numbers[j]
numbers[j] = numbers[j + 1]
numbers[j + 1] = temp
}}
bucket - CORRECT ANSWER: each array element in a hash table
ie A 100 elements hash table has 100 buckets
Bucket sort algorithm - CORRECT ANSWER: **Look for something that distributes the
values into "buckets" where they are individually sorted. **Bucket sort is mainly useful
when input is uniformly distributed over a range.
The bucket index is calculated as ⌊number∗(N−1)/M⌋
N =number of buckets
M =maximum value of M
ie 71 and 99 placed in the same bucket?
71 bucket 2 71 * (5-1) // 99 = 2
BucketSort(numbers, numbersSize, bucketCount) {
if (numbersSize < 1)
return
buckets = Create list of bucketCount buckets
// Find the maximum value
maxValue = numbers[0]