Ch 1.1 and Dynamic Arrays 1.1 Flashcards

1
Q

use ___ to create dynamic arrays and access their elements in
the traditional way. If they are no longer needed, ______ them. You gain the benefits of ______ and also keep the code complexity low

A

pointers
deallocate
resizing

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

When we create a 2D dynamic array (named ary) each beginning address of the columns is stored into the ______, ary[index] which is an array of pointers.

A

rows

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Euclid’s algorithm for computing gcd(m, n)

Step 1 If n = 0, return the value of m as the answer and stop; otherwise,
proceed to Step 2.

Step 2 Divide m by n and assign the value of the remainder to r.

Step 3 Assign the value of n to m and the value of r to n. Go to Step 1.

Alternatively, we can express the same algorithm in pseudocode:

A

ALGORITHM Euclid(m, n)
//Computes gcd(m, n) by Euclid’s algorithm
//Input: Two nonnegative, not-both-zero integers m and n
//Output: Greatest common divisor of m and n
while n = 0 do
r ← m mod n
m ← n
n ← r
return m

How well did you know this?
1
Not at all
2
3
4
5
Perfectly