tags:
- cs321
- school
- bsu
- book
- notes
- algorithms
- data-structures
created: 2024-09-08
What does the insertion sort algorithm solve?
The insertion sort algorithm solves the sorting problem.
What are the numbers to be sorted also called?
The numbers to be sorted are also called the keys.
What is the data associated with the keys called?
The data associated with the keys is called the satellite data.
What is the combination of a key and satellite data called?
The combination of a key and satellite data is called a record.
When describing a sorting algorithm, we focus on the ..., but it is important to remember that there usually is associated ... ...
When describing a sorting algorithm, we focus on the keys, but it is important to remember that there usually is associated satellite data.
How would you sort a deck of cards using insertion sort?
You would sort a desk of cards using insertion sort by taking cards from the deck with your right hand and placing them in their correct positions in your left hand.
What is the pseudocode for insertion sort?
The pseudocode for insertion sort is:
INSERTION-SORT(A,n)
for i = 2 to n
key = A[i]
// Insert A[i] into the sorted subarray A[1:i-1]
j = i - 1
while j > 0 and A[j] > key
A[j+1] = A[j]
j = j - 1
A[j+1] = key
...
A loop invariant proof is a form of mathematical ...
A loop invariant proof is a form of mathematical induction.
What does the proof of the base case correspond to in a loop invariant?
In a loop invariant, the proof of the base case corresponds to the invariant holding true before the first iteration.What does the proof of the inductive step correspond to in a loop invariant?
In a loop invariant, the proof of the inductive step corresponds to the invariant holding true from iteration to iteration.
This section explains the loop invariant for the insertion sort algorithm.
This section explains the syntax of the pseudocode used throughout the book.
Using Figure 2.2 as a model, illustrate the operation of INSERTION-SORT on an array initially containing the sequence
...
Consider the procedure SUM-ARRAY on the facing page. It computes the sum of the
...
Rewrite the INSERTION-SORT procedure to sort into monotonically decreasing instead of monotonically increasing order.
...
Consider the searching problem:
Input: A sequence of
Output: An index
Write pseudocode for linear search, which scans through the array from beginning to end, looking for
...
Consider the problem of adding two
...
What does it mean to analyze an algorithm?
To analyze an algorithm means to predict the resources an algorithm requires.
What do you most often consider when analyzing an algorithm?
When analyzing an algorithm, you most often consider computational time.
What do you need before you can analyze an algorithm?
Before you can analyze an algorithm, you need a model of the technology that it runs on.
What is a random-access machine (RAM)?
A RAM is a model of computation where algorithms are implemented as computer programs running on a generic processor.
How are instructions in the random-access machine (RAM) model executed?
Instructions in the RAM model are executed one after another without concurrent operations.What does the random-access machine (RAM) model assume about the time to execute an instruction or access data?
The RAM model assumes that the time to execute an instruction or access data is the same for each instruction and data access (constant).
...
...