APCPS 1st semester exam

¡Supera tus tareas y exámenes ahora con Quizwiz!

For what values of x and y when input in the program below, will display Right Right? "code "

x must be 0 and y must be a positive number

Given an integer variable x, select from the following code segments a situation where the variable is updated by two.

x ← x + 2

Consider the following procedure, testing, that is intended to display "You Passed!" if an integer, x, is within the range of 70 through 100, inclusive. Values of x that are not within that range should display "FAIL". PROCEDURE testing(x) { IF (***missing code***) { DISPLAY ("You Passed!") } ELSE { DISPLAY ("You Failed!") } } What code should replace ***missing code*** so the procedure will work as intended?

x ≥ 70 AND x ≤ 100

Sally notices that she has the same set of 10 blocks in her code in multiple places. She decides to create a new block (procedure) in Scratch so that she can simply replace those 10 blocks with one. Why would this be beneficial to Sally later when she debugs and reasons through her program?

The procedure makes that section more abstract, so she doesn't have to think through all 10 blocks each time she comes across them in her code. & if there's an error in the procedure, she can fix the error in the procedure without having to search through her code for each place the procedure is used.

The following program segment displays whether a number, x, is even. IF (x MOD 2 = 0) { DISPLAY ("EVEN") } IF (NOT (x MOD 2 = 0)) { DISPLAY ("NOT EVEN") } Select ***TWO*** statements that are true about the above problem.

The program uses remainder division to determine if a number is even. & The program provides a definite answer to the question, Is x even?

Consider the following code segment that appears in the middle of a program. "code" Which of the following can replace the missing statement in the REPEAT UNTIL block so that the user will be required to enter the correct password of "swordfish" before they can continue on with the rest of the program.

userPassword = "swordfish"

Consider the following code segment below: x ← 15 y ← 13 x ← y y ← x What would the value of x and y be after the code is executed?

x = 13, y = 13

Assume that a is 3 and b is 7. Which of the following conditions will evaluate to TRUE?

. (a < 4) AND (b > 4)

Which of the following binary (base-2) values is equivalent to the decimal (base-10) value 56?

00111000

Consider the following code segment: REPEAT UNTIL (x MOD 2 = 0) { x ← x + 3 } Assume that x is 7? How many times will the loop iterate?

1

Use the following code segment to answer this question. z ← (a + b) MOD 8 What will be the value of z be at the end of this code segment, given that a is 4 and b is 5?

1

Consider the following statement: "There are 10 types of people in the world: Those who understand binary, and those who don't." Why might computer scientists find this statement humorous?

10 (binary) = 2 (decimal)

Let a = 10, b = 5 and c = 7. Based on the flowchart below, what order will the values be output at the end of the flowchart?

10, 7, 5

Consider the following code. "code including rep until x>10 Assuming that before this code is run, x = 1. What would be displayed at the end?

16

Consider the following code segment: x ← 3 y ← 4 z ← 0 REPEAT n TIMES { z ← x + y x ← y y ← z } DISPLAY (z) Which of the following values will be displayed if n = 3?

18

Consider the following code segment: num ← 8 value ← 0 IF (num > 10) { value ← value + num * 2 } ELSE { value ← value + num } IF (num < 12) { value ← value * 2 } value ← value * 2 What is the value of the variable value after the code has executed?

32

According to Moore's Law, improvements should approximately double every year. If this holds true, how much improvement would there be in 5 years?

32x

Consider the following code segment: count ← 0 index ← 1 REPEAT LENGTH(numList) TIMES { IF (numList[index] > numList [1]) { count ← count + 1 } index ← index + 1 } Determine the value of count if the values in numList are 1,5,6,3,3,1.

4

Doris needs to represent 26 different letters using binary. What is the minimum number of binary digits she will need to represent this many letters?

5

Consider the following procedure: "code to average #s" Which of the following values is displayed if the user inputs the following list of values for each prompt: 1 2 3 4 5 6 7 8 9 15

6

Andy is writing a program that will keep track of all the movies a user has watched. After watching a movie, the user can enter the title, a brief description, and a rating of the movie. The user can then use the program to locate a movie he or she has watched and publish the ratings to an online forum. The program also has a "must watch" feature that allows the user to keep track of new movies he or she wants to see. Which of the following would be most helpful for Andy? Select ***TWO*** answers

A list of each movie containing the data about it (name, description, and rating) as well as a list containing all of those movie lists that the user has entered. & A "search" feature that finds movies from the list based on the user's search criteria.

Consider the following two algorithms for determining the tallest person in a group. Algorithm A Step 1: Everybody stands and lines up against the wall. Step 2: One person from those who are standing steps forward. Step 3: One person from those who are standing steps forward. Step 4: The shorter of these two people who stepped forward sits down. Step 5: Repeat steps 3 and 4 until only on person is standing. Step 6: The last person standing is the tallest in the group. Algorithm B Step 1: Everybody stands and lines up against the wall. Step 2: Each standing person pairs up with one other standing person. Step 3: The shorter member of each pair sits down. Step 4: Repeat steps 2 and 3 until only one person is standing. Step 5: The last person standing is the tallest in the group. Which of the following statements about these two algorithms is true when applied to a group of 32 people?

Algorithm A is never faster than Algorithm B

Every task that you deal with on a day-to-day basis, no matter how large or small, requires that you perform a specific set of actions and make a particular set of decisions in very precise ways. These sets of actions and decisions are known as what?

Algorithms

A digital file contains the following binary sequence of 24 bits: 010000110110000101110100 Which of the following types of data might the above sequence represent?

All of the above

The halting problem is a problem which decides whether or not a program will run forever. Sometimes, it is easy to determine whether or not a program will run forever. Computer Scientist Alan Turing proved that there is no algorithmic solution to the halting problem that works for every algorithm. What is the halting problem an example of?

An undecidable problem

Consider the following code segment: "code" If the variables onTime and absent both have the value false, what is displayed as a result of running the code segment?

Better late than never.

Consider the following numbers: · Binary 00101010 · Binary 00110011 · Decimal 50 Which of the following lists of numbers is in order from least to greatest?

Binary 00101010, Dec 50, Binary 00110011

Consider the following code segments designed to find the area of a triangle (A = ½ bh).

Both programs will work as intended, but Program B is more readable.

Consider the following code segment: Line 1: IF (x = 0) Line 2: { Line 3: y ← x - 4 Line 4: } Line 5: ELSE Line 6: { Line 7: y ← x + 4 Line 8: } Which of the following changes will NOT affect the results when the code is run?

Change line 3 to y ← -4

Which of the below options would be the best set of instructions to give for my program I designed in Scratch?

Click on the GREEN flag. Once the game starts, use the arrow keys to navigate your way through the maze. In your travels, collect the "hearts" for more lives and avoid being eaten by zombies.

Which of the following best describes the need for using cryptography (encryption) in data communications?

Cryptography ensures data is decipherable by the recipient, but not accessible by a third party.

An online hacktivist group calling themselves Relevance has targeted an international distribution company website citing unfair practices when charging shipping rates. Relevance members have created bot programs that will continually send information requests to the company's servers during prime shopping times. These requests will come in from servers spread across the globe. The actions taken by Relevance are an example of what kind of cyber-attack?

DDOS

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 occurences of "goats" to "sheep" and all occurences 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 the programmer's goal?

First, change all occurences of "goats" to "foxes". Then, change all occurences of "sheep" to "goats". Last, change all occurences of "foxes" to "sheep".

Which statements below are true about fixed and variable width encoding? Select ***TWO***answers.

Fixed width encodings are typically longer than a variable width encoding. & Variable width encodings must use some sort of delimiter in order to know where one character stops and another begins.

What would be beneficial when working with sprites and variables in Scratch programs?

Giving meaningful names to Sprites and variables so that you and other programmers can easily refer to them throughout the code

To determine the best route to take on a recent trip, a maps application gave the user three options based on traffic patterns, road construction, and roadways. Choosing the best alternative among the three possible routes is considered which of the following:

Heuristic solution

Which of the following are examples of dichotomous relationships? I. light switch on or off II. binary III. the colors of the rainbow IV. exist or not exist

I, II, and IV

A mother is attempting to determine which cell phone plan best fits her family's needs. She plans on using a shared pool of data for everyone in her family (defined as the people living in her home). Identify the best sequence of steps she should take to select a plan. I. Determine each family member's data usage. II. If the cost for data overages is lower than the added cost of the next tiered plan, select the plan with about the same amount of data that the family uses. Otherwise, select the plan with slightly more data than the family uses. III. Find the sum of the total data usage for the family. IV. Compare the cost of paying for data overages to the cost of paying for slightly more data.

I,III,IV,II

List myList contains integer values. Which of the following code segments will correctly remove all negative values from myList? Algorithm I: i ←1 REPEAT LENGTH(myList) TIMES { IF (myList[i] < 0) { REMOVE(myList, i) } i ← i + 1 } Algorithm II: i ← LENGTH(myList) REPEAT LENGTH(myList) TIMES { IF (myList[i] < 0) { REMOVE (myList, i) } i ← i - 1 }

II only

A student is creating a budget, and evaluating his purchases over the last month. Consider the following code segment which attempts to find the sum of all purchases made in the last month, stored in purchaseList. n ← 1 sum ← 0 REPEAT UNTIL (<missing code>) { sum ← sum + purchaseList[n] n ← n + 1 } What code can replace missing code to assign the total of all values in purchaseList to sum? I. n = LENGTH[purchaseList] II. n < LENGTH[purchaseList] III. n > LENGTH[purchaseList]

III only

Put the following steps of the Life Cycle of a Program in the correct order: I. Compile the code II. Construct the algorithm III. The Idea IV. Execute the compiled code V. Write the code

III, II, V, I, IV

The figure below shows a circuit composed of two logic gates. The output for the circuit is true. "diagram" Which of the following is a true statement about input A?

Input A MUST be true.

Which of the following is part of the CIA Triad?

Integrity

Which of the following are true about programming documentation?

It allows the programmer an opportunity to attribute help, work and code from others. & It is useful to other programmers that view your code, so that they can understand what different parts of the code will do.

Which of the following type 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

Alvy Ray Smith, the co-founder of Pixar, has written an article discussing the evolution of Pixar. In his article he states that forty years ago he and his colleagues conceived the idea of a fully digital movie. It took 20 more years to finally have the technology that allowed for the creation of Toy Story. What concept in computing gave Smith and his colleagues the belief that in time, the technology would evolve to the level needed by Pixar to create their first digital movie?

Moore's law

Elsa and her friend Olaf are co-owners of the world's largest ice cream truck, offering their customers the choice of 256 different flavors of ice cream. The truck, which has been built from an 18-wheeled tractor-trailer, houses the 256 tubs of ice cream in the refrigerated trailer. The side of the truck displays a large list of the 256 names of the different flavors, which the customers then use when they place their orders. Business is booming and the duo needs to serve their customers quickly. However, in order to quickly find the right tub of ice cream out of such a large collection, Elsa and Olaf both agree that they need to use an efficient solution. Elsa suggests that they organize the flavors alphabetically while Olaf suggests that they organize the flavors in order from his favorite to his least favorite. Which of the following solutions would allow these ice cream peddlers to find the customers' chosen flavors the most efficiently?

Organize the tubs alphabetically by flavor name and use a binary search algorithm to find the customer's requested flavor.

Bill receives an unsolicited e-mail from an address that appears to be his bank. The e-mail is asking Bill to verify his accounts information in a reply. The e-mail looks legitimate an even has his bank's logo and address. Bill replies to the email with his account number and security information. The next day, Bill receives a call from his bank that his account has been closed and all of the funds have been withdrawn. Bill has been defrauded and is a victim of which social engineering technique?

Phishing

Which of the following are examples of cybersecurity threats that are designed to attack users or computer networks?

Phishing & Distributed denial of service (DDoS)

An algorithm was developed to keep track of how many baskets a student has made while playing basketball. Which of the following program structures must be added to the old algorithm to create a new algorithm that only keeps track of 3 pt. baskets and not 2 pt. baskets?

Selection

The following set of instructions represent what kind of flow pattern? * Dump cereal in bowl * Pour milk in bowl * Eat cereal and milk * Place spoon and bowl in dishwasher

Sequencing

Which of the following best describes malware?

Software that is intended to damage or disable computers and computer systems

The table below shows the time a computer system takes to complete a specified task on the customer data of different-sized companies. "chart" Based on the information in the table, which of the following tasks is likely to take the longest amount of time when scaled up for a very large company of approximately 100,000 customers?

Sorting data

ASCII is a character-encoding scheme that uses a numeric value to represent each character. For example, the uppercase letter "G" is represented by the decimal (base 10) value 71. A partial list of characters and their corresponding ASCII values are shown in the table below. "table with alphabet" ASCII characters can also be represented by binary numbers. According to ASCII character encoding, which of the following letters is represented by the binary (base2) number 01010100?

T

Which of the following is NOT true about digitizing physical media?

The digital version is equally as good as the physical one in terms of quality.

Below is the International Morse Code, where each letter is made up of a unique combination of dots and dashes. "pic of morse code" This code is an example of which type of encoding?

Variable Width

As of 2016, the selling of used digital media is illegal. Along with selling it, there are many other illegal uses of digital media. Which of the following would be a legal use of digital media?

You download a song from iTunes and sync it to the cloud so that it is accessible on all of your devices.

What would be displayed after the following code executed? list ← [1,2,3] APPEND (list, 5) INSERT (list,4,4) REMOVE (list,5) DISPLAY (list)

[1,2,3,4]

SSL (Secure Sockets Layer) refers to the process in which websites send the user a "lock" to encrypt their data so that any traffic being sent over the Internet can then only be decoded by the website who create the original key/lock pair. What symbol found in the address bar usually indicates that a website has such security in place?

a green padlock

Whenever you generalize a variety of related problems and develop a common solution that can be applied to solve any of them, you are using a technique called

abstraction

Lisa is looking through papers left behind by some students after her class one day. She finds a scrap of paper with a strange letter series on it (see below). What word best describes what Lisa is looking at? Efn zj kyv kzdv wfi rcc xffu dve kf tfdv kf kyv rzu fw kyvzi tflekip. Kyv hlztb sifne wfo aldgrvu fmvi kyv crqp ufx. Z rd ze cfmv nzky jfdvfev kyrk yrj jkfcve dp yvrik. Z ufe'k vmvi kyvf kf xzzmv zk srtb.

ciphertext

Amy has written the largest part of her program and is now thinking of test cases to make sure the program works the way it should. When she finds errors, she fixes them. What is this process called?

debugging

Given the following code segment, what would be displayed if age were initialized with a value of 18? "code"

group 2

The volume of a rectangular prism is calculated by multiplying the length, width and height all together. What could we substitute into the section of the code marked < missing code > that would accurately calculate the volume based on the user input of l, w and h?

l*w*h

This is a section of code taken from a larger program. "Code including input val=4 & a "if and else" What outputs should be substituted in for "missing output 1" and "missing output 2" based on the condition?

missing output 1: Value does not equal 4 missing output 2: Value is equal to 4

Consider the process of encoding and decoding a message using the following Caesar cipher encoding scheme in which the plaintext and ciphertext alphabets are offset by four positions, as shown below: "chart" Which of the following encoded ciphertext strings decodes to an original plaintext message of "secret"?

oaynap

Which of the following would be the best example of discrete vs. continuous or digital vs. analog - the digital or discrete item being first followed by the continuous or analog next?

pics of 2 clocks with caption: Used for measuring time

The following code segment finds the sum of all numbers in the list, numList: sum ← 0 index ← 1 REPEAT LENGTH(numList) TIMES { sum ← sum + numList[index] index ← index + 1 } What code segment will find the product of all numbers in the list, numList?

product ← 1 index ← 1 REPEAT LENGTH(numList) TIMES { product ← product *numList[index] index ← index + 1 }

Sometimes we care about the order of a list and need to reorder them according to some kind of condition (alphabetical, numerical, etc). The algorithm we worked with in the Reorder and MultiSet to Set projects finds the element in the list that best matches the criteria and makes a swap to put it in its correct place and then repeats these steps, making multiple passes through the list. What type of sorting is this?

selection


Conjuntos de estudio relacionados

court reporters basic legal term

View Set

Chapter 15. Capital Structure: Limits to the Use of Debt

View Set

OB Chapt 5 Sexually Transmitted Infections(nclex)

View Set

CISA Practise Question Database 2013-2014

View Set

Foundations of Project Management

View Set

Software Engineering Test Questions

View Set

Mgmt Theory Midterm (Chapters 1, 2, and 3)

View Set

Chapter 3: Cell Structure and Function (biology)

View Set

OT Survey - Review Questions for Final

View Set

Cultural Anthropology FINAL Part 2

View Set