AP CP - Final

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

An office building has two floors. A computer program is used to control an elevator that travels between the two floors. Physical sensors are used to set the following Boolean variables. Variable Description onFloor1 Set to true if the elevator is stopped on floor 1; otherwise set to false onFloor2 Set to true if the elevator is stopped on floor 2; otherwise set to false callTo1 Set to true if the elevator is called to floor 1; otherwise set to false callTo2 Set to true if the elevator is called to floor 2; otherwise set to false The elevator moves when the door is closed and the elevator is called to the floor that it is not currently on. Which of the following Boolean expressions can be used in a selection statement to cause the elevator to move? (onFloor1 AND callTo2) AND (onFloor2 AND callTo1) (onFloor1 AND callTo2) OR (onFloor2 AND callTo1) (onFloor1 OR callTo2) AND (onFloor2 OR callTo1) (onFloor1 OR callTo2) OR (onFloor2 OR callTo1)

(onFloor1 AND callTo2) OR (onFloor2 AND callTo1)

Which of the following is used in the instructions below to determine how the task of "having breakfast" will be performed? Dump cereal in bowl Pour milk in bowl Eat cereal and milk Place spoon and bowl in dishwasher 1.)Sequencing 2.)Selection 3.)Iteration 1 only 1, 2 and 3 1 and 3 only 2 only

1 only

Sam's password is known to be formed of 5 decimal digits (0-9) in a given order. Karren and Larry are attempting to determine Sam's password by testing all possible combinations. If they are only able to try 10 combinations every day, how many days would it take to try all the possible combinations?

10,000

8 bit system

128, 64, 32, 16, 8, 4, 2, 1

What will be displayed when the code segment below, using the variables a, b, and c, is run? a ← 0 b ← 1 c ← a a ← 2 b ← a DISPLAY (b) DISPLAY (c)

2, 0

The following lines of code can be used are part of a program which is designed to calculate the total a person will pay for a meal which costs mealTotal before a tax and tip is paid. The final amount should include tax on the original mealTotal at a percentage of taxRate and a tip at a percentage of tipRate on the original mealTotal. 1.)mealTotal ← mealTotal + tip + tax 2.)tip ← mealTotal * tipRate / 100 3.)tax ← mealTotal * taxRate / 100 4.)DISPLAY mealTotal In which of the following orders could the lines I-IV be placed if the program is to run as intended? Select two answers. 1, 3, 2, 4 1, 2, 3, 4 2, 3, 1 , 4 3, 2, 1, 4

2, 3, 1 , 4 and 3, 2, 1, 4

Unicode

2^16

ASCII

2^7

Consider constructing an algorithm for a robot that can only perform the following three predefined operations. MOVE_FORWARD ( ): The robot moves one square forward in the direction it is facing ROTATE_LEFT ( ): The robot rotates in place 90 degrees counterclockwise (i.e., makes an in-place left turn) ROTATE_RIGHT ( ): The robot rotates in place 90 degrees clockwise (i.e., makes an in-place right turn) Which of the following algorithms will successfully cause the robot to trace out a square-shaped path, with the robot ending up in its original position and facing in its original direction? 1.)Step 1: MOVE_FORWARD ( ) Step 2: ROTATE_RIGHT ( ) Step 3: MOVE_FORWARD ( ) Step 4: ROTATE_RIGHT ( ) Step 5: MOVE_FORWARD ( ) Step 6: ROTATE_RIGHT ( ) Step 7: MOVE_FORWARD ( ) 2.)Step 1: MOVE_FORWARD ( ) Step 2: MOVE_LEFT ( ) Step 3: MOVE_BACKWARD ( ) Step 4: MOVE_RIGHT ( ) 3.) Step 1: MOVE_FORWARD ( ) Step 2: ROTATE_LEFT ( ) Step 3: MOVE_FORWARD ( ) Step 4: ROTATE_LEFT ( ) Step 5: MOVE_FORWARD ( ) Step 6: ROTATE_LEFT ( ) Step 7: MOVE_FORWARD ( ) Step 8: ROTATE_LEFT ( ) 4.)Step 1: MOVE_FORWARD ( ) Step 2: TURN_LEFT ( ) Step 3: Repeat steps 1 and 2 four more times

3

An IPv4 address has how many bits? (example of an IPv4 address 74.125.224.72)

32

What would be the final value of the variable third once the following program is complete? first ← 2 second ← 3 third ← first * second second ← third - first first ← first + second + third third ← second * first

48

Which of the following are examples of abstraction? Select two answers. A programmer found an error in her code and debugs it by rewriting every line of code, one at a time Correct! A diagram of a computer circuit is drawn using "logic gates". (Note: logic gates are symbols which represent a complicated group of components. They are designed to output an electrical signal based upon inputs they receive.) Code which has been written in a high-level language is rewritten in another high-level language with a different syntax. A programmer writes a procedure called volumeSphere which has a parameter radius and computes the area of a sphere with that radius. She uses this in her code each time the volume of a sphere needs to be computed.

A diagram of a computer circuit is drawn using "logic gates". (Note: logic gates are symbols which represent a complicated group of components. They are designed to output an electrical signal based upon inputs they receive.) A programmer writes a procedure called volumeSphere which has a parameter radius and computes the area of a sphere with that radius. She uses this in her code each time the volume of a sphere needs to be computed.

string

A linear sequence of characters, words, or other data.

For her 4th of July weather report, a local meteorologist wishes to predict the likelihood of the scheduled fireworks show being rained out by analyzing the most recent weather trends in the local vicinity. Which of the following sources of data would be the most appropriate for helping her make the prediction? A floating-point value representing the daily rainfall total for July 4th of the previous year A floating-point value representing the highest daily rainfall total over the last 365 days A list of integers representing the previous years in which it has rained in the area on the 4th of July A list of floating-point values representing the daily rainfall totals for the previous 10 days (June 24th through July 3rd)

A list of floating-point values representing the daily rainfall totals for the previous 10 days (June 24th through July 3rd)

Bits

A single binary values (0 or 1)

Which of the following terms best describes the process of suppressing complex details of a system and presenting a simplified version with just the relevant details?

Abstraction

While writing a program to regulate the speed of a self-driving car, you find that your software sometimes miscalculates the ideal car speed for city streets to be over 1500 MPH (nearly twice the speed of sound), when it should be approximately 30 MPH. Which of the following strategies would be most efficient to employ in debugging your program? At the very end of the speed calculations, add an additional line of code that divides the calculated speed by 50 so that the program never produces such high speeds After each calculation within your program, insert a temporary statement that displays the most recently calculated value. When running your program, compare the displayed values with the expected values to identify where in the program the error is being introduced. Starting at the end of your program and working backwards, systematically delete each line of code that relates to calculating and re-run the program after each deletion to identify where in the program the error is being introduced Delete all of the code relating to speed calculations and rewrite it again

After each calculation within your program, insert a temporary statement that displays the most recently calculated value. When running your program, compare the displayed values with the expected values to identify where in the program the error is being introduced.

The following two algorithms are designed to find the minimum value in a list of integers. Algorithm I: Create a variable (min), and set this to the first value in the list. Compare each subsequent value in the list against the value of (min), and if it is smaller than or equal to the current value, set (min) to this value. When the end of the list is reached, display the value of (min). Algorithm II: Create a variable (min), and set this to 0. Compare each value in the list against the value of (min), and if it is smaller than the current value, set (min) to this value. When the end of the list is reached, display the value of (min). Which of the following statements correctly demonstrates that the two algorithms are NOT equivalent? - Both algorithms will correctly display the minimum value of the list [-1, 3, -4, 8] - Neither algorithm will correctly display the minimum value of the list [0, 5, 6, 2] - Algorithm I will correctly display the minimum value of the list [4, 10, 6, 1], but Algorithm II will not - Algorithm II will correctly display the minimum value of the list [-4, 2, 3, 2], but Algorithm I will not

Algorithm I will correctly display the minimum value of the list [4, 10, 6, 1], but Algorithm II will not

Many tasks, large and small, can be solved by performing a specific set of actions and making a particular set of decisions in very precise ways. These sets of actions and decisions are known as what?

Algorithms

Which of the following algorithms require both selection and iteration? Select two answers: An algorithm that, given a list of integers, displays the sum of the integers in the list. An algorithm that, given a list of integers, displays the number of even integers in the list. An algorithm that, given two integers, displays the greater of the two integers. An algorithm that, given a list of integers, displays only the negative integers in the list.

An algorithm that, given a list of integers, displays the number of even integers in the list. An algorithm that, given a list of integers, displays only the negative integers in the list.

If a program were to guess a random number between 1-1,000 that you had selected, which would be the most effective choice of finding that number?

Binary Search

Gordon Moore

Co-founder of Intel

A programmer completes the user manual for a video game she has developed and realizes she has reversed the roles of (goats) and (sheep) throughout the text. Consider the programmer's goal of changing all occurrences of (goats) to (sheep) and all occurrences of (sheep) to (goats). The programmer will use the fact that the word foxes does not appear anywhere in the original text. Which of the following algorithms can be used to accomplish this?

First, change all occurrences of (goats) to (foxes), then change all occurrences of (sheep) to (goats), and then change all occurrences of (foxes) to (sheep).

Moore's Law describes the rate at which the number of transistors on a single chip doubles over time. Which of the following assumptions CANNOT be inferred as a direct consequence of this rate of doubling? Five years from now, web pages will require less memory (RAM) than today's web pages. Five years from now, top-of-the-line computers will have faster processors (CPUs) than today's top-of-the-line computers. Five years from now, computer programs will be able to solve complex problems faster than today's computer programs. Five years from now, electronic components can be made smaller than today's equivalent electronic components.

Five years from now, web pages will require less memory (RAM) than today's web pages.

Which statements below are true about fixed and variable width encoding? Select two answers. Fixed width encodings are limited to only 8 bits of data. Variable width encodings will always be longer than a fixed width encoding. Fixed width encodings are typically longer than variable width encodings. Variable width encoding must use extra bits to specify where characters start/end.

Fixed width encodings are typically longer than variable width encodings. Variable width encoding must use extra bits to specify where characters start/end.

An entrepreneur has hired a programmer to design software to take user input and convert it to appear a certain way. The programmer is not clear on the assignment, so he asks the entrepreneur to elaborate. Which of the following would be most helpful for the programmer to ask the entrepreneur to do to make the assignment clearer? Give some examples of user input and what the result should look like Write some sample code to show the programmer exactly what he wants Sit side-by side throughout the debugging process Select the most appropriate language for the application

Give some examples of user input and what the result should look like

Which of the following statements about high-level programming languages when compared to low-level programming languages is true? Correct! High-level programming languages provide programmers with more abstractions and are easier for people to read High-level programming languages provide programmers with more abstractions but are more difficult for people to read High-level programming languages provide programmers with less abstractions but are easier for people to read High-level programming languages provide programmers with less abstractions and are more difficult for people to read

High-level programming languages provide programmers with more abstractions and are easier for people to read

A particular problem is currently not able to be practically solved by using an algorithm. Which of the following statements about the problem could possibly be true? No algorithm has yet been developed which would solve this problem, but it is possible one may be developed in the future. An algorithm has been developed which would solve this problem but technology is not yet available which would compute this algorithm fast enough to be practicable. It is impossible to develop an algorithm which would solve this problem. I and II only I only I, II, and III I and III only

I, II, and III

Which of the following CollegeBoard AP Computer Science Principles Pseudocode commands is used to record something typed by a user of the program so that it can be used in the program? a MOD b RANDOM (a, b) DISPLAY (expression) INPUT ()

Input ()

branching

Instruction in a computer program that can cause a computer to begin executing a different sequence of instructions.

Operator blocks

Light-green colored blocks of code used to handle strings and math equations in Scratch.

Which of the following types of languages is optimized for machine processing and may be written and expressed as a series of binary digits (e.g., ones and zeros), making it difficult for humans to read and write?

Low-level programming language

Cardel is using Java to write a SaaS program for an educational technology company. He chooses to keep his code private and to protect his work from imitation but may wish to modify or update the code in the future. Which of the following will be most likely to make it easier for him to edit his code in the future? Select two answers. Syntax of the language Testing of the code with various inputs Naming conventions Adequate and appropriate comments

Naming conventions, Adequate and appropriate comments

What is an important step to take before beginning to write the code for a program?

Plan the logic and anticipated input/output of the code

sequential execution

Program instructions are executed one at a time, in order.

Which are the different types of Big-O notation?

Quadratic, Linear, Logarithmic, Constant

RAM

Random Access Memory

As part of the lifecycle of a program, after a computer programmer writes the code, it is then compiled and usually used to create an executable file to be run on the CPU. The code that is run through the compiler is known as what?

Source Code

A group of high school students is participating in a mobile application development contest. They have a limited time frame and would like to add many features. Which of the following strategies will allow them to create the best app they can in the time allotted? Strategy I: The students outline all goals. They make a program with all procedure names. They use software to simultaneously work on different parts of the code, frequently compiling and testing all code together. As each individual student completes one procedure, that student moves onto the next procedure. Strategy II: The students outline all goals. They work together on some shared code, and students work with their own copies of the code on specific parts. They check in regularly and completed, correct code is added to a master program. Strategy I only Strategy II only Strategy I and Strategy II will both allow the students to create a quality application Neither Strategy I nor Strategy II will allow the students to create a quality application

Strategy II only

Which following measures can a programmer take to help ensure that a program produces correct output?

Test multiple inputs on the program and develop the program in smaller steps, ensuring each step is correct

Chad has written the majority of his code in Scratch and is ready to start running his program using a variety of carefully chosen conditions to see if it functions properly in all these cases. Which of the following software development terms best describes this process?

Testing

Frankie is considering whether to use a binary or linear search in her program to find a value in a sorted list. When she tests the algorithms on selection of short lists of fixed-length lists she finds that the binary search is faster on average than the linear search. Another programmer suggests she tests both algorithms on a selection of lists which are 10 times as long as her original test lists. Which of the following best describes the likely results of this test? The binary search will still be faster on average than the linear search, and the difference in run times between the two searches will be approximately 10 times greater than for the shorter lists. The binary search will still be faster on average than the linear search, and the difference in run times between the two searches will be significantly more than 10 times greater than for the shorter lists. The binary search will still be faster on average than the linear search, and the difference in run times between the two searches will be approximately the same as for the shorter lists. The linear search will now be faster on average than the binary search.

The binary search will still be faster on average than the linear search, and the difference in run times between the two searches will be significantly more than 10 times greater than for the shorter lists.

The owner of a pet store wants to determine how many fish she can keep in a given aquarium before the population becomes too overcrowded for the fish to survive. Rather than risking the lives of actual fish, she decides to simulate an aquarium with a program in order to determine its maximum capacity. Which of the following would NOT be a useful factor to include when modeling the properties of the simulated tank and fish population?

The color of the fish

A city engineer is tasked with studying vehicular traffic patterns throughout a large metropolitan area. He designs a number of small, remote devices that can be installed along streets throughout the city to sense and record the hundreds of cars that pass through each of the city's five busiest intersections during a 24-hour period. Every time a car trips the sensor in a device, it increments an internal, 5-bit counter that stores the number of cars that have passed through the intersection since the counter was last reset. Every 24 hours, each device transmits the 5-bit value stored in its counter back to a central server that collects the daily data from all of the devices throughout the city. After transmitting, the counter in each device is reset back to 0. Fortunately, the engineer's supervisor points out a flaw in the device's design and orders that the engineer modify the design specifications for this device before building and installing the sensors. Which of the following is most likely the design flaw in this scenario? In order to measure the five busiest intersections, devices will need to be installed at all other intersections throughout the city as well. The counter is not capable of counting hundreds of cars without exceeding the limit of the five bits of storage. In addition to incrementing the counter, the device should also transmit its counter value after each car trips the sensor. The device should only transmit its counter value once per week to avoid overloading the network.

The counter is not capable of counting hundreds of cars without exceeding the limit of the five bits of storage.

control flow

The direction the computer program moves from instruction to instruction over time

What would be the result of running the program below? list ← [ 1, 2, 3 ] APPEND ( list, 5 ) INSERT ( list, 4, 4 ) REMOVE ( list, 5 ) DISPLAY ( list ) The program would display the list [1, 2, 3, 4]. The program would display the list [1, 2, 3, 5, 4]. The program would display an error message. The program would display the list [1, 2, 3, 4, 4].

The program would display the list [1, 2, 3, 4].

state space

The space of potential possibilities.

low-level languages

They are generally less readable by humans than other languages and They are very rarely ambiguous

What things could be considered part of the beginning "state" of a Scratch program?

Visibility of sprites, The background image, The value of a variable

nesting

Where different logic structures sequence, selection and loops are combined or nested in one another.

sequencing

all instructions are performed in order and executed at one time

comments

annotation in the code of a computer program

Binary code can represent

any number

bytes

bit multiples

In scratch, parameters is when you...

change the numbers in blocks

Binary Code

code represented with 1's and 0's

Sequencing

computer will run code in order, one line at a time from top to bottom

We use pseudocode to be _____________ and ____________.

concise and precise

Binary conditions

conditions with two possible outcomes

Transistor

controllable switch

fixed point representation

decimal point is always in the same place

The purpose of bits is to represent something ___________________ and to represent how ___________ or ________ is stored, accessed, transformed and used by computers.

digitally, info or data

The # of traqnsistors that could fit on a chip roughly ___________ every _________ year(s)

doubled, 1-2

pseudocode

informal method of writing algorithmic instructions that doesnt follow grammatical rules and syntax

In scratch, the sprites state is its ________________ and/or ______________________.

location, orientation

selection helps the computer...

make a decision

Big-O Notation

mathematical concept used by computer scientists to determine how well algorithms scale - performances classified into different categories.

Heuristics

method for deriving an approximate solution - Rules of Thumb but not guaranteed an accurately correct answer.

remix

modify and share a version of an uploaded existing project

Technology is like a ______________ it always _______________.

moving target, changes

procedure

named collection of steps in an algorithm that can be reused anytime it is needed without restating the detailed procedures (abstraction)

floating point representation

numbers where the decimal point can float because there is no fixed number of digits before and after the decimal point (AKA: real #'s)

If statements

only execute if a specific condition is met

flow pattern

pattern that can emerge when data is transformed using computational logic structures (sequencing, selection, iteration).

IF (n > 0) { Display ("The number is positive.") } ELSE { Display ("The number is not positive.") } What do we display if the number is 2? What do we display if the number is -3? What do we display if the number is 0?

positive, not positive, not positive

In scratch, the sprites are the _______________________.

program output

selection uses if then to tell the computer how to?

select a step or tell the sequence that should be executed

Algorithmic logic structure

selection, sequencing, iteration

operators

setting up a condition by comparison

flowcharts

simple diagram with symbols showing the flow of the process

Joanna wishes to create a variable in her Scratch game which records the number of seconds until the game ends. Which of the following would be the most appropriate name for this variable? Variable1 amountOfTimeRemainingInTheGame time_left

time_left

parameter

variable that defines a procedure or sets the conditions of an operation


Kaugnay na mga set ng pag-aaral

AAOS EMT Eleventh Edition Section 6: Medical (thanks edooley911)

View Set

Chapter 7: The Empires of Persia

View Set

Pharm Made Easy 4.0 The Genitourinary System

View Set

Ch 17: Information & Accounting Concepts

View Set

36 Art History: Characteristics of Modern Art in America, Surrealism, 34 Art History: DaDa, 33 Art History: Cubism, Modern Art in Context, 31 Art History: Modern Art in Context, Realism, 29 Art History: Impressionism, 28 Art History: Romanticism, Neo...

View Set