1 INFORMATION IN MEMORY Flashcards
What is the fundamental requirement for a computer program to function?
The ability to store and access data from memory.
What do variables represent in a computer program?
Names representing the location (or address) of a piece of data in the computer’s memory.
Why are variables essential in programming?
They enable programs to track information that changes throughout the course of execution.
What happens when you create a variable?
The system allocates and assigns it a location behind the scenes.
How are variables visualized in computer memory?
As a long column of bins.
What analogy is used to describe variables?
They are like labels on file folders.
What determines the type of data a variable can store?
The associated type of the variable, such as integers, floats, or Booleans.
What is an example of defining a variable in pseudocode?
<type>: <name> format, e.g., Integer: coffee_count = 5.
</name></type>
What are composite data structures?
Structures that gather multiple individual variables into a single group.
What is an example of a composite data structure for coffee?
CoffeeRecord containing Name, Brand, Rating, Cost_Per_Pound, Is_Dark_Roast, Other_Notes.
Why are composite data structures useful?
They simplify tracking and passing related pieces of data.
What is an array used for?
To store multiple related values.
What is the structure of an array?
A contiguous block of equal-sized bins in memory.
How do you access an element in an array?
By specifying its location, or index.
What indexing system do most programming languages use for arrays?
Zero-indexed arrays.
How do you reference the value at index i of an array A?
A[i].
What is the formula to compute the location of an item in an array?
Location(item i) = Location(start of array) + Size of each element × i.
What is a common operation to set a value in an array?
Using the syntax A[index] = value.
What is the significance of the insertion sort algorithm?
It sorts the values in an array by expanding a sorted range.
What is the process of insertion sort?
It iterates through each element, finds the correct location in the sorted section, and inserts it.
What is a potential drawback of using arrays?
You need to manage the individual bins for operations like shifting or swapping values.
True or False: Each bin in an array behaves like an individual variable.
True.
Fill in the blank: An array is effectively a row of _______.
variables.
What is the primary function of the insertion sort algorithm?
To sort elements by moving each element into the correct location of the sorted section.