Memory and Pointers
- 74Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
74 questions
- 1The computer's main memory, divided conceptually into bytes, is called_____.
Hint
Recall the abbreviation for Random Access Memory.
Answer
RAM (Random Access Memory)
Explanation
RAM is the computer memory described as a grid of individual bytes, which can be used to organize data.
- 2A computer examines an array's contents_____rather than taking in the entire array at once.
Hint
Think about how a computer checks lockers one at a time.
Answer
step by step
Explanation
A computer processes array elements sequentially, examining one element at a time rather than instantly seeing the whole collection.
- 3For a search problem, the Boolean output indicates whether the target is_____.
Hint
The output answers a yes-or-no question about the target and the collection.
Answer
among the items being searched
Explanation
The search returns true if the target is present and false if it is absent.
- 4An algorithm that checks array elements in a line, one after another, is called_____.
Hint
Its name describes following a line through the elements.
Answer
linear search
Explanation
Linear search checks elements sequentially until it finds the target or reaches the end.
- 5When an array is unsorted and the target might be in the last position, linear search may inspect_____elements.
Hint
Consider the worst case for searching from one end to the other.
Answer
all
Explanation
If the target is last—or absent—the search must check every element before it can finish.
- 6Binary search requires the items to be_____before it begins.
Hint
The algorithm decides which half to discard by comparing values.
Answer
sorted
Explanation
Binary search relies on sorted order to determine whether the target can only be in the left or right half.
- 7Binary search first checks the item in the_____of the current range.
Hint
This position lets the algorithm eliminate one half of the range.
Answer
middle
Explanation
By checking the middle item, binary search can keep the relevant half and discard the other half.
- 8If the target is smaller than the middle item in a sorted array, binary search continues in the_____half.
Hint
Smaller values appear on this side when the list is in ascending order.
Answer
left
Explanation
In ascending order, values smaller than the middle item must occur in the left half.
- 9If the target is larger than the middle item in a sorted array, binary search continues in the_____half.
Hint
Larger values appear on this side when the list is in ascending order.
Answer
right
Explanation
In ascending order, values larger than the middle item must occur in the right half.
- 10In recursive or repeated binary search, if the search range has no items left, the algorithm returns_____.
Hint
If the range is empty, the target was not found.
Answer
false
Explanation
An empty range contains no possible match, so the search concludes that the target is absent.
- 11The word “binary” describes the repeated division of the search problem into_____parts.
Hint
The prefix “bi” means this number.
Answer
two
Explanation
Binary search repeatedly divides the remaining problem in two, which is the source of its name.
- 12If a search finds its target at the first position it checks, it has taken_____step.
Hint
This is the best-case number of checks for either search method discussed.
Answer
one
Explanation
Both linear search and binary search can find a target immediately if it happens to be at the first position examined.
- 13Big O notation describes an algorithm's approximate_____bound on running time.
Hint
It is commonly used to describe the worst-case amount of work.
Answer
upper
Explanation
Big O gives an upper bound on how much time or how many steps an algorithm may require.
- 14Omega notation describes an algorithm's approximate_____bound on running time.
Hint
It can describe the best-case amount of work.
Answer
lower
Explanation
Omega notation gives a lower bound on the running time, such as the best case for a particular algorithm.
- 15When an algorithm's upper and lower bounds are the same, its running time can be described using_____notation.
Hint
This notation uses a Greek letter and summarizes matching bounds.
Answer
theta
Explanation
Theta notation describes a running time when its upper and lower bounds are identical.
- 16The phrase “on the order of” refers to_____notation.
Hint
It is written with a capital O and gives an approximate upper bound.
Answer
big O
Explanation
Big O notation is read as “on the order of” and summarizes the growth of an algorithm's running time.
- 17In big O analysis, a linear search through n items has a worst-case running time of_____.
Hint
In the worst case, the number of checks grows in proportion to the number of items.
Answer
O(n)
Explanation
Linear search may inspect all n elements, so its worst-case running time is O(n).
- 18In big O analysis, binary search has a worst-case running time of_____.
Hint
The search range is repeatedly divided in two.
Answer
O(logn)
Explanation
Repeatedly halving a collection of size n takes a number of steps proportional to logn.
- 19For sufficiently large inputs, big O analysis ignores a constant factor such as the division by_____in n/2.
Hint
Constant multipliers do not change the overall growth category.
Answer
2
Explanation
Big O focuses on growth as the input grows, so n and n/2 are both classified as linear.
- 20For big O growth rates, changing the base of a logarithm changes its value only by a_____factor.
Hint
The difference between logarithm bases does not change the growth category.
Answer
constant
Explanation
Logarithms with different fixed bases differ by a constant multiplier, which big O notation ignores.
- 21An algorithm that counts every item must examine all items even in the best case, so its lower bound is_____.
Hint
Accurate counting requires inspecting each of the n items.
Answer
Ω(n)
Explanation
To know the total number of items, the algorithm must count each one, giving a best-case lower bound of Ω(n).
- 22Computer scientists often prioritize an algorithm's_____case because it describes how it performs on difficult inputs.
Hint
This is the case represented by an upper bound such as big O.
Answer
worst
Explanation
Worst-case performance is a useful guarantee about how much work an algorithm may require, even when its input is unfavorable.
- 23In C, an array can be initialized with a fixed list of values using_____braces.
Hint
The notation encloses the values with braces rather than parentheses.
Answer
curly
Explanation
A statically initialized array can be written with its values enclosed in curly braces.
- 24An array whose values are specified when it is declared is described as a_____initialized array.
Hint
The term contrasts with values supplied dynamically later.
Answer
statically
Explanation
A statically initialized array has its values specified in advance, such as in a brace-enclosed initializer.
- 25In C, an array with six elements has valid indices from 0 through_____.
Hint
Array indexing begins at zero, so the final index is one less than the size.
Answer
5
Explanation
A six-element array uses indices 0 through 5; the final index is the array size minus one.
- 26In C, the expression_____
i++is commonly used in a loop tothe index.Hint
It advances the loop variable by one.
Answer
increment
Explanation
The postfix increment operator adds one to the loop index, allowing the loop to move through an array.
- 27A C string is represented as an_____of characters, rather than as a single character.
Hint
A string can contain multiple characters stored together.
Answer
array
Explanation
In C, a string is an array of characters, which is why comparing strings differs from comparing single values such as integers.
- 28In C, the string-comparison function introduced in the lecture is called_____.
Hint
Its name abbreviates string comparison.
Answer
strcmpExplanation
strcmpcompares two strings and is declared in the string library header. - 29The function_____
strcmpreturnswhen the two strings are the same.Hint
Equality is represented by the neutral comparison result.
Answer
0
Explanation
A return value of zero from
strcmpindicates that the two strings are equal. - 30The_____
strcmpfunction is declared in the C header file.Hint
Its name is the standard header for string operations.
Answer
string.hExplanation
Programs that use
strcmpshould includestring.hso the function is declared. - 31In the conventions used for the C program's_____
mainfunction, returningindicates success.Hint
This is the conventional success exit status described in the lecture.
Answer
0
Explanation
The examples use
return 0to indicate that the program completed successfully. - 32In the examples, returning_____from
mainindicates failure.Hint
This nonzero exit status contrasts with the success value.
Answer
1
Explanation
The examples use
return 1to indicate an unsuccessful outcome. - 33A phone number containing characters such as dashes or parentheses is better represented as a_____than as an integer.
Hint
These parts of a phone number are characters, not quantities for arithmetic.
Answer
string
Explanation
Phone numbers can include punctuation and leading zeros, so representing them as strings preserves their formatting.
- 34Representing a phone number as an integer can lose a leading_____.
Hint
This digit does not affect a number's mathematical value when placed at the beginning.
Answer
zero
Explanation
Leading zeros are dropped in numeric representations, even though they can be meaningful in a phone number.
- 35In C, a_____
structacts as athat can contain multiple data types.Hint
It groups related fields together.
Answer
container
Explanation
A structure can hold multiple pieces of data, such as a person's name and phone number.
- 36The C keyword_____
typedefis used toa type.Hint
Its name describes creating a type name for use in a program.
Answer
define
Explanation
typedefallows a programmer to define a type name, including a custom structure type. - 37A custom_____
persontype can keep a person's name and phone numberin one structure.Hint
Grouping them prevents their association from depending on separate arrays staying aligned.
Answer
together
Explanation
Encapsulating the related fields in one structure helps keep each person's name associated with the correct number.
- 38The dot operator accesses a particular_____of a structure, such as a person's name.
Hint
A structure contains named pieces of data.
Answer
field
Explanation
Expressions such as
people[i].nameuse the dot operator to access a structure field. - 39Keeping names and phone numbers in separate arrays relies on the arrays remaining in the same_____.
Hint
The name at one index must correspond to the number at that index.
Answer
order
Explanation
Separate arrays can become mismatched if one is rearranged without applying the same rearrangement to the other.
- 40A database commonly stores related pieces of information together using a form of_____.
Hint
This design principle groups related information into a single unit.
Answer
encapsulation
Explanation
The lecture connects custom structures and the grouping of related information to the way databases organize data.
- 41A sorting algorithm transforms an unsorted list into a list ordered from_____to largest.
Hint
This describes ascending numerical order.
Answer
smallest
Explanation
The sorting example arranges values from the smallest on the left to the largest on the right.
- 42Bubble sort compares_____elements and swaps them when they are out of order.
Hint
The elements are next to each other in the list.
Answer
adjacent
Explanation
Bubble sort repeatedly compares neighboring elements and swaps a pair if their order is incorrect.
- 43Bubble sort gets its name from larger values that appear to_____toward the end of the list.
Hint
The motion is compared to a value rising through repeated neighboring swaps.
Answer
bubble
Explanation
Repeated swaps move large values toward their correct positions at the right-hand end of the list.
- 44In the bubble sort pseudocode described, the algorithm repeats passes until there are no_____.
Hint
A pass with none indicates that no neighboring pair needed correction.
Answer
swaps
Explanation
If a full pass makes no swaps, the list is sorted and bubble sort can stop early.
- 45Selection sort repeatedly finds the next_____element in the unsorted portion of the list.
Hint
The selected value is placed into the next position in ascending order.
Answer
smallest
Explanation
Each selection sort pass searches the remaining elements for the smallest value and places it in its final position.
- 46After selection sort finds the smallest remaining element, it swaps it with the element at the current_____.
Hint
This position marks the next place to fill in the sorted portion.
Answer
index
Explanation
Selection sort puts the smallest remaining item at the current index, extending the sorted portion by one element.
- 47Selection sort can place a selected value by shifting other items or by_____the item occupying the desired position.
Hint
The lecture's alternative avoids moving every item over by one position.
Answer
evicting
Explanation
Instead of shifting all intervening values, the described approach swaps or evicts the item at the target position and handles it later.
- 48An election in which the candidate with the most votes wins is described as a_____election.
Hint
The method chooses the candidate with the greatest number of votes.
Answer
plurality
Explanation
In a plurality election, the candidate with the most votes wins, without requiring voters to rank preferences.
- 49In a runoff election, voters can_____their preferences among candidates.
Hint
This process records more than a single first choice.
Answer
rank
Explanation
A runoff system can use voters' ranked preferences to determine the winner through further tabulation.
- 50Different vote-tabulation_____can produce different election outcomes.
Hint
The procedure used to process votes may vary.
Answer
algorithms
Explanation
The lecture notes that different algorithms for tabulating votes can have real-world effects on election results.
- 51For bubble sort with nested passes that each take on the order of n steps, the worst-case running time is_____.
Hint
Multiply the growth of the outer and inner loops.
Answer
O(n2)
Explanation
The two loops each take on the order of n steps, so bubble sort has a quadratic worst-case running time.
- 52The lecture's original bubble sort performs its nested passes even when the input is already sorted, giving it a best-case lower bound of_____.
Hint
That version does not stop early when a pass makes no swaps.
Answer
Ω(n2)
Explanation
Without an early-exit condition, the algorithm continues through its nested loops even for sorted input.
- 53With the improvement “repeat until no swaps,” bubble sort can finish an already sorted list in_____time.
Hint
It still has to compare each adjacent pair in one pass.
Answer
Ω(n)
Explanation
For n elements, one pass checks n−1 adjacent pairs, so the best-case running time is linear.
- 54Selection sort examines the remaining unsorted elements on each pass, so its worst-case running time is_____.
Hint
The work decreases across passes but sums to a quadratic quantity.
Answer
O(n2)
Explanation
The passes require roughly n, then n−1, then n−2 checks, summing to a quantity on the order of n2.
- 55Selection sort still scans the remaining elements to verify the minimum, even when the list is already sorted, so its lower bound is_____.
Hint
The algorithm cannot infer that the first item is smallest without inspecting the rest.
Answer
Ω(n2)
Explanation
Selection sort follows the same search process on already sorted input, so its best-case work remains quadratic.
- 56The sum n+(n−1)+⋯+1 equals_____.
Hint
This is the formula for the sum of the first n positive integers.
Answer
2n(n+1)
Explanation
The repeated decreasing scans in selection sort sum to 2n(n+1), which grows on the order of n2.
- 57In big O analysis, the highest-order term of n2−2n+1 is_____.
Hint
It grows faster than the other terms as n becomes large.
Answer
n2
Explanation
As the input grows, the quadratic term dominates the linear and constant terms, so the expression is O(n2).
- 58An iterative algorithm uses a_____to repeat instructions.
Hint
Examples include
forandwhileconstructs.Answer
loop
Explanation
Iteration means repeating instructions, commonly by using a loop.
- 59A function is recursive when it_____.
Hint
Its own name appears in its implementation as a function call.
Answer
calls itself
Explanation
Recursion occurs when a function invokes itself, often on a smaller version of the original problem.
- 60A recursive function needs a_____case that stops further recursive calls.
Hint
It handles a simple situation directly, such as a pyramid of height zero.
Answer
base
Explanation
The base case prevents recursion from continuing forever by specifying when the function should stop.
- 61To recursively draw a pyramid of height h, the function first draws a smaller pyramid of height_____.
Hint
The smaller problem is one row shorter than the original.
Answer
h−1
Explanation
A pyramid of height h can be defined as a pyramid of height h−1 followed by one additional row.
- 62After drawing the pyramid of height h−1, the recursive pyramid function prints_____additional row.
Hint
This row completes the pyramid at the current height.
Answer
one
Explanation
The recursive definition builds the smaller pyramid first and then adds a row of h bricks.
- 63In the recursive pyramid example, a height of zero is the case in which the function should simply_____.
Hint
The function does not draw a row or call itself again in this case.
Answer
return
Explanation
Returning when the height is zero provides the base case that stops the recursive calls.
- 64A recursive call should work on a_____input than the function originally received.
Hint
The problem must move toward its base case.
Answer
smaller
Explanation
Reducing the input, such as changing height h to h−1, ensures recursive calls progress toward termination.
- 65In the pyramid example, recursive calls print the smaller rows first, so the rows appear while the calls_____.
Hint
After the base case returns, earlier function calls resume in reverse order.
Answer
unwind
Explanation
The function reaches the base case before printing the larger rows; as calls return, each one prints its additional row.
- 66Merge sort's base case is a list with_____item, which is already sorted.
Hint
There cannot be any out-of-order pair in a collection of this size.
Answer
one
Explanation
A list containing one item is sorted by definition, so merge sort can return without further work.
- 67For a list with more than one item, merge sort sorts the left half, sorts the right half, and then_____the halves.
Hint
The final step combines two already sorted lists into one sorted list.
Answer
merges
Explanation
Merge sort's recursive process is to sort each half and then merge the sorted halves together.
- 68During a merge, the algorithm repeatedly takes the smaller available item from the two sorted lists to preserve_____order.
Hint
The combined list should remain arranged from smallest to largest.
Answer
sorted
Explanation
Comparing the next available items and selecting the smaller one builds a correctly ordered merged list.
- 69Merging two sorted halves requires_____space in the lecture's example.
Hint
The elements are placed into a separate row before forming the combined result.
Answer
extra
Explanation
The example uses additional memory to combine the two sorted lists before producing the merged list.
- 70Repeatedly dividing a list in half produces a number of levels proportional to_____.
Hint
This is the growth pattern associated with repeatedly halving a problem.
Answer
logn
Explanation
A list of size n can be halved about log2n times before reaching lists of size one; the base is omitted in the growth notation.
- 71At each level of merge sort, merging processes all_____elements.
Hint
The halves together contain the entire list.
Answer
n
Explanation
Although the list is split into smaller parts, merging across one level collectively touches all n elements.
- 72Because merging processes n elements across about logn levels, merge sort has running time_____.
Hint
Multiply the work per level by the number of levels.
Answer
O(nlogn)
Explanation
Merge sort performs linear work at each of its logarithmically many levels, giving an O(nlogn) running time.
- 73The merge sort described does the same splitting and merging even for already sorted input, so its lower bound is_____.
Hint
Unlike optimized bubble sort, this version does not stop early based on the input order.
Answer
Ω(nlogn)
Explanation
The algorithm follows its recursive divisions and merges regardless of whether the input begins sorted, so the best-case work remains nlogn.
- 74Because merge sort has matching bounds of O(nlogn) and Ω(nlogn), its running time can also be written as_____.
Hint
Use the notation for identical upper and lower bounds.
Answer
Θ(nlogn)
Explanation
When an algorithm's upper and lower bounds match, theta notation summarizes both; merge sort is Θ(nlogn).

Ask anything
We've read this whole study set, so questions about it get the best answers.