Midterm Review Flashcards
A programming language uses 4-bit binary sequences to represent nonnegative integers. A programmer attempts to add the decimal values 14 and 15. What will happen?
An overflow error will occur, because the largest binary value that can be represented using 4 bits is 1111, which equals 15.
Lossless vs. Lossy compression
Lossless - does not lose any data in the compression process
Lossy - uses approximations and partial data, so the file is not restored to its original form after decompression
What is an advantage of lossless compression over lossy compression
Lossless compression can guarantee reconstruction of the original data, while lossy compression cannot
There are hundreds of digital photos with data representing the level of red, green, and blue for each pixel, as well as metadata that describes the date, time, and location the photo was taken.
For which goals would analyzing the metadata be more appropriate than analyzing the data?
A) Determining the chronological order of the photos
B) Determining the number of clouds in a photo
C) Determining whether a photo is suitable for printing in black-and-white
D) Determining whether two photos were taken at the same location
A and D
Because date and time, as well as location, are considered metadata
Metadata
Data that describes data
In ASCII:
What number corresponds with A and Z
A: 65
Z: 90
What letter is represented by 1001010
H (74)
What letter is represented by 1001001
I (73)
What letter is represented by 1001000
H (72)
What letter is represented by 1001011
K (75)
Redundancy
A system design with multiple paths for traffic, so that data can keep flowing even if one path fails
If you upgrade from 32-bits to 64-bits, how many more items can be stored?
232 times more
Overflow error
Happens when a program receives a value that exceeds the storage capacity, usually in binary
Round-off error
The difference between an approximation of a number (9.5) and the exact number (9.51235932)
Floating-point representation
Allow computers to represent very large or very small numbers using scientific notation. There can be a loss of precision due to the infinite number of real numbers compared to the finite number of bits used to represent them.
What is the next binary number after: 1001 0011
1001 0100
Parameter
Input to a function that is named
Boolean
Can have two values, true or false
Undecidable problem
A problem that it is impossible to construct an algorithm for that always leads to a correct yes-or-no answer
Explain what this will do:
PROCEDURE printNums(max)
{
count ← 1
REPEAT UNTIL(count > max)
{
DISPLAY(count)
count ← count + 2
}
}
Starts the count at one, and inside the loop, the value of count is displayed, and then it will increase by two. The loop stops when count exceeds max, so all positive integers less than or equal to max will be displayed
Return
Will immediately end the function and send back whatever information it is meant to return
Generalization
Identifies commonalties among a set of entities
String
A sequence of characters
Example: “Hello”
List
Data type that represents a number of ordered values, usually strings or numbers
Example:
doglist = [“poodle”, “pug”, “pitbull”]