Data Abstraction
Algorithims
Control Structures
Boolean
Porpourri
100

Complete the following definition: An abstraction is a ____________ representation that stands for some collection of individual instances.

A. general

B. specific

C. fixed

D. artistic

A. general

100

What is an algorithm?

A step-by-step method used to solve a problem.

100

Which combination of statements can be used to express algorithms?

Iterative, sequential, and selection

100

A Boolean Expression

An expression that evaluates to true or false in programming.


100

Which of the following can be represented by a group of bits?

A. A high-definition picture
B. A number
C. Program code
D. All of the above

D. All of the above

200

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.

200

Name three common sorting algorithms.

Ex: Bubble Sort, Bucket Sort, and Merge Sort.



200
myAge = 12
PRINT "Next year I will be: "
PRINT myAge + 1
PRINT "In two years I will be: "
PRINT myAge + 2
PRINT "In three years I will be: "
PRINT myAge + 3
This code uses

A. Iteration

B. Sequencing

C. Selection



B. Sequencing

200

With Boolean, what does "A OR B" mean?

A. Neither A or B can be true for the condition to be true.
B. If A is true, then the condition is true.
C. If B is not true, then the condition is true.
D. Both A and B must be true for the condition to be

B-OR means either or both conditions can be true for the condition to be

200

What is a MOD operator?

The MOD operator, short for modulus, is a mathematical operation that returns the remainder when one number is divided by another.

300

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.

300

What is the difference between undecidable problems and intractable problems?



Undecidable problems are inherently unsolvable by any algorithm, while intractable problems are theoretically solvable but practically impossible due to their efficiency.

300

Which type(s) of statement is needed to find all records in a list that are positive?

 Iterative and selection

300

Which of the following is a method of search refinement that is based on Boolean logic?

A. Excluding results of a genre
B. Filtering results by decade published
C. Only including results with specific data values
D. All of the above require Boolean

D. All of the above require Boolean

300

Biologists ofen attach tracking collars to wild animals. For each animal, the following geolocation data is collected at frequent intervals.

1. The time

2. The date

3. The location of the animal

Which of the following questions about a particular animal could NOT be answered using only the data collected from the tracking collars?

(A) Approximately how many miles did the animal travel in one week?

(B) Does the animal travel in groups with other tracked animals?

(C) Do the movement patterns of the animal vary according to the weather?

(D) In what geographic locations does the animal typically travel?

(C) Do the movement patterns of the animal vary according to the weather?

400

Which of the following examples of abstraction can be found? Choose all that apply

A. Designs

B. Computer science

C. Languages

D. Maps

All of the above

A. Designs

B. Computer science

C. Languages

D. Maps

400

Why is a binary search the most effective way to search a sorted data set?

  • A. The item searched for bubbles to the beginning of the data set after one pass
  • B. It uses machine learning with each pass of the data to learn where the data is located in the file to speed up the search process
  • C. It eliminates half the data set with each iteration of the search
  • D. It merges sections of data to only have to search one section with each iteration
  • C. It eliminates half the data set with each iteration of the search
400

Silas develops this algorithm to compute the calories burned for an activity for a given number of minutes and body weight:


  1. If the activity is running, compute caloriesPerMin by dividing weight by 10.5
  2. If the activity is walking, compute caloriesPerMin by dividing weight by 15.5
  3. Compute numCalories by multiplying caloriesPerMin by numMinutes


He implements the algorithm in an app, and users soon ask for the ability to compute the total calories for multiple sessions of walking or running.

What structure must be added to the original algorithm so that it can compute the total across multiple sessions?

Iteration

400

According to the US Constitution, a presidential candidate must be at least 35 years old and have been a US resident for at least 14 years. The variable age represents a candidate's age, and the variable residency represents their years of residency.

Which of the following expressions evaluates to true if a candidate meets the criteria?

A. age > 35 AND residency ≥ 14

B. NOT(age < 35) AND residency > 14

C. NOT(age < 35) AND NOT (residency < 14)

D. age ≥ 35 AND NOT (residency > 14)

C. NOT(age < 35) AND NOT (residency < 14)

400

Which of the following algorithms require both selection and iteration? Select two answers.

(A) An algorithm that, given two integers, displays the greater of the two integers

(B) An algorithm that, given a list of integers, displays the number of even integers in the list

(C) An algorithm that, given a list of integers, displays only the negative integers in the list

(D) An algorithm that, given a list of integers, displays the sum of the integers in the list

B,C

500

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.



500


An algorithm finds the smallest (small) number in a list of integers (num). Which code does it use?

a)    if (small < num){
    num = small
}
b) if (small < num){
    small = num
}
c) if (small > num){
    num = small
}
d) if (small > num){
    small = num
}


d) if (small > num){
    small = num
}

500

FOR EACH score IN testScores
{
    IF score > 0
    {
        total <- total + score
    }
    count <- count + 1
}
DISPLAY ("The average score on the test was:", total / count)

Test 1 [100, 90, 80, 80, 85, 50, 0, 85, 90]

Test 1 [192, 85, 74, 100, 96, 88]

If a programmer tested the above code with the values indicated, would the program correctly calculate the average of the test scores (assume all variables and lists are appropriately initialized)?

  • A. Yes, the code works as it should for both test cases
  • B. No, the code does not average the test scores correctly for either test
  • C. No, the code only works for the Test 1 scores
  • D. No, the code only works for the Test 2 scores
  • D. No, the code only works for the Test 2 scores
500

Which of the following will result in a True value?

NOT (TRUE AND FALSE) AND TRUE
NOT (TRUE AND TRUE) AND TRUE
NOT (TRUE AND TRUE) OR TRUE
A. I only
B. I and II
C. I and III
D. I, II, and III

C. I and III

500

What will the following program display?

x ← 10

arr ← ["I", "Love", "Puppies"]

DISPLAY (arr[(x - LENGTH(arr))MOD 4])

A. I
B. Love
C. Puppies
D. ArrayOutOfBounds

C. Puppies

Explanation:
x = 10
LENGTH(arr) = 3

10 - 3 = 7
7 MOD 4 = 3
arr[3] = "Puppies"