APCSP Unit 4 Review

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which of the following is a simplified but equivalent Boolean expression to the following: (X > 0 AND X ≤ 20) OR (X > -5 AND X < 15)

(X > -5) AND (X ≤ 20) - Correct, this is equivalent it describes the same range of X from -5 to 20

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. 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) OR (onFloor2 AND callTo1) - Correct, this will evaluate to True only when the elevator is on floor 1 and called to floor 2 OR on floor 2 and called to floor 1

A newspaper editor has noticed that one of his writers wrote an article where he misspelled the word "accommodation", and wrote it as "accomodation" many times. Assuming that the editor doesn't know the number of times the word is used, or the number of words in an article, which of the following sets of instructions would provide an effective way of automating the process of fixing the mistake?

1) Repeat until end of article is reached: 2) Grab the next word 3) If the word is "accomodation" then replace it with "accommodation" 4) End Repeat - This is correct. This algorithm iterates through every word in the article, but only selects the option to replace the word if it is the incorrectly spelled "accomodation", which it replaces with "accommodation".

Which of the following are true about programming documentation?Select two answers:

1. It is useful to other programmers that view your code, so that they can understand what different parts of the code are intended to do. - This is correct. One of the most important functions of documentation is to explain the purpose and function of variables and procedures in the code. This allows other programmers to determine how to use or adapt the program without needing to carefully read through many lines of code. 2. It allows the programmer an opportunity to attribute help, work and code from others. - This is correct. Documentation provides a place where programmers can provide any attributions needed for others input and influence on the code.

In the program below, x is an integer between 5 and 10 inclusive. What is the maximum possible value of answer after running the program?

20 -This is correct. Since the only operation changing the value of answer in the embedded loops is addition of a positive number, the maximum value will be achieved when the loops repeat the most times. As the outer loop repeats x times, and x is between 5 and 10 inclusive, this means that the maximum is achieved when it repeats 10 times. The inner loop adds 1 to answer 4 times, effectively increasing answer by 4. The outer block runs ten times, increasing answer by 4 a total of 10 times. Since answer begins as 0, once the outer REPEAT loop exits it has increased to 4*10 = 40. The final statement divides this by 2, giving a final result of answer = 40.

Procedural abstraction allows the programmer to change the internals of the procedure without needing to notify users of the change as long as it does the same thing as before. Why would a programmer want to make changes to a procedure if it already works as intended?

All of the options are true - Correct, these are all valid reasons to edit the internal code of a procedure.

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

All of these - This is correct. A string of bits can be interpreted simply as a binary integer, using each bit to represent a different power of 2. Alternatively it could be a 24 bit RGB color value: each byte (group of 8 bits) would refer to one of the three color components R, G, B and represents a value between 0 (000000002) and 255 (111111112). Finally each byte could also refer to an ASCII character, since when extended each character is represented by 8 bits (the original ASCII specification uses 7 bits, however a 0 can be added to the start of the number to make each original character also use 8 bits).

Images used in web page development are often raster images. What is the primary disadvantage of using raster images?

Enlarging a raster image degrades the image - This is correct. As raster images are made up of a fixed number of pixels, when the image is enlarged these pixels will become bigger, making the image appear blocky or jagged

Dylan and Frank have designed a compression algorithm used for directions to unknown locations. In their algorithm the direction to travel at each intersection encountered is replaced with a single letter: "E" for East, "W" for West, "N" for North and "S" for South. In addition, the string "EEE" is replaced with "A" and "SSS" is replaced with "D". Which of the following best describes the directions which are expressed as "NASSA" when compressed using Dylan and Frank's algorithm?

Go North at the first intersection, then go East at the next three intersections, then go South at the next two intersections, then go East at the next three intersections. - This is correct. The symbol "A" replaces "EEE", therefore the string "NASSA" is equivalent to "NEEESSEEE". As each letter represents the first letter of the direction traveled at each intersection, this means traveling North at the first intersection, East at the next three, South at the next two and East at the next three.

An audio engineer recorded a sound and digitized the recording. He noticed that the sound quality deteriorated significantly after the recording was digitized. Which of the following changes should he make in the digitizing process if he wants to ensure that the quality of recordings are better preserved when converting to a digital format in the future?

Increase the sampling rate - This is correct. Increasing the sample rate means that more samples will be taken of the sound wave when it it is digitized.Therefore a more accurate recreation of the sound wave can be created.

Which of the following best describes the results of running the program shown above?

Nothing will be displayed. The program will run indefinitely. -This is correct. Each time the repeated instructions are run, the value of i is set to 1 and later increased by 2. This means it will never reach the value 8, so the loop never exits. This means the program runs indefinitely, increasing the value of sum without ever reaching the display block.

Which of the following is not a concern when you are thinking about whether or not to compress your files?

Security of the files - This is correct. The security of a file is not affected by whether it is compressed or not. Decompression algorithms are often readily available for anyone to use, and are not the same as encryption algorithms (which you will learn more about in unit 6).

A photographer has shot a photo session using RAW format. The client wishes to preview the photo shoot and requests that a series of photos be sent via email. The files are too large for most email servers and must be compressed in order to be emailed. Which of the following is correct about a compression of the files if the client wants to see the photos in the best possible quality?

The files should be compressed using a lossless compression - This is correct. No data is lost when using lossless compression, meaning that a completely accurate reproduction of the image will be displayed by a computer accessing the file, with no quality being lost.

A student is creating a filter that can be applied to an image. Once the filter is applied, the new image completely replaces the original image and any information about the original image is lost. Which of the following filters described below would demonstrate a lossy transformation of the digital image?

The image is converted to grayscale by averaging the RGB values for individual pixels and then applying the averaged numbers as the new RGB colors for the pixels. - Correct, there is no way to determine the original individual RGB values from the average value saved in grayscale.

Which of the following statements about a work published under a Creative Commons license is true?

The work can be freely shared although there may be conditions regarding what it can be used for. - This is correct. Creative Commons licenses are designed specifically to allow work to be shared for free, however there are always conditions attached. This always includes attributing the creator in any use but may also stipulate other conditions such as not permitting commercial use.

Consider the following procedures. ----------------------- PROCEDURE name (a, b, c) { full ← a + " " + b + " " + c RETURN(full) } ------------------------ What is displayed as a result of executing the following program if fn = Tim, mn = Berners and ln = Lee? fn ← INPUT() mn ← INPUT() ln ← INPUT() result←name(fn,mn,ln) DISPLAY(result)

Tim Berners Lee - Correct, this is value result returned from the name procedure.

The procedure Max(list) is used to find the maximum number in list and display that number. Below is the procedure described above. _________________________________ PROCEDURE Max(list) { maximum ← 0 FOR EACH number IN list { IF (number > maximum) { maximum ← number } } DISPLAY (maximum) } _______________________________

list ← [-5, -3, -10, -8, -1] - Correct, this will display 0, because none of these numbers are greater than 0. This shows the error that occurs when we use >0 to check for a maximum value on a list of all negative numbers.


संबंधित स्टडी सेट्स

Chronicle of a Death Foretold Vocab

View Set

CS 4347.501 (Database Systems) - Chapter 4: The Enhanced Entity-Relationship (EER) Model

View Set

Precision Nutrition GI Hormones and Neurotransmitters

View Set

Total abdominal hysterectomy with Bilateral Salpingo-oophorectomy (TAH)

View Set

الحركة الارضية والانجراف القاري

View Set

Gran Maestros de La Pintura Española: El Greco

View Set