AP CSP Unit 1-5

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

From the list of possible outputs listed two (2) are IMPOSSIBLE. Choose the two (2) outputs that are impossible for this code to produce. x <- 0 REPEAT_UNTIL( x = 3 ) y <- 0 x <- x+1 REPEAT_UNTIL ( y = 3 ){ y <- y+1 DISPLAY( x + ", " + y) } }

0,0 2,4

Bit rate

(sometimes written bitrate) the number of bits that are conveyed or processed per unit of time. e.g. 8 bits/sec.

SSL/TLS

Secure Sockets layer / Transport Layer Security - An encryption layer of HTTP that uses public key cryptography to establish a secure connection.

Giving the parameters a value

Which of the following is NOT part of defining a function?

Modulo (or "mod")

the name of the mathematical operation. Modulo gives the remainder from dividing two numbers. For example: 17 MOD 13 is 4.

Moore's Law

the observation that computing power roughly doubles every two years.

Hypertext Transfer Protocol (HTTP)

the protocol used by the World Wide Web. It describes how messages are formatted and interchanged, and how web servers respond to commands.

Private key.

A sealed cup of beans that Alice puts on the table.

Summary table

A table of aggregate information about a dataset (e.g., the average, sum, count of some values). A table that summarizes information about some larger dataset. It typically consists of performing computations like sums, averages, and counts on higher level groupings of information. The intent is to summarize lots of data into a form that is more useful, and easier to "see".

for loop

A typical looping construct designed to make it easy to repeat a section of code using a counter variable. The for loop combines the creation of a variable, a boolean looping condition, and an update to the variable in one statement.

Return Value

A value sent back by a function to the place in the code where the function was called form - typically asking for value (e.g. getText(id)) or the result of a calculation or computation of some kind. Most programming languages have many built-in functions that return values, but you can also write your own.

Application Program Interface

A well-documented library of functions provided in a programming language that helps to simplify complex programming tasks.

CSV

Abbreviation of "comma-separated values," this is a widely-used format for storing data.

What will be displayed as a result of the javascript code below executing? var a = 0; while( a != 5 ){ a = a+2; } console.log(a);

Infinite loop

BMP

Uncompressed Image

WAV

Uncompressed Sound

Vigenère cipher (Vee-zha-nair)

a method of encrypting text by applying a series of Caesar ciphers based on the letters of a keyword.

Function

a named group of programming instructions. Functions are reusable abstractions that reduce the complexity of writing and maintaining programs

Hexadecimal Number System

a number system consisting of 16 distinct symbols -- 0-9 and A-F -- which can occur in each place value.

Heuristic

a problem solving approach (algorithm) to find a satisfactory solution where finding an optimal or exact solution is impractical or impossible.

Top Down Design

a problem solving approach (also known as stepwise design) in which you break down a system to gain insight into the sub-systems that make it up.

Encryption

a process of encoding messages to keep them secret, so only "authorized" parties can read it.

Decryption

a process that reverses encryption, taking a secret message and reproducing the original plain text

Virus

a program that runs on a computer to do something the owner of the computer does not intend.

Models and Simulations

a program which replicates or mimics key features of a real world event in order to investigate its behavior without the cost, time, or danger of running an experiment in real life.

Loop

a programming construct that repeats a group of commands.

while loop

a programming construct used to repeat a set of commands (loop) as long as (while) a boolean condition is true.

Binary Question

a question to which there are only two possible answers.

Abstraction

a simplified representation of something more complex. Abstractions allow you to hide details to help you manage complexity, focus on relevant concepts, and reason about problems at a higher level.

Caesar's Cipher

a technique for encryption that shifts the alphabet by some number of characters.

Phishing Scam

a thief trying to trick you into sending them sensitive information. Typically these include emails about system updates asking you send your username and password, social security number or other things.

Asymmetric encryption

a type of cryptographic based on algorithms that require two keys -- one of which is secret (or private) and one of which is public (freely known to others).

Image

a type of data used for graphics or pictures.

Canvas

a user interface element to use in HTML/JavaScript which acts as a digital canvas, allowing the programmatic drawing and manipulation of pixels, basic shapes, figures and images.

Public key

a value that can be used to encrypt a message. However, only when combined with a mathematically-related private key, can the message be decrypted.

Random Substitution Cipher

an encoding technique that maps each letter of the alphabet randomly to different letters or characters.

Metadata

data that describes other data. For example, a digital image may include metadata that describes the size of the image, number of colors, or resolution.

Transmission Control Protocol (TCP)

provides reliable, ordered, and error-checked delivery of a stream of packets on the internet. TCP is tightly linked with IP and usually seen as TCP/IP in writing.

Protocol

A set of rules governing the exchange or transmission of data between devices.

Router

A type of computer that forwards data across a network

ZIP

Compressed Files - Lossless

PNG

Compressed Image - Lossless

GIF

Compressed Image - Lossless (256 color limit)

JPEG

Compressed Image - Lossy

MP3

Compressed Sound - Lossy

Array

A data structure in JavaScript used to represent a list.

Code

(v) to write code, or to write instructions for a computer.

Server

A computer that awaits and responds to requests for data.

Client

A computer that requests data stored on a server.

Encrypting a message.

The number of beans Alice chooses to put in the cup initially.

Iteration

"loop" by another name - the repetition of a statement, process, or procedure.

Given the following array, what will the code segment below display after being run? The initial state of the array is shown for you to use as a reference. data = [5, 8, 3, 4, 2, 1] Index = 1, 2, 3, 4, 5, 6 a <- data[5] b <- data[2] DISPLAY(a + b)

10

What is contained in the list data after the following code segment is run? data <- [10, 45, 38, 16, 23] Index = 1, 2, 3, 4, 5 REMOVE(data, 2) REMOVE(data, 3)

10, 38, 23

What does the following code segment display? data <- [3, 5, 8, 2, 1] index = 1, 2, 3, 4, 5 REMOVE(data, 3) DISPLAY(data[3])

2

What value will be displayed after the loop has executed? var a = 5; while (a >= 3){ a = a - 1; } console.log(a);

2

When responding to a question with 4 choices, the most efficient method will require _____ number of bits.

2 bits

ASCII has an encoding for every character of the alphabet as well as encodings for numbers -- that is, encodings for the symbols of the digits 0-9. So here is a trick question: How many bits are required to store the text of the number "150" in ASCII?'

24 bits

Bit

A contraction of "Binary Digit". A bit is the single unit of information in a computer, typically represented as a 0 or 1.

The counter variable in the code below increments by 1 each time through the loop. What will the value of counter be after the following loop executes? var counter = 0; var n = 6; while(n > 0){ n = n - 2; counter = counter + 1; } console.log(counter)

3

What is stored in list data after the following code segment is run? data <- [0,1,2] INSERT(data, 1, 3) INSERT(data, 2, 4) INSERT(data, 3, 5) DISPLAY(data) Data = [0, 1, 2] Index = 1, 2, 3

3, 4, 5, 0, 1, 2

What will be displayed as a result of the code below executing? var a = 5; while (a < 5) { a = a - 1; } console.log(a);

5

What is the minimum number of bits you need to encode the 26 letters of the alphabet plus a space?

5 bits

Consider the following code segment that appends numbers to a list one at a time. data <- [] APPEND (data, 2) APPEND (data, 6) APPEND (data, 9) APPEND (data, 3) APPEND (data, 1) What is the value of data[2] after the code above is executed (Assume indexing begins with 1)?

6

What is the output of the code segment below? The initial state of the array is shown for you to use as a reference. data = [5, 8, 3, 4, 2, 1] Index = 1, 2, 3, 4, 5, 6 i <- 4 a <- data[i] b <- data[i + 1] DISPLAY(a + b)

6

How many unique IP addresses could be made in a fixed-length IP address system using 6 bits?

64

If you just had two shapes (say, a circle and a square), how many 3-place patterns could you make?

8

Hexadecimal

A base-16 number system that uses sixteen distinct symbols 0-9 and A-F to represent numbers from 0 to 15.

One-pager

A business/corporate term for a one-page document that summarizes a large issue, topic or plan. The purpose is to distill and highlight the most important pieces of information in a digestible manner so that the reader can be quickly acquainted with the relevant details of the "big picture."

API

A collection of commands made available to a programmer

Aggregation

A computation in which rows from a data set are grouped together and used to compute a single value of more significant meaning or measurement. Common aggregations include: Average, Count, Sum, Max, Median, etc.

README

A document providing background information about a dataset.

List

A generic term for a programming data structure that holds multiple items.

Selection

A generic term for a type of programming statement (usually an if-statement) that uses a Boolean condition to determine, or select, whether or not to run a certain block of statements.

The Internet Engineering Task Force (IETF) defines the protocols and standards for how the Internet works. The members of the IETF are:

A loosely organized collection of citizens and engineers who communicate mostly by email.

Which of the following is NOT true about packets?

A message sent across the Internet can always be contained in a single packet

IP Address

A number assigned to any item that is connected to the Internet.

Which two of the following statements are true about routing on the Internet.

A packet travelling between two computers on the Internet may be rerouted many times along the way. A packet contains addressing information to allow routers to decide how best to forward along that packet towards its destination.

For Loop

A particular kind of looping construct provided in many languages. Typically, a for loop defines a counting variable that is checked and incremented on each iteration in order to loop a specific number of times.

Algorithm

A precise sequence of instructions for processes that can be executed by a computer and are implemented using programming languages. (NOTE: this is the definition from the AP CS Principles framework).

Prototype

A preliminary sketch of an idea or model for something new. It's the original drawing from which something real might be built or created.

Random Substitution Cipher

A problem that cannot be solved in a reasonable amount of time

Low level programming language

A programming language that captures only the most primitive operations available to a machine. Anything that a computer can do can be represented with combinations of low level commands.

High level programming language

A programming language with many commands and features designed to make common tasks easier to program. Any high level functionality is encapsulated as combinations of low level commands.

Hypothesis

A proposed explanation for some phenomenon used as the basis for further investigation.

A binary question is defined as:

A question which can be answered in only one of two possible ways

The definition of HTTP makes use of the ASCII character set without reference to how these characters are encoded. Explain why this is an example of abstraction.

Abstraction involves removing details and generalizing functionality. This applies to the protocols that make up the different functions of the Internet because each is able to "assume" that certain functionality already exists (i.e. the details of that functionality are abstracted away) and doesn't need to account for it explicitly. For example, the Internet Protocol doesn't need to worry about how bits are actually transmitted via wires, fiber optic cables, or wifi - it can just solve the problem of delivering fixed-size packets of information via the Internet. The HTTP protocol can similarly assume that the details of what binary values map to which characters is a problem that's been already solved by the ASCII protocol. So long as the receiver of an HTTP request understands the ASCII protocol, then the HTTP protocol can focus on what it was designed to do, namely requesting and receiving files across the Internet.

Tiffany is writing a program to help manage a bake sale. She writes the following code which prompts the user to enter the total number of items a person is buying and then a loop repeatedly prompts for the cost of each item. She wrote the code but there is a problem: it runs in an infinite loop. How can Tiffany change her code so it doesn't loop forever? 0 var numItems = promptNum("How many items?"); 1 var total = 0; 2 while (numItems > 0){ 3 total = total + promptNum("Enter next item price"); 4 } 5 console.log("The total is" + total);

Add after line 3: numItems = numItems - 1;

Public key.

Alice dumping the beans out of the cup and counting off her original number.

ASCII

American Standard Code for Information Interchange. ASCII is the universally recognized raw text format that any computer can understand.

Choose Two: Identify the two true statements about HTTP.

An HTTP request is sent from a client to request access to data stored on a server. Displaying a web page will often require multiple HTTP requests in order to acquire all the necessary data.

Parameter

An extra piece of information that you pass to the function to customize it for a specific need.

Caesar Cipher

Another term for encrypted message

Decrypting a message.

Bob adding beans to the cup.

Meaningful function names help people better understand programs. Functions in programming are named groupings of programming instructions.

Choose the two (2) statements that are true about functions

DDoS Attack

Distributed Denial of Service Attack. Typically a virus installed on many computers (thousands) activate at the same time and flood a target with traffic to the point the server becomes overwhelmed.

Computationally Hard

Encryption in which arbitrary symbols replace letters

Encrypt

Encryption scheme based on shifting the alphabet

Cipher

Encryption that shifts the alphabet differently per character

HTTP is considered to be a high level protocol because:

HTTP requests make use of abstractions provided by lower level protocols.

What feature of DNS and IP allow the internet to scale?

Hierarchy

Moore's Law

Historically it has been observed that computer processing speeds tend to double every two years. This is known as:

3,753 bytes (30,024 bits)

How many bytes (or bit) are required to encode an image that is 25 pixels wide and 50 pixels tall, if you encode each pixel with 3 bytes (24 bits) of RGB data. (Don't forget to add in the metadata! -- you should assume that we are using the file format used in the associated lesson with metadata that had 1 byte each for width, height, and bits-per-pixel.)

A programmer created a list of all of her sibling's ages: Unfortunately, she made a typo! Her middle sibling is 13 years old. Which of the following solutions will NOT fix the typo? Data = [10, 12, 17] Index = 1, 2, 3

INSERT the value 13 at the index of 2

Student response should cover the following points. To brighten: RGB values should be increased. Example: add some amount to each of the RGB values to make it brighter. To darken: do the opposite of brightening - subtract 50 from each value.

Imagine that you have an image that is too dark or too bright. Describe how you would alter the RGB settings to brighten or darken it. Give an example.

The use of asymmetric keys allows for people who haven't agreed in advance on a key to build one without having to share it in secret.

In symmetric encryption the same key is used to encrypt and decrypt a message. In asymmetric encryption different keys are used to encrypt and decrypt. Give at least one reason why asymmetric encryption is useful.

Learning to program isn't just a matter of memorizing commands. The art of programming is always about understanding how to use the features of a programming language to solve a problem. Whether you know 4 commands of a language or hundreds, you will always be constrained by the programming language. The reason you need to learn how to program is because there isn't a command to do every little thing - you have to understand the set of things that a programming language can do, and then use your creativity and problem-solving skills to get the computer to do what you want.

In the beginning of this unit, we solved a series of problems with a limited set of commands (only 4). Give at least one reason why it's useful to learn how to solve and program solutions with a limited set of commands.

Answers will vary, but should include these concepts: Enables programmers to write code in larger, more logical chunks. Enable programmers to focus on what something does rather than how it does it. Streamlines code into shorter, but more readable (understandable) sequences. Enables programmers to reuse code segments. Examples may include: Combining the turns and moves to go the opposite direction with the turnAround function. Combining turns and moves to create the drawRectangle function. Combining turns and moves to create drawSide, drawSteps, and drawDiamond functions.

In your own words, explain at least one reason why programming languages have functions. Include an example of something you did in this lesson that demonstrates the reason you describe.

Students should not feel comfortable sending their password over the internet using a substitution cipher. With a frequency analysis tool substitution cipher is very easy to crack. Someone would likely be able to figure out the password fairly quickly.

Knowing what you know now about frequency analysis, would you feel comfortable sending your password over the Internet using a substitution cipher? Why or why not?

Easy/fast to encode data Easy to decode data if you know the key but difficult to crack without it Decoding returns the exact data that was encoded originally Encoded message is easy to transmit or communicate

List 3 characteristics of the ideal encryption scheme.

If I understand how the internet works then I will be able to:

Make informed choices to support or oppose decisions my government makes about access to the internet and make informed choices about my privacy on the internet.

Sequencing

Putting commands in correct order so computers can read the commands.

Abstraction

Reducing information and detail to focus on essential characteristics.

What is an RFC?

Request for Comments

Functions with parameters can be used to prevent the creation of duplicated code. Parameters help generalize the solution of a specific problem.

Select the two true statements about functions with parameters:

Packets

Small chunks of information that have been carefully formed from larger chunks of information.

Pick Two: Pick the two statements about packets and routing on the Internet which are true.

TCP ensures messages can be reliably transmitted across the Internet TCP must account for the fact that packets may not arrive at a destination computer in the intended order

26 × 25 × 24 ×···× 3 × 2 x 1

The Caesar Cipher has 25 different shifts to try. How many possibilities are there to try in a random substitution cipher?

Why do computers need to periodically check the DNS for websites you have already visited?

The IP address associated with a given URL is not static; it can change.

If the post office delivered mail exactly like routers deliver messages on the internet, which 2 of the following statements would be true?

The mailman would sometimes take a different path to deliver each letter to your home. Letters would be written on the outside of envelopes for all to read instead of letters put inside envelopes.

Raw data

The original data as it was collected.

Pivot Table

The tool used by most spreadsheet programs to create a summary table.

A single central register of IP addresses and names (a DNS style system) is an efficient means of translating human readable names to IP addresses. Which of the following is NOT solved by DNS?

There are too few IP addresses to meet the current demand.

Efficiency definition: achieving some desired outcome while minimizing wasted effort or resources. Note that, depending on the context, the resources or effort may take many different forms. Other examples may include fuel efficiency in cars, energy efficiency in appliances or light bulbs, or even efficient use of space in apartments. The description of similarities might include the idea of how much one is getting (amount/size of the image compared to miles per gallon or hours of operation or living space) for the expenditure of resources (lines of code compared to fuel or electricity or rent).

This unit introduced the notion of "efficiency" in programming, and that it might mean different things at different times. Think of an example outside of computer science in which you have heard the term "efficiency" and compare it to the ways we talked about efficiency in programming. In what ways is the meaning of "efficiency" the same? In what ways is it different?

Latency

Time it takes for a bit to travel from its sender to its receiver.

Iterate

To repeat in order to achieve, or get closer to, a desired goal

Iterate

To repeat in order to achieve, or get closer to, a desired goal.

Bandwidth

Transmission capacity measure by bit rate

Decrypt

Use an algorithm to decode a message

Vigenere Cipher

Use an algorithm to encode a message

Yes in general the longer the key the "better" the encryption. It is harder to find patterns in a longer key. A key is better when it does not have repeating letters used (ex. AAAAA would not be a good key).

Using the Vigenere cipher, does the length of the key matter? For example, if one key is length 5 and another is 20, does one produce a "better" encrypted message than the other, or is it basically the same? Yes or no? Explain your reasoning.

13

What is 13 MOD 17?

5

What is 20 MOD 15?

A Caesar cipher is a type of substitution encoding in which each letter in the message is replaced by a letter at a fixed position down the alphabet.

What is a Caesar cipher? As part of your answer demonstrate encrypting the plaintext messages: CS IS COOL with a caesar cipher.

A way to give input to a function that controls how the function runs.

What is a function parameter?

The number of characters to shift each letter in the alphabet.

What is the "key" to a Caesar Cipher that someone needs to know (or discover) to decrypt the message?

Decrypting is just using an algorithm to undo the encryption. It's what the recipient of an encrypted message needs to do to recover the original message. Cracking is trying to figure out a decryption algorithm for an encrypted message, using clues found within the secret message itself. If you know the algorithm that was used, then cracking the encryption means figuring out the key that was used with that algorithm. It is more like detective work.

What is the difference is between "cracking" a code and "decrypting" a message?

There is enough data that traditional data processing applications are inadequate.

When a computer scientist uses the term "Big Data" what do they typically mean?

Why don't we need to know the IP addresses for our favorite sites?

When we type in a web page address and click [enter], the browser contacts the DNS server to look up the IP address. It does this every time we browse to a page.

Cracking encryption

When you attempt to decode a secret message without knowing all the specifics of the cipher, you are trying to crack the encryption.

Functions cannot make calls to other functions written by the same programmer.

Which of the following is NOT a true statement about functions?

...people's access to computing and the Internet differs based on socioeconomic or geographic characteristics.

Which of the following is the most accurate description of what is known as the "digital divide". The digital divide is about how...

Two programmers solving the same problem using Top-Down Design should arrive at identical programs.

Which of the following statements about writing functions and Top-Down Design is NOT true?

Companies are required by law to give users options to personalize what data they collect about them.

Which of the following statements is the LEAST TRUE about personal data that technology companies potentially collect about their users?

Defining the parameters of a function

Which one of the following is NOT a valid use of randomNumber?

Which of the following is true about while loops in JavaScript?

While loops run as long as a given boolean condition is true.

Any response that explicitly says that the main point of compression is to represent the same information with fewer bits should receive full credit.

Why do you want to compress anything? What's the point?

A good response would mention that compression is hard because there are too many possible ways it could be done to reasonably just try every possibility. This means that you can never really know whether an exact or optimal solution has been reached - at least not in a reasonable amount of time. The resois might mention the need to come up with a heuristic, but a perfectly good response might not mention it.

Why is compression a "hard problem" for computers? Draw on your own experience compressing text with the text compression widget. Is there a way to know when you've compressed it the most? Explain why you can or can't know.

One cannot solve using frequency analysis directly. The key length is variable and potentially very long.

Why is the Vigenere cipher hard to crack? (select 2)

The JavaScript code below creates an array of numbers and makes a call to the mystery function. The code for the mystery function is also shown and it makes use of the swap function which you should assume works as described in the previous question. mystery(data); function mystery(data){ if(data[1] < data[0]){ swap(data, 0, 1); } if(data[2] < data[1]){ swap(data, 1, 2); } if(data[1] < data[0]){ swap(data, 0, 1); } } Data = [3, 8, 1] Index = 0, 1, 2

[1, 3, 8]

Computationally Hard

a "hard' problem for a computer is one in which it cannot arrive at a solution in a reasonable amount of time.

Big Data

a broad term for datasets so large or complex that traditional data processing applications are inadequate.

Turtle Programming

a classic method for learning programming with commands to control movement and drawing of an on-screen robot called a "turtle". The turtle hearkens back to early implementations in which children programmed a physical robot whose dome-like shape was reminiscent of a turtle.

Library

a collection of commands / functions, typically with a shared purpose

Lossy

a compression scheme in which "useless" or less-than-totally-necessary information is thrown out in order to reduce the size of the data. The eliminated data is unrecoverable.

Lossless

a compression scheme in which every bit of the original data can be recovered from the compressed file.

Lossless Compression

a data compression algorithm that allows the original data to be perfectly reconstructed from the compressed data.

Documentation

a description of the behavior of a command, function, library, API, etc.

Binary Message

a message that can only be one of two possible values.

Network Redundancy

having multiple backups to ensure reliability during cases of high usage or failure

Key Event

in JavaScript an event triggered by pressing or releasing a key on the keyboard. For example: "keyup" and "keydown" are event types you can specify. Use event.key - from the "event" parameter of the onEvent callback function - to figure out which key was pressed.

A statistician would like to simulate rolling a single die until she has rolled the die a total of 100 times, or she rolls a six a total of 25 times, whichever comes first. Which boolean expression should she use for the <missing code> to accomplish this? var rolls = 0; var sixes = 0; while ( <missing code> ){ var nextRoll = randomNumber(1, 6); if(nextRoll == 6) { sixes = sixes + 1; } rolls = rolls + 1; } console.log(rolls);

rolls < 100 && sixes < 25

Pixel

short for "picture element" it is the fundamental unit of a digital image, typically a tiny square or dot which contains a single point of color of a larger image.

Firewall

software that runs on servers (often routers) that only allows traffic through according to some set of security rules.

Domain Name System (DNS)

the Internet's system for converting alphabetic names into numeric IP addresses.

Private key

the complementary key to a public key that is used to decrypt a message.

Cipher

the generic term for a technique (or algorithm) that performs encryption

Antivirus Software

usually keeps big lists of known viruses and scans your computer looking for the virus programs in order to get rid of them.

You are trying to write a function swap(list, a, b) , which will swap the position of the two values at indexes a and b in the list. Example: before and after a call to swap(list, 1, 2) on the list shown below The function header is defined for you. Choose the 3 lines of code that will perform the swap correctly. function swap(list, a, b){ <choose option from below>

var temp = list[b] list[b] = list[a]; list[a] = temp;


Conjuntos de estudio relacionados

Real Estate Prelicensing National Exam

View Set

Chapters 22,23,&30 Competency Quiz

View Set

Real Estate 100 - Chapter 4 - Real Estate Disclosures

View Set

CRJ 100 Exam 2 Study Guide Chapters 6,7,8

View Set

NUR 304 Chapter 56 Concepts of Care for Patients with Diabetes Mellitus

View Set

Topic 10 Lesson 3 Earthquakes and Tsunamis

View Set