1 INFORMATION IN MEMORY Flashcards

1
Q

What is the fundamental requirement for a computer program to function?

A

The ability to store and access data from memory.

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

What do variables represent in a computer program?

A

Names representing the location (or address) of a piece of data in the computer’s memory.

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

Why are variables essential in programming?

A

They enable programs to track information that changes throughout the course of execution.

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

What happens when you create a variable?

A

The system allocates and assigns it a location behind the scenes.

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

How are variables visualized in computer memory?

A

As a long column of bins.

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

What analogy is used to describe variables?

A

They are like labels on file folders.

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

What determines the type of data a variable can store?

A

The associated type of the variable, such as integers, floats, or Booleans.

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

What is an example of defining a variable in pseudocode?

A

<type>: <name> format, e.g., Integer: coffee_count = 5.
</name></type>

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

What are composite data structures?

A

Structures that gather multiple individual variables into a single group.

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

What is an example of a composite data structure for coffee?

A

CoffeeRecord containing Name, Brand, Rating, Cost_Per_Pound, Is_Dark_Roast, Other_Notes.

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

Why are composite data structures useful?

A

They simplify tracking and passing related pieces of data.

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

What is an array used for?

A

To store multiple related values.

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

What is the structure of an array?

A

A contiguous block of equal-sized bins in memory.

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

How do you access an element in an array?

A

By specifying its location, or index.

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

What indexing system do most programming languages use for arrays?

A

Zero-indexed arrays.

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

How do you reference the value at index i of an array A?

A

A[i].

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

What is the formula to compute the location of an item in an array?

A

Location(item i) = Location(start of array) + Size of each element × i.

18
Q

What is a common operation to set a value in an array?

A

Using the syntax A[index] = value.

19
Q

What is the significance of the insertion sort algorithm?

A

It sorts the values in an array by expanding a sorted range.

20
Q

What is the process of insertion sort?

A

It iterates through each element, finds the correct location in the sorted section, and inserts it.

21
Q

What is a potential drawback of using arrays?

A

You need to manage the individual bins for operations like shifting or swapping values.

22
Q

True or False: Each bin in an array behaves like an individual variable.

23
Q

Fill in the blank: An array is effectively a row of _______.

A

variables.

24
Q

What is the primary function of the insertion sort algorithm?

A

To sort elements by moving each element into the correct location of the sorted section.

25
At the start of iteration i in insertion sort, which sections of the array are sorted?
Bins 0 through i − 1 are all in sorted order.
26
How does the insertion sort algorithm determine where to insert the current item?
It finds the correct location in the sorted prefix by comparing the current value to preceding values.
27
What is the initial sorted prefix in the coffee sorting example?
A single bag at the front of the shelf.
28
What happens when the algorithm compares the second bag to the first in the coffee sorting example?
It determines whether to swap their positions based on their best-by dates.
29
What is the time complexity of insertion sort in the worst case?
Proportional to the square of the number of items.
30
What does the outer loop in the insertion sort algorithm do?
It iterates through each value in the unsorted range.
31
What does the inner loop in insertion sort do?
It shifts the current value down into the sorted prefix.
32
True or False: Insertion sort is particularly efficient for large datasets.
False.
33
What are strings often thought of as in programming?
A special kind of arrays.
34
What does each bin in a string hold?
A single character, which can be a letter, number, symbol, space, or special indicator.
35
What is the purpose of a special character in a string?
To indicate the end of the string.
36
How is string equality typically checked in programming?
By iterating through each character and comparing them.
37
Fill in the blank: The algorithm for checking the equality of two strings starts by comparing their _______.
[size]
38
What does the worst-case computational cost of string comparison grow with?
The length of the strings.
39
Why is it important to understand the performance of string comparisons?
To avoid underestimating the cost of comparing long strings.
40
What do variables and arrays provide in computer programming?
The very foundations for programming and data structures.
41
What will later chapters explore in relation to dynamic data structures?
Their impact on algorithms and trade-offs among efficiency, flexibility, and complexity.