Knowing how to drive a car without knowing how the engine works is an example of
Abstraction
Which of the following is a benefit of using a list as a data abstraction in a program?
(A)Lists often allow their size to be easily updated to hold as many data values as needed.
(B)Lists convert all elements to strings so that they can be inspected character-by-character.
(C)Lists prevent duplicate data values from appearing in the list.
(D)Lists are used to store all input data so that there is a running record of all user input.
(A)Lists often allow their size to be easily updated to hold as many data values as needed.
Calculate a if a ← (5 + 3) * 2 MOD 3
Answer: a is 1.
What is the API, and what does it do?
Application Program Interface: contains specifications for how the procedures in a library behave and can be used.
An expression that evaluates to true or false in programming is called _______.
A Boolean Expression
For which of the following situations would it be best to use a heuristic in order to find a solution that runs in a reasonable amount of time?
(A)Appending a value to a list of n elements, which requires no list elements be examined.
(B) Finding the fastest route that visits every location among n locations, which requires n possible routes be examined.
(C) Performing a binary search for a score in a sorted list of n scores, which requires that fewer than scores be examined.
(D) Performing a linear search for a name in an unsorted database of n people, which requires that up to entries be examined
(B) Finding the fastest route that visits every location among n locations, which requires n possible routes be examined.
A computer science student completes a program and asks a classmate for feedback. The classmate suggests rewriting some of the code to include more procedural abstraction. Which of the following is NOT a benefit of procedural abstraction?
(A)Making the code more readable
(B)Making the code run faster
(C)Providing more opportunities for code reuse
(D)Reducing the amount of duplicated code
(B)Making the code run faster
Designed to represent and mirror the real world for testing.
Why are parameters useful when programming?
A. Parameters allow for more flexible, generalized behaviors in functions.
B. Parameters determine the number of times the function will run.
C. Parameters are useful for teams of programmers because they help define the boundaries of the problem they are trying to solve.
D. Parameters change the order of operations within a function.
A. Parameters allow for more flexible, generalized behaviors in functions.
What will the following program display if the INPUT function reads an even number such as 4?
a <-- INPUT ()
a <-- a MOD 2
DISPLAY (a)
For 4 or any other even number divided by 2, the remainder will always be 0. So..the answer is 0
A computer can use 6 bits to store non-negative numbers. Which of the following will NOT give an overflow error?
I. 54
II. 63
III. 64
IV. 89
I and II only
What is Procedural Abstraction?
The details of how a procedure works are abstracted away. You only need to know the name of the procedure, the number and type of parameters, and the output to expect.
Which of the following is NOT true about functions in programming?
A. Functions are reusable programming abstractions.
B. Functions help reduce the complexity of writing and maintaining programs.
C. Functions cannot make calls to other functions within the same program.
D. Once defined, a function can be called many times from different parts of a program.
C. Functions cannot make calls to other functions within the same program.
Assume that both lists and strings are indexed starting with index1. The listwordListhas the following contents. ["abc", "def\", "ghi", "jkl"] Let myWord be the element at index3 of wordList. Let myChar be the character at index 2 of myWord. What is the value o fmyChar? (A)"e" (B)"f\" (C)"h" (D) "i"
(C)"h"
What will the following program display?
a <-- 3
b <-- 14
c <-- 5
a <-- c
b <-- a
DISPLAY (a)
DISPLAY (b)
DISPLAY (c)
555
What is an Undecidable Problem
Does not have an algorithm that can give a correct "yes" or "no" for all cases of the problem. An algorithm may work for some cases, but not all.
Which of the following will call the function drawStar? A. drawStar B. drawStar(); C. function drawStar; D. function drawStar();
B. drawStar();
In the program below, y is a positive integer (e.g., 1, 2, 3, ...).
result = 0
REPEAT 3 TIMES
REPEAT y TIMES
result = result + 1
What is the value of "result" after running the program?
3y
Consider the following code segment.
j=1
REPEAT UNTIL <MISSING CONDITION>
j=j+2
Which of the following replacements for <MISSING CONDITION> will result in an infinite loop?
j=6
What is a RETURN statement?
1. To end a function before the end of the procedure is reached.
2. To send a value back to the calling program.