1/161
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced |
|---|
No study sessions yet.
Program design consists of
Steps a programmer should do before they start coding a program in a specific language
Pseudocode is
An informal high-level description of the operating principle of a computer program or algorithm
T/F - A flowchart is a type of diagram that represents an algorithm, workflow, or process
True
T/F - Software training involves the execution of a software component or system component to evaluate one or more properties of interest
True
IDE stands for
integrated development environment
debugging is the process of
solving errors in the source code
T/F - input is sending messages to the console/user
false
T/F - output is the process of reading information from the user, usually via keyboard or mouse
false
T/F - the MAIN method tells the program where to begin running code as it is the entry or starting point for the program
true
programming starts with
developing an algorithm
T/F - If the expression xyz % 3 == 0 is true and xyz is a positive integer, then the value stored in the variable xyz is evenly divisible by 3
true
What would be the best datatype to represent a product? A variable that stores information about the number of time currently in stock in a grocery store
int
What is the output of the following code?
BEGIN MAIN
int num1 = 500;
int num2 = 200;
int num3 = 300;
double average = num1 + num2 + num3 / 3;
PRINTLINE(average);
END MAIN800.0
What is the output of the following code?
BEGIN MAIN
int u = 3;
int v = 5;
u += v;
v += u;
u -= v;
v -= u;
PRINT (u + ", " + v);
END MAIN-5, 18
T/F - a String/string object is a primitive data type
false
What is the value of j after this code is executed?
BEGIN MAIN
int i = 6, int j=10;
j+=i;
END MAIN16
Consider the expression: value >= 30
Which of the following is equivalent to this expression?
value > 30 OR value == 30
Consider two variables x and y. If the values of x = 5 and y = 10
BEGIN MAIN
IF(x < 0) {
PRINT "Mr.Spock"
} ELSE {
IF (x > y) {
PRINT "Captain Kirk"
} ELSE {
PRINT "Star Trek it is!"
}
}
END MAINWhat is displayed as the result of the code being executed?
Star Trek it is!
T/F - Imagine a game of Yahtzee where a roll of dice always returns an even number.
Consider this code where the number is a variable that stores the value of the dice.
BEGIN MAIN
CREATE result = number % 2;
IF (result == 0)
PRINT "TRUE"
ELSE
PRINT "FALSE"
END MAINWhat will the code display?
true
T/F - an if statement does not need to have an else clause
true
T/F - If the variable isTested is a Boolean, then the statement below if a valid control expression: IF(isTested)
true
T/F in programming && is considered an arithmetic operator
false
T/F - If x = 3, y = 1, and z = 5 then the following Boolean expression evaluates to true:
( x > 0) && (y == 0) || (z < 5)
false
The Boolean expression ((A AND B) AND (NOT(A AND B)) evaluates to
false in all cases
Which statement below will be true after the following code terminates?
BEGIN MAIN
CREATE x = 0
WHILE (x < 100) {
x *= 2;
}
END WHILE
END MAINthe code won’t terminate; it’s an infinite loop
Consider this code:
BEGIN MAIN
int y=1;
int x=1;
PRINTLINE(x++);
END MAINWhat will this code print?
1
T/F - a relational ooperator used when comparing primitive data types is !=
true
T/F - a switch statement is similar to an if statement in that both are used to alter the flow of a program
true
T/F - pseudocode form of writing should be used only when the logic of the program is complex
false
T/F - Is this valid syntax for a FOR loop?
BEGIN MAIN
FOR(CREATE j = 0; j < 1000; j++)
PRINT(j)
END FOR
END MAINtrue
T/F - Consider the following code:
BEGIN MAIN
CREATE list[] = {5, 10, 15, 20}
END MAINThis would cause an error since there is no length/size included in the statement.
false
Select the correct declaration for a 2D array of 5 rows and 10 columns
CREATE myArray[5,10] OR CREATE myArray[5][10]
Which of the following correctly refers to the last element in the array of integers called numbers?
numbers[length of numbers-1]
T/F - an array index cannot be double, float, or String data types
true
Consider the following code:
BEGIN MAIN
CREATE values[7] = {1,2,3,4,5,6,7}
PRINTLINE (values[7])
END MAINWhat would happen when this code is executed?
it would print nothing as there is no index 7
T/F - you can only nest FOR loops
false
Consider the following code:
BEGIN MAIN
CREATE arrayOne[5]
END MAINIt stores 5 elements with legal indices from 0 to 4
T/F - 2D arrays are declared in row, column order, meaning first value is number of rows, second value is number of columns
true
T/F - Once an array is created, it cannot be resized during program execution
true
T/F - 2D arrays are still homogeneous
true
T/F - in general, the advantage of using a binary search over a linear search increases when searching larger sorted arrays
true
which of these sorts was not covered in the lecture slides?
merge
T/F - an array must be sorted for a Binary search to work properly
true
FOREACH loops cannot be used for which of the following tasks?
assignment
programming starts with
algorithm development
an algorithm is a
set of instructions
abstraction is the
level of detail
a good algorithm exhibits
precision, clarity, completeness, correctness, and simplicity
an algorithm can be described as
using a natural language, pictures and diagrams, and pseudocode or a specific programming language
all languages can
print to the screen
have variables and the ability to assign values to them
an entry point (a BEGIN and END) - a skeleton
can read text/numbers from the user
have basic operators
an application always contains a ____ method so that the program can be executed
MAIN
in object-oriented programming (OOP) language, MAIN is inside a _____
class
variable declaration indicates its ____ and possibly its _______ _____
type; initial value
a value is assigned using the assignment ________
operator
a constant value does not ______
change
data type tells
how much memory to allocate
the format in which to store data
the types of operations you will perform on data
primitive data types include
four integer types
two floating point types
character (char)
boolean
an expression is a combination of one or more _________ and ________
operators; operands
expressions evaluation follows ________ __________ ____
operator precedence rule (order of operations)
type conversion can be either ________ or _________ conversion
widening (promotion); narrowing (demotion)
arrays hold values of the ____ ____
same type
arrays are ______ in size
static
T/F - you can create an array of any type
true
you use a ____ to initialize or search arrays
loop
any time you have to visit an element in an array, you use ______ _____
nested loops
T/F - 2D arrays are like 1D arrays in nature
true
2D arrays use ______ _____ to traverse the array
nested loops
how many dimensions do array lists have?
1
array lists are _______ - they can grow and shrink
dynamic
searching an array list can be done either in ______ or ______ fashion
linear; binary
the linear search approach for array lists is slow and takes to the order of O(_)
O(n)
the binary search approach for array lists is much faster and takes to the order of O(_)
O(log(n))
T/F - bubble, selection, and insertion sort algorithms are relatively slow compared to other advanced sort methods
true
bubble, selection, and insertion sort algorithms perform to the order of O(_)
O(n²)
algorithm
a set of logical steps to accomplish a specific task; a set of instructions
abstraction
refers to the logical grouping of concept of objects; the level of detail
pseudocode
a mixture of languages not concerned with syntax, but concepts
skeletons
the smallest program you can write; define the entry/starting point of the program
variable
a name for a location in memory used to hold a data value
byte, int, short, long
float, double
char
boolean
what are the 8 primitive data types
expression
a combination of one or more operators and operands
true
T/F - while and do-while loops run an undetermined number of iterations
true
T/F - the for loop runs a predetermined number of iterations
counting loop
another name for a for loop
sentinel values
how the user controls a loop
sorting
the process of rearranging elements to be in a specific order
runtime stack
keeps track of active (currently running) methods in the program, and order of method calls
overloading
creating multiple functions with the same name but different parameters
object oriented programming
based on the concept of classes, from which objects are created
class
represents the concept of things in the real world; made of variables and methods
object
an entity in the real world that can be distinctly identified with a unique identity, state, and behavior
T/F - The following is an example of a valid program in Pseudocode
MAIN
false
T/F - Variables can be declared and initialized in one line of code
true
What type of error is present in the underlined C# code sample below?
public static void Main(string[] args)
{
Console.WriteLine("Enter a number");
int num = Convert.ToInt32(Console.ReadLine());
int squared = num + num;
Console.WriteLine(num + " squared is " + squared);
}
logic error
What type of error is present in the underlined C++ code sample below?
using namespace std;
int main()
{
dble value = 12;
cout << value << endl;
}
syntax error
Evaluate ((18 % 5) * 3) - (6 - 4) + 1
Assume all values are integers.
8
Evaluate as an integer: 5 + 3 / 2 * 4 – 2 % 1
9
Evaluate 10 - (40 + (20 / (10 - 5) * 2) / 4) + 50
Assume all values are integers.
18
T/F - In the equation 2 + 8 /4 * 2, the addition operation + is evaluated first.
false