Final Exam Blog
Blog on experiences takng final, questions I had, and research I did
Question | My Answer | Difficulties/Research/Notes |
---|---|---|
1. Which of the following best describes the behavior of the code segment? # | D. The code segment displays the value of 2(5^3) by initializing result to 2 and then multiplying result by 5 a total of three times. | None |
2. In the following procedure, assume that the parameter x is an integer. Which of the following best describes the behavior of the procedure? # |
C. It displays true if x is negative and displays nothing otherwise. | y <- (x<0) Output y is True or False. |
3. A company that develops educational software wants to assemble a collaborative team of developers from a variety of professional and cultural backgrounds. Which of the following is NOT considered a benefit of assembling such a team? | A. Collaboration that includes diverse backgrounds and perspectives can eliminate the need for software testing. | Collaboration with diverse members, allow the team to anticipate needs of users, avoid bias, and reflect the strength of each member. Having a diverse team does not take away the need for software testing. |
4. Which of the following data are needed for DineOutHelper to recommend a restaurant for the group? Each group member’s list of food allergies or dietary restrictions Alejandra’s geographic location The usernames of the people on Brandon and Cynthia’s contact lists |
A. I and II only. | None |
5. Which of the following data is not provided by Alejandra but is necessary for DineOutHelper to recommend a restaurant for the group? Brandon’s contact list Information about which restaurants Brandon and Cynthia have visited in the past Information about which food allergies and dietary restrictions can be accommodated at different restaurants near Alejandra |
B. III only Other information is unnecessary |
|
6. Which of the following is the most appropriate documentation to appear with the printNums procedure? # |
B. Prints all positive odd integers that are less than or equal to max. | Note: when pseudo code gets confusing strategy is to assign numbers to variable, or map it out |
7. Which of the following is the most appropriate documentation to appear with the calculate procedure? # |
C. Displays the value of (x + y) / x. The value of the parameter x must not be 0. |
C not D because of the restriction on parameter x ** read carefully Documentation: Code documentation is text that accompanies software code to explain what your code is doing, why it’s written the way it is, and/or how to use it. source |
8. Which of the following is the most appropriate documentation to appear with the swapListElements procedure? # | B. Returns a copy of numList with the elements at indices j and k interchanged. The values of j and k must both be between 1 and LENGTH(numList), inclusive. |
Indices: indicates the position of the element within the array (starting from 1) source A copy of numList, newList is returned with the position in the list (parameters) j and k Values of J and K represent indices, or positions in the list. The positions must be between 0 and the len(numList) inclusive |
9. Which of the following changes can be made so that the code segment works as intended? # |
D. Interchange lines 3 and 7 | Again, assign numbers and remember what happens to each variable when it is overcomplicated |
10. Three students in different locations are collaborating on the development of an application. Which of the following strategies is LEAST likely to facilitate collaboration among the students? |
C. Having all three students write code independently and then having one student combine the code into a program | This is ineffective because without frequent discussion the code may not be coherent |
11. The code segment compares pairs of list elements, setting containsDuplicates to true if any two elements are found to be equal in value. Which of the following best describes the behavior of how pairs of elements are compared? # |
B. The code segment iterates through myList, comparing each element to all subsequent elements in the list. | The code segment iterates through myLIst and compares each element to the elements following it. The first loop, repeats the segment until every element is tested ( j > len(myList) - 1) The second loop repeats as long as ‘k’ which is the subsequent remaining elements of the list is greater than the length of the list. |
12. A student is creating an application that allows customers to order food for delivery from a local restaurant. Which of the following is LEAST likely to be an input provided by a customer using the application? | B. The cost of a food item currently available for order | This should be an output not user input |
13. The following procedure is intended to return true if the list of numbers myList contains only positive numbers and is intended to return false otherwise. The procedure does not work as intended. # |
C. [-1, 0, 1] | The function iterates through the list, only returning true if the number is positive. But if the first elements in the list are not positive, they are skipped over. Therefore in C, -1 and 0 are skipped over but when +1 is checked to be >0, the return is True even though the first two elements are not positive. |
14. For which of the following values of numCorrect does the code segment NOT display the intended grade? # |
B. 8 and D. 6 |
Input 6 will display ‘check’ Input 8 will display ‘check minus’ |
15. A company that develops mobile applications wants to involve users in the software development process. Which of the following best explains the benefit in having users participate? | D. Users can provide feedback that can be used to incorporate a variety of perspectives into the software. | User feedback incorporates a variety of perspectives |
16. Which of the following best explains how messages are typically transmitted over the Internet? | B. The message is broken into packets. The packets can be received in any order and still be reassembled by the recipient’s device. | Before messages get sent, they’re broken up into tinier parts called packets source |
17. Which of the following is a primary reason for the use of open protocols on the Internet? | D. Open protocols provide a way to standardize data transmission between different devices. | Open protocol: not owned by any particular company and not limited to a particular company’s products Open protocol allows data to be standardized |
18. Which of the following best describes the relationship between the World Wide Web and the Internet? | C. The World Wide Web is a system of linked pages, programs, and files that is accessed via a network called the Internet. | None |
19. A certain programming language uses 4-bit binary sequences to represent nonnegative integers. For example, the binary sequence 0101 represents the corresponding decimal value 5. Using this programming language, a programmer attempts to add the decimal values 14 and 15 and assign the sum to the variable total. Which of the following best describes the result of this operation? | C. An overflow error will occur because 4 bits is not large enough to represent 29, the sum of 14 and 15. | Binary is 4-bit meaning the max number represented is 4! = 24. 14+15 = 29 > 24 so 29 cannot be represented |
20. A video game character can face toward one of four directions: north, south, east, and west. Each direction is stored in memory as a sequence of four bits. A new version of the game is created in which the character can face toward one of eight directions, adding northwest, northeast, southwest, and southeast to the original four possibilities. Which of the following statements is true about how the eight directions must be stored in memory? | D. Four bits are enough to store the eight directions. | None |
21. Which of the following are true statements about the data that can be represented using binary sequences? Binary sequences can be used to represent strings of characters. Binary sequences can be used to represent colors. Binary sequences can be used to represent audio recordings. |
D. I, II, and III | Binary can represent many different types of data including strings. source |
22. Consider the 4-bit binary numbers 0011, 0110, and 1111. Which of the following decimal values is NOT equal to one of these binary numbers? | C. 9 0011: (2^0 ) 1 = 1 (2^1 ) 1 = 2 (2^2 ) 0 = 0 (2^3 ) 0 = 0 2+1 = 3 0110: (2^0 ) 0 = 0 (2^1 ) 1 = 2 (2^2 ) 1 = 4 (2^3 ) 0 = 0 2+4 = 6 1111: (2^0 ) 1 = 1 (2^1 ) 1 = 2 (2^2 ) 1 = 4 (2^3 ) 1 = 8 1+2+4+8 = 15 Can not equal 9. |
Convert Binary to Decimal # source |
23. The position of a runner in a race is a type of analog data. The runner’s position is tracked using sensors. Which of the following best describes how the position of the runner is represented digitally? | D. The position of the runner is sampled at regular intervals to approximate the real-word position, and a sequence of bits is used to represent each sample. Best guess |
Analog Data: Data represented in a physical way, grooves on a vinyl |
24. Which of the following lists the values in order from least to greatest? Binary 1011 Binary 1101 Decimal 5 Decimal 12 |
A. Decimal 5, binary 1011, decimal 12, binary 1101 1011: (2^0 ) 1 = 1 (2^1 ) 1 = 2 (2^2 ) 0 = 0 (2^3 ) 1 = 8 1+2+8 = 11 1101: (2^0 ) 1 = 1 (2^1 ) 0 = 0 (2^2 ) 1 = 4 (2^3 ) 1 = 8 1+4+8 = 13 5, 1011, 12, 1101 |
See question 22 |
25. The variable age is to be used to represent a person’s age, in years. Which of the following is the most appropriate data type for age ? | B. Number | None |
26. The variable isOpen is to be used to indicate whether or not a store is currently open. Which of the following is the most appropriate data type for isOpen ? | A. Boolean | None |
27. A teacher is writing a code segment that will use variables to represent a student’s name and whether or not the student is currently absent. Which of the following variables are most appropriate for the code segment? | C. A string variable named studentName and a Boolean variable named isAbsent | None |
28. Which of the following code segments correctly sets the value of the variable cost to the cost, in dollars, of using numUnits units of electricity? | C. # | None |
29. 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. | Data Abstraction: shows only required information about the data and hides the unnecessary data, like how we manipulated the Api |
30. A programmer has a need to round many numeric values to the nearest integer. Which of the following best explains the benefit of using a list as a data abstraction in this situation? | B. Keeping the numeric values in a list makes it easier to apply the same computation to every data element. | Apply same rounding computation to each element in list. |
31. The list wordList has the following contents. [“abc”, “def”, “ghi”, “jkl”] Let myWord be the element at index 3 of wordList. Let myChar be the character at index 2 of myWord. What is the value of myChar ? |
C. ‘h’ | None |
32. What are the contents of yourList after the code segment is executed? # |
A. [10, 30, 50, 70] | None |
33. What is displayed as a result of executing the code segment? # |
C. 100 300 500 | None |
34. What are the contents of secondList after the code segment is executed? # |
B. [“guitar”, “drums”, “bass”] | None |
35. In a certain video game, the variable maxPS represents the maximum possible score a player can earn. The maximum possible score depends on the time it takes the player to complete the game. The value of maxPS should be 30 if time is greater than 120 and 50 otherwise. Which of the following code segments correctly sets the value of maxPS based on the value of time ? ** incorrect sould be A and D |
A. # C. # |
None |
36. Intended to store ten consecutive even integers, beginning with 2, in the list evenList. Which of the following can be used to replace # |
C. APPEND(evenList, 2 * i) i ← i + 1 |
None |
37. Which of the following code segments can be used to interchange the values of the variables num1 and num2 ? | D.# | None |
38. Which of the following code segments can be used to update the values of the variables as shown in the table? | B. temp ← word1 word1 ← word3 word3 ← temp |
None |
39.The list wordList contains a list of 10 string values. Which of the following is a valid index for the list? | B. “hello” ** incorrect because it usulally consists of non negative numbers | None |
40. If the value of x is 3 and the value of y is 5, what is displayed as a result of executing the code segment? # |
A. -2 | None |
41. What is the value of r as a result of executing the code segment? # | B. 20 |
None |
42. What is the value of sum after the code segment is executed? # | C. 16 | None |
43. What is the value of result after the code segment is executed? # |
C. 15 | None |
44. Which of the following initial values of the variable y would result in the variable z being set to 2 after the code segment is executed? # |
C. 3 | MOD: The modulo operation (abbreviated “mod”, or “%” in many programming languages) is the remainder when dividing |
45. What are the values of count1 and count2 as a result of executing the code segment? # |
B. count1 = 2, count2 = 3 | None |
46. What are the values of first and second as a result of executing the code segment? # |
The value of first is true, and the value of second is true. | None |
47. What is displayed as a result of executing the code segment? # |
D. 21 40 30 50 | None |
48. Which of the variables have the value 50 after executing the code segment? # |
C. x and z only | None |
49. Which of the following code segments can be used to store “noon” in the string variable word ? # |
word ← “on” word ← concat(reverse(word), word) |
concat(str1, str2) For example, concat(“key”, “board”) returns “keyboard”. reverse(str) For example, reverse(“abcd”) returns “dcba”. |
50.The variable initials is to be assigned a string consisting of the first letter of the string firstName followed by the first letter of the string lastName. Which of the following assigns the correct string to initials ? | initials ← concat(prefix(firstName, 1), prefix(lastName, 1)) | prefix(str, length) For example, prefix(“delivery”, 3) returns “del” and prefix(“delivery”, 100) returns “delivery”. |