CS GACE Qs

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Which of the following are examples of a digital divide?

A.An older couple cannot post messages on a social network site without help from their grandchildren. B.A student is unable to view a video homework assignment because the student does not have access to a high-speed Internet connection.

Lossless Compression

Allows perfect reconstruction of the original data from the compressed data

If a move results in the robot moving off the grid, that move will not be made and no points are awarded for that move. The robot skips that move and resumes from the next move. Of the following, which code segment correctly moves the robot from P to Q and earns the most points? A. forward ()forward ()forward_left ()forward ()forward () B. forward ()forward_left ()forward_right ()forward_left ()forward () C. forward_left ()forward_left ()forward_right ()forward_right ()forward ()forward ()forward () D. forward_left ()forward_right ()forward ()forward ()forward_left ()forward_left ()forward_right ()

Consider labeling the squares in the grid as shown in the grid below. HIJQ DEFG PABC Option (B) is correct. Using the labels in the grid above, the robot begins in square P facing right. From there it will move to square A facing right, then to square B facing up, then to square F facing right, then to square G facing up, then to square Q facing up. The sequence of moves meets all the conditions and earns a total of 1+3+2+3+1=101+3+2+3+1=10 points. Option (A) is incorrect. The robot begins in square P facing right. From there it will move to square A facing right, then to square B facing right, then to square C facing up, then to square G facing up, then to square Q facing up. The sequence of moves meets all the conditions but only earns a total of 1+1+3+1+1=71+1+3+1+1=7 points. Option (C) is incorrect. The robot begins in square P facing right. From there it will move to square A facing up, then to square E facing left, then to square D facing up, then to square H facing right, then to square I facing right, then to square J facing right, then to square Q facing right. Although this option earns 13 points, which is more than option (B), this option does not meet all the conditions. The robot should end in square Q facing up, not right. Option (D) is incorrect. The robot begins in square P facing right. From there it will move to square A facing up, then to square E facing right, then to square F facing right, then to square G facing right. The next 3 statements will put the robot off the grid so the robot will not make any more moves. The sequence of moves does not meet all the conditions. The robot never gets to square Q.

For the encoding scheme shown in the table, what decimal number is the result of adding the decimal numbers 5 and 6 ? 5 = 0101 6 = 0110

Correct Answer: -5 The correct answer is −5−5. According to the table, the binary representations of the numbers 5 and 6 are 0101 and 0110, respectively. Addition of binary numbers is like the addition of decimal numbers except that 1+1=01+1=0 with a carry of one. So adding the binary digits in each column and carrying one when appropriate, the sum is binary 1011. Binary 1011 corresponds to −5−5.

A computer simulation of operations at a car wash with several wash stations is run several times. In each run of the simulation, only the number of available wash stations is changed. Which of the following changes is most likely to occur between runs of the simulation? A.A change in the average wait time per customer to enter a wash station B.A change in the amount charged per car wash C.A change in the amount of water used per car wash D.A change in the average length of time needed to wash a car once the car enters the wash station

Correct Answer: A Option (A) is correct. Changing the number of available wash stations would directly impact the amount of wait time per customer. Option (B) is incorrect. Changing the number of available wash stations would not impact the amount charged per car wash. Option (C) is incorrect. Changing the number of available wash stations would impact the total amount of water used since the total number of cars that could be washed would vary depending on the number of wash stations. However, the amount of water used per car wash would remain the same. Option (D) is incorrect. Changing the number of available wash stations would not impact the amount of time needed to wash a car once the car enters the wash station. The number of wash stations would impact how long a customer would wait to enter a wash station, but once a car is in the wash station, the amount of time needed to wash the car would remain the same.

Consider the following pseudocode procedure, where the length of each of the two integer arrays A and B is n and the first index of each of the two arrays is 0. void mystery ( int[] A, int[] B, int n ) int i ← ← 0 for ( int k ← ← 0; k < n; k ← ← k + 1 ) if ( A[i] > B[k] ) A[i] ← ← B[k] else i ← ← i + 1 end if end for end mystery Consider the following pseudocode segment. int[] c ← ← {7, 6, 8, 10} int[] d ← ← {8, 6, 7, 5} mystery ( c, d, 4 ) What is the value of c after the code segment above is run? A.{7, 6, 5, 10} B.{7, 6, 7, 5} C.{7, 6, 7, 10} D.The code causes an array index out-of-bounds error.

Correct Answer: A Option (A) is correct. In the procedure, i and k are index variables for arrays A and B,respectively. In theforloop, the value of k increases from 0 to n - 1,while the value of i starts at 0 but increments only when A[i] ≤ B[k].Note that the values in array A may change, but the values in array B stay the same. In the call mystery ( c, d, 4 ), c and d correspond to A and B,respectively, so accesses and changes to A and B are made in the arrays referenced by c and d.At the beginning of the first iteration of theforloop, k is 0, i is 0,and c is {7, 6, 8, 10}.In the firstforiteration, since c[0] = 7 is not greater than d[0] = 8,the value of i is incremented to 1.At the beginning of the second iteration, k is 1, i is 1,and c is {7, 6, 8, 10}.In the second iteration, since c[1] = 6 is not greater than d[1] = 6,the value of i is incremented to 2.At the beginning of the third iteration, k is 2, i is 2,and c is {7, 6, 8, 10}.In the third iteration, since c[2] = 8 is greater than d[2] = 7,the value of c[2] is set to 7,but the value of i is not incremented. At the beginning of the fourth iteration, k is 3, i is 2,and c is {7, 6, 7, 10}.In the fourth iteration, since c[2] = 7 is greater than d[3] = 5,the value of c[2] is set to 5.At the end of theforloop, c is {7, 6, 5, 10}.

Which of the following is the decimal representation of the sum of binary numbers 1011 and 1011 ? A.22 B.31 C.44 D.2022

Correct Answer: A Option (A) is correct. The binary number 1011 is equal to the decimal number 11, and the sum of the decimal numbers 11 and 11 is the decimal number 22. Alternately, using the binary addition rules, the sum of the binary numbers 1011 and 1011 is the binary number 10110, which is equal to the decimal number 22. Options (B) and (C) are incorrect and could result from errors in performing binary addition. Option (D) is incorrect and could result from adding the binary values as if they were decimal numbers.

Consider the following pseudocode procedure header. int average ( int a, int b, int c ) Which of the following is a valid call to the procedure average ? A.average ( 3, 4 ) B.average ( "2", 3, 4 ) C.average ( 2.5, 5, 6 ) D.average ( average ( 1, 2, 3 ), 4, 5 )

Correct Answer: D Option (D) is correct. The call is valid because the three arguments in the outer average procedure are average ( 1, 2, 3 ), 4, and 5, all of which are integer values.

Consider the following pseudocode procedure, which is intended to return the index of the least element in an array of integers data[0..n-1] of length n. If the least element in the array data occurs at multiple positions, the lowest index is returned. // precondition: n > 0 public int positionOfMinimum ( int[] data, int n ) int startingPosition ← ← 0 int bestGuessSoFar ← ← startingPosition for ( int i ← ← startingPosition + 1; i < n; i ← ← i + 1 ) if ( data[i] < data[bestGuessSoFar] ) bestGuessSoFar ← ← i end if end for return bestGuessSoFar end positionOfMinimum Sometimes, it is necessary to search only part of an array. Of the following, which describes the most general solution for updating positionOfMinimum so that only the part of the array that begins at a specified index is searched? A.Make startingPosition a parameter of the method and remove the line that declares startingPosition and initializes it to 0. B.Change the for loop to a while loop that only executes while the code is searching the correct part of the array. C.Add a second if statement to the method that checks that the index found is in the correct part of the array. D.Change the initial value of startingPosition to the value of the index in the array where the search should begin.

Correct Answer: A Option (A) is correct. The procedure positionOfMinimum searches through array data beginning at the first element and continuing until the last element. The procedure initializes a local variable named startingPosition to 0 (the index of the first element). If startingPosition is instead initialized with the parameter, it could be given different values in different calls. Abstraction is a way of generalizing. A procedure that always searches from a fixed position (in this case, zero) is less general than a procedure that can begin a search at any specified position. Note that option (D) would also address starting the search from a position other than the first, however, this is not the most general solution for updating the procedure. If a new starting position is needed, this code would need to be changed and recompiled. If the starting position is passed to the procedure as a parameter, then the procedure can be called with different starting positions, but the procedure itself would not have to change.

A sensor on a refrigerator monitors the temperature and humidity in a room. Consider the following event handler pseudocode segment intended to display "comfortable" if the room climate is comfortable and "uncomfortable" otherwise. The room climate is defined to be comfortable if the temperature is between 62 and 75 degrees Fahrenheit, inclusive, and the humidity is between 30 percent and 50 percent, inclusive. // getTemperature () returns the temperature reading,// in degrees Fahrenheitint temperature ←← getTemperature ()// getHumidityPercent () returns the humidity percent// reading, as an integer between 0 and 100, inclusiveint humidity ←← getHumidityPercent () if ( /* missing expression */ ) print "comfortable"else print "uncomfortable"end if Which of the following could replace /* missing expression */ so that the code segment will work as intended? A. ( temperature ≥≥ 62 and temperature ≤≤ 75 ) and( humidity ≥≥ 30 and humidity ≤≤ 50 ) B. ( temperature ≥≥ 62 or temperature ≤≤ 75 ) and( humidity ≥≥ 30 or humidity ≤≤ 50 ) C. ( temperature ≥≥ 62 and temperature ≤≤ 75 ) or( humidity ≥≥ 30 and humidity ≤≤ 50 ) D. ( temperature ≥≥ 62 or temperature ≤≤ 75 ) or( humidity ≥≥ 30 or humidity ≤≤ 50 )

Correct Answer: A Option (A) is correct. The temperature and humidity must be within both of their bounds, so the and operator must be used throughout.

Consider the following two equivalent algorithms, which calculate and return the same value. Algorithm 1 int f ( int n )int a ←← 1int b ←← 1while ( n ≥≥ 3 )int temp ←← a + b a ←← b b ←← temp n ←← n - 1end whilereturn bend f Algorithm 2 int g ( int n )if ( n ≤≤ 2 )return 1elsereturn g ( n - 1 ) + g ( n - 2 )end ifend g Which of the following best describes the running times of algorithm 1 and algorithm 2 in terms of n ?

Correct Answer: B Option (B) is correct. Both algorithms return the nth term in the Fibonacci sequence beginning with 1, 1, 2, 3, .... Algorithm 1 uses an iterative approach. When n ≥≥ 3, the while loop executes n - 2 times, so the overall running time for algorithm 1 is linear in n. Algorithm 2 uses a recursive approach. The second algorithm generates two recursive calls for every integer from n to 3. Finding the nth term by algorithm 2 will require almost 2n2n recursive calls, so algorithm 2 is exponential.

Which of the following software license agreements allows users to use, modify, and sell or give away source code without the payment of royalties to the original developer? A.Creative Commons Attribution-NoDerivs license B.End-user license C.Open-source license D.Proprietary license

Correct Answer: C Option (C) is correct. Open-source licenses allow software to be freely used, modified, and shared, including being sold or used for commercial purposes.

A programmer is writing a program to display the even numbers 2 through 10. The program will contain the following statements. Statement Number/ Pseudocode 1 / print ( n ) 2/ while ( n ≤≤ 10 ) 3/ n ←← n + 2 4/ end while 5/ int n ←← 2 Which of the following shows the five numbered statements in correct order so that the program works as intended? A.2, 5, 1, 3, 4 B.2, 5, 3, 4, 1 C.5, 2, 1, 3, 4 D.5, 2, 3, 1, 4

Correct Answer: C Option (C) is correct. Statement 5 should be placed first because it declares variable n. Statement 2 should be placed next because it starts the while construct. Statement 4 should be placed last because it closes the while construct. The body of the while loop should consist of statement 1 followed by statement 3.

A programmer has written a procedure wa ( x, y, w ) to calculate the weighted average of two values x and y. In the procedure, the given weight w is applied to the greater of x and y, and the remaining weight 1 - w is applied to the smaller of x and y. An application calls the procedure on a pair of values a and b and then on a different pair of values c and d. Both calls use the same weight w. The final step in the application's algorithm is to call wa on the results of the previous two procedure calls, again using the same weight w. Which of the following correctly uses wa to calculate the desired result? A.wa ( wa ( a, b ), wa ( c, d ), w ) B.wa ( wa ( a, b, w ), wa ( c, d, w ) ) C.wa ( wa ( a, b, w ), wa ( c, d, w ), w ) D.wa ( wa ( a, b, w ) + wa ( c, d, w ) )

Correct Answer: C Option (C) is correct. The first argument in the outer wa procedure is wa ( a, b, w ), which is the weighted average procedure applied to the pair of values a and b. The second argument in the outer wa procedure is wa ( c, d, w ), which is the weighted average procedure applied to the pair of values c and d. The third argument in the outer wa procedure is w, which is also the weight used in the first and second arguments.

Consider the following pseudocode procedure, which is intended to return true if a positive integer greater than 1 is prime and to return false otherwise. A prime number has only two positive factors: 1 and itself. boolean isPrime ( int n ) if ( n < 2 ) return false end if int k ←← 2 /* missing code */end isPrime Which of the following can replace /* missing code */ so that isPrime works as intended?

Correct Answer: C Option (C) is correct. The positive number n is prime if it does not have any factors from 2 to n - 1, inclusive. In the code segment in option (C), the value of k increases from 2 to n - 1. The if statement checks whether k is a factor of n by comparing the remainder when n is divided by k with 0. If k is a factor of n, then n is not prime and the procedure returns false. If k is not a factor of n, then the value of k is incremented by 1 and the while loop moves to the next iteration. Option (A) is incorrect because the procedure returns in the first iteration of the while loop. In other words, option (A) only checks whether 2 is a factor of n, and it returns a result before testing all the other possible factors. Option (B) is incorrect because it returns true too soon—it returns as soon as it finds the first value of k that is not a factor of n. In fact, option (B) returns false when n is 2 and returns true for all integers n greater than 2. Option (D) is incorrect because the value of k is not incremented and the while loop does not terminate.

A software developer is designing a simulation of city street traffic over a 24-hour period. As part of the design, the simulation will use a variable that represents the amount of time, in hours, that elapses between the entry of successive cars onto the street. During a run of the simulation, which of the following best describes what values should be assigned to the variable in order to create the most realistic simulation? A.Values that decrease linearly during the simulation B.Values that increase exponentially during the simulation C.Values that oscillate during the simulation above and below a specified mean D.Values randomly generated during the simulation that are integers between 1 and 23, inclusive

Correct Answer: C Option (C) is correct. The street traffic activity will vary throughout a 24-hour period, with high levels of activity during the day and very low levels of activity during the night. A high level of street traffic activity will correspond to a small value for the variable, while a very low level of street traffic activity will correspond to a large value for the variable. Throughout the day and night, street traffic activity will oscillate between low levels of activity and high levels of activity, so the values used in the simulation should also oscillate above and below a specified mean. Options (A) and (B) are incorrect because the traffic over a 24-hour period is not likely to continually decrease or increase. Option (D) is incorrect because the integer constraints on the variable are not realistic. The activity will fluctuate according to the time of day, changing from periods of increasing to decreasing traffic and vice versa.

Which of the following best describes how network load and latency change as more devices are connected to the Internet in a home network? A.Both the network load and the latency decrease. B.The network load decreases and the latency increases. C.The network load increases and the latency decreases. D.Both the network load and the latency increase.

Correct Answer: D Option (D) is correct. As more devices are connected to the Internet in a home network, the network load, which is the total amount of data transmitted and received by all the devices, increases. At the same time, the latency, which is the time it takes for data to make a round trip from the home to the intended destination and back again, increases, since the devices have to wait while other devices are serviced.

Consider the pseudocode procedure below, which implements a binary search on integer array arr. The parameter length is the length of array arr and the parameter target is the value to be searched for. The index of array arr starts at 0. In line 5, the symbol / represents integer division. Line 01: int binarySearch ( int[] arr, int length, int target ) Line 02: int lo ← 0 Line 03: int hi ← length - 1 Line 04: while ( lo ≤ hi ) Line 05: int mid ← lo + ( hi - lo ) / 2 Line 06: if ( arr[mid] > target ) Line 07: hi ← mid - 1 Line 08: else Line 09: if ( arr[mid] < target ) Line 10: lo ← mid + 1 Line 11: else Line 12: return mid Line 13: end if Line 14: end if Line 15: end while Line 16: return -1 Line 17: end binarySearch Consider the following code segment. int[] arr ← {-3, -2, 1, 2, 3, 4, 5, 6, 7, 9} int length ← 10 int target ← 4 int z ← binarySearch ( arr, length, target ) When the call to binarySearch is executed, what value is returned and how many total comparisons are executed? (Comparisons are executed in lines 4, 6, and 9.)

Correct Answer: D Option (D) is correct. Before the first while loop is executed, the value of lo is set to 0 and the value of hi is set to 9. During the first while loop, the value of mid is set to 4 and the value of lo is set to 5. During the first while loop, lines 4, 6, and 9 are all executed. During the second while loop, the value of mid is set to 7 and the value of hi is set to 6. During the second while loop, lines 4 and 6 are executed but not line 9. During the third while loop, the value of mid is set to 5 and the call to binarySearch returns 5. During the third while loop, lines 4, 6, and 9 are all executed. The total number of times lines 4, 6, and 9 are executed is 8.

Writers and graphic artists are working to develop illustrations for a children's book. Which of the following aspects of the creative process has been most significantly enhanced by the availability of software? A.Determining the layout, size, and number of illustrations B.Designing sketches to illustrate the author's concepts C.Selecting sketches to recommend for each illustration D.Sharing illustrations among all the artists and writers to obtain feedback

Correct Answer: D Option (D) is correct. Even if the writers and graphic artists are nearby, the processes of sharing the illustrations and obtaining feedback have been made easier through a variety of software applications. Without software, the illustrations would have to be physically shipped to the various team members. Options (A), (B), and (C) could be done with the aid of software; however, the judgments needed for layout, sketch design, and selection are typically not done by software.

Which of the following network devices is responsible for finding and changing the paths of data packets as needed? A.Network firewall B.Network interface card C.Network repeater D.Network router

Correct Answer: D Option (D) is correct. Routers attempt to direct packets through the network by finding the appropriate path. A firewall uses decision rules to either grant or deny access to a packet, but the packet always follows the same path. The NIC, or network interface card, allows a computer to exchange data with a network but always uses the same path. Repeaters receive a signal and amplify it, allowing the signal to be transmitted over a longer distance along the path.

Lossy Compression

Generally achieves a greater compression ratio & Is more appropriate for streaming music and video

Place the four items in order from lowest level of abstraction to highest level of abstraction. Drag each item to the correct box

Lowest Field Record Table Database Highest

Consider the following incomplete pseudocode procedure, twoInARow, which is intended to simulate rolling a fair 6-sided die multiple times. The procedure has one parameter, numRolls, which is the number of times the die is rolled. The procedure returns the number of pairs of consecutive identical rolls of the die. For example, assume a call to twoInARow ( 8 ) creates the sequence of eight rolls 3, 2, 2, 2, 3, 4, 4, 6. The number of pairs of consecutive identical values in the sequence is 3. The first pair of consecutive identical values is 2 and 2 in the second and third positions in the sequence. The second pair of consecutive identical values is 2 and 2 in the third and fourth positions in the sequence. The third pair of consecutive identical values is 4 and 4 in the sixth and seventh positions in the sequence. Therefore, the call twoInARow ( 8 ) with the given sequence of rolls will return 3. // precondition: numRolls > 0int twoInARow ( int numRolls ) int numTwoInARow ←← 0 int temp ←← 0 for ( int i ←← 0; i < numRolls; i ←← i + 1 ) /* missing code block */ end for return numTwoInARowend twoInARow The rolls are simulated using a procedure call RANDOM ( 1, 6 ), which returns a random integer value between 1 and 6, inclusive. Which of the following code segments can replace /* missing code block */ so that procedure twoInARow will work as intended? Select all that apply.

int roll ←← RANDOM ( 1, 6 )if ( roll == temp ) numTwoInARow ←← numTwoInARow + 1end iftemp ←← roll Correct Answer: B Option (B) is correct. For each roll of the die, two steps are required. First, the count of matching rolls should be increased only when a matching value is rolled. Next, the value of the current roll needs to be stored so that it can be compared with the next roll. Option (B) implements this algorithm. The variable numTwoInARow is used to store the count of the matching rolls, and the variable temp is used to store the value of the current roll. Options (A) and (C) are incorrect because the Boolean condition in each of the two if statements is always false and the variable temp is never updated.


Set pelajaran terkait

Testing & Evaluation - Chapter 9

View Set

Chapter 29 APUSH- Learning Curve

View Set

Anatomy and Physiology Lab ch 10-12

View Set

Psych of adjustment final part 3

View Set

Nursing Health Assessment Exam #2

View Set

Using Reference Sources, Unit 2, Lesson 1

View Set

Consumer Behavior Exam 3: Chapters 11-17

View Set

Japan Facts, Basic vocab, Pronunciation tips, Sentence structure, Basic Katagana

View Set