Computer Science - 1 WYSE Academic Challenge 2002 Computer Science Test (Sectional) SOLUTION 1. Access to moving head disks requires three periods of delay before information is brought into memory. The response that correctly list the three time delays in the order in which they occur is a. latency time, seek time, transmission time b. transmission time, latency time, seek time c. seek time, latency time, transmission time d. latency time, transmission time, seek time e. none of the above Disk access involve 3 time periods occurring in the following order: 1. Move the read/write head to the proper track (seek) 2. Wait for the disk to rotate so that the read/write head will be at the correct location on a track (i.e., at the beginning of the data block) (rotational delay or latency) 3. Actual transmission of data Answer C 2. Two computers that communicate with each other use a simple odd parity check to detect errors for ASCII transmission. Which of the following event will always lead to an undetected error in a byte? a. Any even number of bits are inverted b. Any odd number of bits are inverted c. All the 1s are changed to 0s d. All the 0s are changed to 1s When an even number of bits in a byte are inverted, the parity of the byte does not change. As a result, these Type of errors cannot be detected with a simple odd parity check. Answer A. 3. The ASCII code for the character E is 01000101. What is the ASCII code for the character F? a. 01000101 b. 01000110 c. 01100101 d. 01010101 The ASCII code for F is 1 greater than the ASCII code for E. 010000101+00000001= 010000110 Answer B
Computer Science - 2 4. What application is best handled in ROM? a. storage for temporary variables b. storage for protected passwords c. storage for application programs d. storage for the operating system s boot sector Read-Only Memory (ROM) are small, permanent storage device that stores, among other thing, the booting instructions. Answer D. 5. If an instruction requires 3 cycles and takes 15 nanoseconds to execute, what is the clock speed of the processor? a. 500 MHz b. 200 MHz c. 400 MHz d. 450 MHz Since 3 cycles requires 15 nanoseconds, each cycle requires 5 nanoseconds. Clock speed is 1000/5 = 200 MHz. Answer B 6. The largest integer that can be stored as a 32-bit unsigned binary number is closest to a. 2 millions b. 4 billions c. 6 millions d. 1 billion An unsigned 32-bit integer uses all 32 bits to store the value. The largest is 111..1 = 2 32-1 = 4*2 30-1 Since 2 30 is about 1 billion. The largest number is around 4 billions. Answer B. 7. The total number of positive even integers that can be stored by 8-bit unsigned word is a. 127 b. 128 c. 255 d. 256 An 8-bit unsigned integer has a value between 0 (000 0) and 2 8-1 = 255 (11111111). Among them, there are 127 even numbers. Answer A
Computer Science - 3 8. The decimal integer 61 stored in 8-bit, 2 s-complement form is a. 00111101 b. 11000010 c. 11000011 d. 10111101 +61 = 00111101 1 s compliment 61 = 11000010 (1 0. 0 1) 2 s complement - 62 = 11000011 (1 s compliment+1) Answer C. 9. The difference of the two hexadecimal numbers 91 and 12 is the binary number a. 79 b. 01111001 c. 01111111 d. 10100011 In hexadecimal, 91-12 = 7F (F+1 = 10 ) 7F in binary is 01111111, Answer C 10. Which of the following is equivalent to the Boolean expression (A AND B) OR (A AND (NOT B))? a. A b. B c. A OR B d. NOT B A B A AND B A AND (NOT B) (A AND B) OR (A AND (NOT B)) 0 0 0 0 0 0 1 0 0 0 1 0 0 1 1 1 1 1 0 1 The truth table shows that A and (A AND B) OR (A AND (NOT B)) have the same values for all combination of A and B.
Computer Science - 4 11. The 2 s complement number system is considered better than 1 s complement system because a. Two is better than 1. b. There are more positive numbers in 2 s complement system than 1 s complement system c. There are more negative numbers in 2 s complement system than 1 s complement system d. A 1's complement system has a positive zero and a negative zero. 1 s compliment system has a positive zero (000000 0) and a negative zero (111.111) 2 s compliment has only one zero (000 0000). Having 1 representation for 0 is certainly better than having 2. Answer D. 12. In object-oriented design, the combination of data and operations on the data describes a. Member functions b. Methods c. Member elements d. Objects In OO design, an object is a combination of data and operations on the data (called methods). Answer D. 13. The following program segment calculates: X = 1 Y = 5 N = 3 While (N >= 1) X = X * Y N = N - 1 End While a. Y X b. Y N c. N y d. X Y The while loop repeats N time (from N to 1). IN each iteration, we another Y is multiplied to X (which begins at 1). Overall, N Ys, or Y N are multiplied to X. Answer B. 14. Examine the following code segment where all variables are Boolean. While ((NoExchange or last) and (Not flag)) loop body End While Given that the variables in the loop condition are properly initialized so that the loop body executes at least once, what set of conditions will NOT cause the loop to terminate?
Computer Science - 5 a. NoExchange = False last = true flag = true b. NoExchage = true last = false flag = false c. NoExchange = false last = false flag = false d. Two of the above Only B will set the WHILE condition to True and will NOT cause the loop to terminate. 15. How many times is the word Hello written to the screen when the following code is executed? For K From 3 To 5 For J from 1 To 4 Print( Hello ); a. 18 b. 15 c. 10 d. 12 The K loop repeats 3 time (3, 4, 5) The J loop repeats 4 times (1,2,3,4) Since J loop is inside of K loop, the total number of iteration is 3*4=12. Answer D. 16. Given the array A[1..6] = 1, 2, 3, 4, 5, 6, what would be the contents of the array A after the following code executes? For I From 3 to 6 A[I] = A[I-1]+A[I-2] a. 1,2,4,8,16,32 b. 1,2,3,4,5,6 c. 1,2,3,5,7,9 d. 1,2,3,5,8,13 Here is how the array changes after each iteration: A[1] A[2] A[3] A[4] A[5] A[6] Initial 1 2 3 4 5 6 I = 3 1 2 3 4 5 6 I = 4 1 2 3 5 5 6 I = 5 1 2 3 5 8 6 I = 6 1 2 3 5 8 13 Answer D.
Computer Science - 6 17. What value is stored in A after the function call A = F(100)? Function F(N) Count = 0 K = 2 While (K<N) While (N MOD K = 0) N = N DIV K Count = Count + 1 EndWhile K = K + 1 EndWhile Return(Count) EndFunction a. 2 b. 4 c. 6 d. 99 The argument N is initialized to 100 and changed 4 times: 100 100 DIV 2 = 50 50 DIV 2 = 25 25 DIV 5 = 5 5 DIV 5 = 1 The count variable counts the number of time that N changed. It returns 4 (B) 18. Assuming A[1..N], what value will be stored in the variable Result after the following code executes? Result=1 For Index From 2 To N If (A[Index] < A[Result]) Then Result = index EndIf a. the value of the largest element in the array A b. the index of the largest element in the array A c. the index of the smallest element in the array A d. the value of the smallest element in the array A Result is set to index whenever the value at index is smaller than the one at result. When the loop terminates, result contains C.
Computer Science - 7 19. What is the value of A after the following code executes? A=0; For K From 3 To 5 A = A + F(K) Function F(B) If (B Mod 2 > 0) Then Return B Else Return (0 - B) EndIf EndFunction a. 4 b. 8 c. 12 d. 16 A = F(3)+F(4)+F(5) = 3 + (-4) + 5 = 4 Answer A 20. Given the array A[1..5] = 3, 2, 5, 1, 4, what would be the contents of the array A after the following code executes? J = 1 For K From 2 To 5 If (A[K] > A[J]) Then J = K EndIf K = 5 Temp = A[K] A[K] = A[J] A[J] = Temp a. 3, 2, 1, 4, 5 b. 3, 2, 1, 5, 4 c. 3, 2, 4, 1, 5 d. 1, 2, 3, 4, 5 At the end of For loop, J contains the index of the largest element in the array, which is 3 Swapping A[3] (containing 5) and A[5] (containing 4), we get a array: 3, 2, 4, 1, 5 Answer C
Computer Science - 8 21. What is the value of A after the following code executes? A = 0 For J from 1 To 10 If (J MOD 2 > 0) Then A = A + J EndIf a. 11 b. 15 c. 25 d. 55 A gets the sum of all odd numbers between 1 and 10. In other words, A = 1+3+5+7+9 = 25 Answer C. 22. Given the hash function: H(N) = N MOD 19 If linear probing is used and seven integer data items are stored in the hash table in the following order: 65 8 361 20 19 38 27 How many collisions occurred? a. 3 b. 4 c. 5 d. 6 The following illustrate how and where each number is stored 65 arrives, hash value = 65 MOD 19 = 8, Store it in table[8], no collision 8 arrives, hash value = 8 MOD 19 = 8, since table[8] is already occupied, using linear probing, store it in the next available cell, table[9] collision 361 arrives, hash value = 361 MOD 19 = 0, store it in table[0], no collision 20 arrives, hash value = 20 MOD 19 = 1, Store it in table[1], no collision 19 arrives, hash value = 19 MOD 19 = 0, since table[0] is already occupied, using linear probing, store it in the next available cell, table[1] collision 38 arrives, hash value = 38 MOD 19 = 0, since table[0] is already occupied, using linear probing, store it in the next available cell, table[2] collision 27 arrives, hash value = 27 MOD 19 = 8, since table[8] is already occupied, using linear probing, store it in the next available cell, table[10] collision Total number of collision: 4, answer B.
Computer Science - 9 23. If the root of a binary tree is considered at level 1, then the maximum number of nodes at level 3 of a binary tree is a. 2 b. 3 c. 4 d. 5 level 1: 1 node level 2: at most 2 nodes level 3: at most 4 nodes. Answer C. 24. A Post-order traversal of the binary tree below would result in what sequence? a. 5, 6, 3, 7, 4, 2 b. 5, 3, 6, 2, 4, 7 c. 2, 3, 5, 6, 4, 7 d. 2, 3, 4, 5, 6, 7 A 2 3 4 5 6 7 Recursively, Post-order traversal visit the nodes in the order of: Left sub-tree, Root, right sub-tree Answer A. 25. The tree in the previous question is called a(n) a. Expression tree b. Min Heap c. Search tree d. Complete binary tree In the above tree, the value stored at any node is less than the values stored in any of its child nodes. A is incorrect because there is no operator in the tree B is incorrect because leaf nodes of a heap must be in the left most position. In other words, 7 must a left child of 4 for the tree to be a heap C is incorrect since a search tree requires that the left child has value smaller than its parent node.
Computer Science - 10 D. is incorrect since node 4 does not have a left child. Answer E. 26. The expression (A+B)*C/(D*(E-F)) written in reverse polish notation is a. AB+C*DEF-*/ b. ABC+*DEF-/* c. ABCD**+EF-/ d. ABC*D+DEF-/* The following describe how the postfix (or reverse polish) expression is created: A AB AB+ AB+C AB+C* AB+C*D AB+C*DE AB+C*DEF AB+C*DEF- AB+C*DEF-* AB+C*DEF-*/ Answer A. 27. In a complete binary tree of 31 nodes, what is the maximum distance between any two nodes? Assume each edge in the path counts as 1. a. 4 b. 5 c. 8 d. 10 e. 30 A complete binary tree of 31 nodes has 5 levels: Level 1 2 3 4 5 # of nodes 1 2 4 8 16 the leftmost leaf node and the rightmost leaf nodes are furthest apart. The distance = distance between leftmost leaf and root + distance between root and rightmost = 4+4 = 8 Answer C 28. Which of the following is not a proper postfix notation? a. ABCDE++++ b. ABC***EF/ c. AB+C+D+E+ d. ABC++DEF+++ In a proper postfix expression, as we scan from left to right, at no time will the Number of operands be less than or equal to the number of operators. B is not proper since the part ABC*** has equal number of operands as operators. Answer B.
Computer Science - 11 29. Which of the following programming tasks does NOT require a stack? a. Implementation and simulation of recursion b. Simulation of waiting line c. Converting an expression to reverse polish notation d. Evaluation of arithmetic expression Simulation of waiting line requires queue which is First In First Out, not stack. Answer B 30. Given the array A[1..6] = 44, 66, 11, 33, 99, 77, what would be the contents of the array A after the first pass of Straight Selection Sort (or jump down sort)? a. 11, 33, 44, 66, 77, 99 b. 44, 66, 11, 33, 77, 99 c. 11, 44, 66, 33, 99, 77 d. 44, 11, 33, 66, 77, 99 The logic behind a straight selection sort is: For Counter = 1 to Length Find minimum in List[Counter]... List[Length] Swap minimum with List[Counter] After the 1 st path, the smallest value is found (11 in A[3]) and swap with A[1], resulting in the array: 11, 66, 44, 33, 99, 77 Answer E