GRE_CS_Practice

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

B

A hash function h maps 16-bit inputs to 8-bit hash values. What is the largest k such that in any set of 1,000 inputs, there are at least k inputs that h maps to the same hash value? (A) 3 (B) 4 (C) 10 (D) 64 (E) 256

B

A hiker faces the 0/1 Knapsack problem. There are 7 items to be packed into the knapsack, each with value vₙ and weight wₙ as shown in the following table. The knapsack, which is initially empty, can hold a maximum weight of 24, so some item(s) must be left behind, and fractions of items cannot be packed. The optimality criterion is to maximize the total value of the items that are placed in the knapsack. The hiker fills the knapsack one item at a time, using a heuristic algorithm that is greedy on value density, where the value density of an item is its value/weight ratio. When this heuristic algorithm is used, what is the total value of the items that are packed, and is this total optimal? Total Value -- Optimal/Not Optimal (A) 29 -- Optimal (B) 29 -- Not optimal (C) 30 -- Optimal (D) 30 -- Not optimal (E) 32 -- Optimal

B

A k-sorted array is a nearly sorted array in which no element is more than k locations away from its final position in the sorted array. Thus, a 0-sorted array is completely sorted and every array of size n is n-sorted. Suppose that A is a k-sorted array of size n. If insertion sort is used to sort A, what is the order of growth of the number of comparisons performed by the sorting algorithm in the worst case? (A) θ(k) (B) θ(kn) (C) θ(k²n) (D) θ(n log n) (E) θ(n²)

A

A privileged instruction may be executed only while the hardware is in kernel mode. Which of the following is LEAST likely to be a privileged instruction? (A) An instruction that changes the value of the program counter (B) An instruction that sends output to a printer (C) An instruction that modifies a memory management register (D) An instruction that halts the CPU (E) An instruction that resets the computer's time-of-day clock

E

A researcher is preparing a questionnaire with 6 questions. The only possible responses to each question are "Yes," "Maybe," and "No." The researcher wants to know how many people answer with any given combination of responses. A programmer is designing a data structure to collate the responses to this questionnaire. The programmer decides to use a base structure containing 6 memory locations, one for each question. Each element will contain a 2 for "Yes," a 1 for "Maybe," and a 0 for "No." One person's response may look like this: img The programmer then declares an array with one slot for each possible combination of responses. What will be the number of entries in the array? (A) 3 (B) 6 (C) 216 (D) 324 (E) 729

C

A software requirements specification is I. a contract between developers and clients specifying what the developers will produce for the clients. II. a specification of the features that the target software deliverable must have. III. a specification of the personnel and resources that will be committed to the software development effort. (A) I only (B) II only (C) I and II only (D) I and III only (E) I, II, and III

A

Amdahl's Law pertains to the speedup achieved when running a program on parallel processors versus using a single serial processor. In this context, speedup is the ratio of original running time to improved running time. According to Amdahl's Law, approximately how much speedup could we expect for an unlimited number of processors if 10 percent of a program is sequential and the remaining part is ideally parallel? (A) 10X (B) 20X (C) 40X (D) 90X (E) Infinite

D

Consider a single-issue processor with an in-order five-stage pipeline (IF, ID, EX, MEM, and WB) and with the following characteristics. • The register file can be written and then read in the same cycle. • The pipeline does not have other bypassing/forwarding hardware. • Instructions, including loads and stores, spend only one cycle in the MEM stage. Consider the following MIPS-like instructions in which the destination register is the first (leftmost) register. The instruction set supports (i) register-indirect addressing, which is indicated by using parentheses and (ii) displacement addressing, which is indicated as an integer offset from a register indirect value. loadword $t0, ($t1) add $t2, $t2, $t0 loadword $t0, 4($t1) add $t1, $t1, 1 add $t2, $t2, $t0 sub $t3, $t1, $t0 How many stall cycles do the instructions incur? (A) 0 (B) 1 (C) 2 (D) 3 (E) 4

E

Consider the binary heap img that uses an array a[] = [9, 7, 4, 2, 6, 1, 3] to store its elements. What will be the values of the remaining elements in the array after one delete-max operation from the heap? (A) [7,4,2,6,1,3] (B) [7,4,6,2,1,3] (C) [7,4,6,2,3,1] (D) [7,6,4,2,1,3] (E) [7,6,4,2,3,1]

D

Consider the following Java code. class BaseClass { int data = 101; public void print () { System.out.print ( data + " " ); } public void fun () { print (); } } class SubClass extends BaseClass { int data = 202; public void print () { System.out.print ( data + " " ); } } class TestClass { public static void main ( String[] args ) { BaseClass obj = new SubClass (); obj.print (); obj.fun (); System.out.print ( obj.data ); } } What is printed by the execution of TestClass.main () ? (A) 101 101 101 (B) 101 202 202 (C) 202 101 101 (D) 202 202 101 (E) 202 202 202

D

Consider the following binary search tree. img Starting from an empty binary search tree, the insertion of which of the following sequences of integer keys could produce the binary tree above? (A) 5, 9, 1, 7, 3, 4 (B) 5, 7, 4, 9, 3, 1 (C) 5, 4, 7, 3, 9, 1 (D) 5, 3, 4, 9, 1, 7 (E) 5, 3, 1, 7, 9, 4

D

Consider the following concurrent tasks, in which each assignment statement executes atomically. Initially, the shared variables x and y are set to 0. Task 1 -- Task 2 x = 1 -- y = 1 a = y -- b = x At the end of the concurrent tasks, the values of a and b are examined. Which of the following must be true? I. ( a == 0 ) -> ( b == 1 ) II. ( b == 0 ) -> ( a == 1 ) III. ( a == 1 ) -> ( b == 1 ) (A) I only (B) II only (C) III only (D) I and II only (E) I, II, and III

E

Consider the following directed graph. img Which of the following is a topological sort of the nodes of the graph? (A) 5, 7, 10, 13, 14, 17, 20, 30 (B) 10, 5, 13, 14, 7, 30, 17, 20 (C) 10, 5, 13, 17, 20, 14, 7, 30 (D) 10, 5, 20, 13, 17, 30, 14, 7 (E) 10, 20, 5, 17, 13, 14, 7, 30

D

Consider the following function. int f () { int k, result; result = 0; for ( k = 0; k < 5; k++ ) { if ( ( k % 3 ) == 1 ) result = result + k; else result = result + 1; } return result; } What value is returned as a result of the call f () ? (A) 5 (B) 6 (C) 7 (D) 8 (E) 9

B

Consider the following instruction sequence in a single-issue in-order 5-stage pipeline (IF, ID, EX, MEM, and WB). img How many data hazards does the ID stage need to detect for this instruction sequence? (A) 1 (B) 2 (C) 3 (D) 4 (E) 5

D

Consider the following nondeterministic finite state automaton over alphabet {x, y} with start state S. img Which of the following is the regular expression corresponding to the automaton above? (A) xxx + yyx (B) x³ y² x (C) x* y* x (D) xx* (x + y) y* x (E) x* xy* x

D

Consider the following page reference string: 1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1 Assuming there are 4 page frames available and that all frames are initially empty, what is the total number of page faults that would occur for the page reference string above if the least-recently-used (LRU) replacement policy is used? (A) 6 (B) 7 (C) 9 (D) 10 (E) 11

E

Consider the following pseudocode fragment. i = 0; j = 0; k = 0; while (i < 10 and j < 10) { if (A[i] > B[j]) { C[k] = A[i]; k = k + 1 ; i = i + 1 ; } else { C[k] = B[j]; k = k + 1 ; j = j + 1 ; } } Which of the following could serve as a loop invariant for the while loop above? I. i < 10 or j < 10 II. i < 11 and j < 11 III. k = i + j (A) I only (B) I and II only (C) I and III only (D) II and III only (E) I, II, and III

B

Consider the following pseudocode in which all variables are integers and m ≥ 1. Pseudocode I sum = 0 for i = 1 to m sum = sum + i output ( sum ) The following pseudocode is intended to produce the same output as Pseudocode I. Pseudocode II sum = 0 i = <initial value> while ( <condition> ) { i = i + 1 sum = sum + i } output ( sum ) Which of the following can be used to replace <initial value> and <condition> so that Pseudocode II will produce the same output as Pseudocode I ? <initial value>, <condition> (A) 0, i < m - 1 (B) 0, i < m (C) 0, i < m + 1 (D) 1, i < m (E) 1, i < m + 1

A

Consider the following pseudocode of the recursive function goAgain. // assume N is a positive integer integer goAgain ( integer a, integer N ) begin if ( N == 1 ) then return a else return a + goAgain ( a, N/2 ) end What is the order of growth, as a function of N, of the number of times the function goAgain is recursively executed? (A) θ(log N) (B) θ(N) (C) θ(N log N) (D) θ(N²) (E) 3 θ(N³)

D

Consider the following pseudocode program. int i main () { i = 3 S () R () } void S () { print i // prints the value of i on the current line of output print " " // prints a blank space on the current line of output } void R () { int i i = 2 S () } What is the output of the program if the pseudocode uses either static (lexical) scoping or dynamic scoping? Static Scoping - Dynamic Scoping (A) 3 2 - 3 2 (B) 3 3 - 2 2 (C) 3 3 - 2 3 (D) 3 3 - 3 2 (E) 3 3 - 3 3

D

Consider the following pseudocode. program main () begin integer a, b, c, i a = 6 b = 7 c = 8 i = fun(a, b, c) print i, a, b, c end integer fun (integer x, integer y, integer z) begin if (x > 6) then y = 25 z = x + y return y + z end If fun uses call-by-reference, what values would be printed as a result of executing the pseudocode? i a b c (A) 6 20 8 7 (B) 6 20 13 7 (C) 20 6 7 8 (D) 20 6 7 13 (E) 56 6 25 31

E

Consider the following truth table and implementation. img Which of the following statements is (are) true about the circuit shown? I. The line labeled S is correct. II. The line labeled T is correct. III. The line labeled U is correct. (A) None (B) I only (C) II only (D) III only (E) I, II, and III

D

Consider the following two fragments of Java programs. public void P1 (int x, int y, int z) { if ((x != 0) && ((y / x) == z)) z = z + 1; System.out.println("x = " + x + " y = " + y + " z = " + z); } public void P2 (int x, int y, int z) { if (((y / x) == z) && (x != 0)) z = z + 1; System.out.println("x = " + x + " y = " + y + " z = " + z); } Which of the following is true? (A) For all x, y, and z, P1(x, y, z) and P2(x, y, z) have the same behavior. (B) For all x and y, there exists z such that P1(x, y, z) and P2(x, y, z) behave differently. (C) For all x and z, there exists y such that P1(x, y, z) and P2(x, y, z) behave differently. (D) For all y and z, there exists x such that P1(x, y, z) and P2(x, y, z) behave differently. (E) For all x, y, and z, P1(x, y, z) and P2(x, y, z) behave differently.

A

Consider the following two problems. Nearest Neighbors: Given an unsorted array of n floating-point numbers as input, return two of the numbers that are closest in value to each other. Farthest Neighbors: Given an unsorted array of n floating-point numbers as input, return two of the numbers that are farthest in value from each other. Assume that the only operations allowed on the data are • comparing the values of two entries in the array and identifying the larger value; • comparing the distance between two array entries (the absolute value of the difference between the two array entries) with the distance between two other array entries; • swapping two entries in the array. Further assume that each allowed operation has unit cost. What are the worst-case optimal asymptotic running times for algorithms that solve the two problems? Nearest Neighbors - Farthest Neighbors (A) θ( n log n) - θ(n) (B) θ(n log n) - θ(n log n) (C) θ(n²) - θ(n) (D) θ(n²) - θ(n log n) (E) θ(n²) - θ(n²)

C

Consider three processes P1, P2, and P3 with respective arrival times of 0 ms, 10 ms, and 20 ms and respective processing times of 30 ms, 15 ms, and 30 ms. The three processes are preemptively scheduled on a single-CPU system using the shortest-remaining-processing-time-first scheduling policy. Which of the following shows the order in which the processes complete, from first to last? (A) P1 P2 P3 (B) P1 P3 P2 (C) P2 P1 P3 (D) P2 P3 P1 (E) P3 P1 P2

C

Which of the following typically occurs when a procedure call is executed on a processor? I. Program counter is updated. II. Stack pointer is updated. III. Data cache is flushed to avoid aliasing problems. (A) I only (B) II only (C) I and II only (D) I and III only (E) I, II, and III

E

An algorithm's real-time readiness (RTR) ratio is defined as the ratio of its average-case running time to its worst-case running time. Which of the following algorithms has an RTR ratio closest to 0 ? (A) Bubblesort (B) Heapsort (C) Insertion sort (D) Mergesort (E) Quicksort

A

Assume that any n-bit positive integer x is stored as a linked list of bits so that the first element of the list is the least significant bit. For example, x =14= 1110₂ is stored as the linked list (0, 1, 1, 1) of size n 4. For this data structure, the operation that replaces x by img can be done in (A) θ(1) steps (B) θ(log n) steps (C) θ(n) steps (D) θ(n log n) steps (E) θ(n²) steps

B

If the delay through a single-bit adder is 3 (measured in gate delays) to the sum output and 2 to the carry output, what is the delay through a k-bit ripple-carry adder? (A) 2k - 1 (B) 2k + 1 (C) 3k - 1 (D) 3k (E) 3k + 1

E

In order to create a good solution for the mutual exclusion problem for concurrent processes, which of the following conditions must hold? I. No process should have to wait forever to enter its critical region. II. No process running outside of its critical region may block other processes from entering their critical region. III. There should be no assumptions about the speed or number of CPUs. (A) None (B) I and II only (C) I and III only (D) II and III only (E) I, II, and III

E

Suppose that Professor X develops a new model of computation, called a neutron machine. Which of the following would be a consequence of the Church-Turing thesis? (A) No neutron machine can solve the Traveling Salesman problem in polynomial time. (B) No neutron machine can solve the Maximum Matching problem for bipartite graphs in polynomial time. (C) No neutron machine can determine whether the decimal expansion of π has 7 consecutive 7s. (D) No neutron machine can simulate a given Turing machine in polynomial time. (E) No neutron machine can determine in polynomial time whether a given Turing machine halts when its input tape is initially blank.

E

What is the negation of the predicate ∀x∃y(p(y) → q(x))? (A) ∀x∃y (p(y)→ ∠q(x)) (B) ∀x∃y (p(y)∧ ∠q(x)) (C) ∃x∀y (p(y)→ ∠q(x)) (D) ∃x∀y (q(x)→ ∠p(y)) (E) ∃x∀y (p(y)∧ ∠q(x))

B

The routing table below uses the longest prefix match in its routing decisions. img What are the next hops for each of the following two destination addresses? Next Hop to 196.94.10.7 - Next Hop to 196.94.34.9 (A) S - T (B) S - U (C) T - T (D) T - U (E) U - U

A

Which data structure would be most appropriate to implement a collection of values with the following three characteristics? • Items are retrieved and removed from the collection in FIFO order. • There is no a priori limit on the number of items in the collection. • The size of an item is large relative to the storage required for a memory address. (A) Singly-linked list, with head and tail pointers (B) Doubly-linked list, with only a head pointer (C) Array (D) Binary tree (E) Hash table

A

A color (RGB) raster-scan graphics system provides 18 bits per pixel and uses no color lookup table. If black and white count as shades of gray, how many different shades of gray does the system offer? (A) 64 (B) 255 (C) 256 (D) 262,143 (E) 262,144

C

A computer memory system has a 64KB byte-addressable main memory with 16-bit addresses. This same system has a one-level cache memory that can hold 16 blocks of data, where each block contains 16 bytes. Assuming this is a direct-mapped cache, to which cache block will main memory address 9A81ₙ map? (n = 16) (A) 0ₙ (B) 1ₙ (C) 8ₙ (D) 9ₙ (E) Aₙ

B

A full binary tree is a rooted tree in which every internal node has exactly two children. How many internal nodes are there in a full binary tree with 500 leaves? (A) 250 (B) 499 (C) 500 (D) 501 (E) 1,000

C

Consider a relational database schema with the following instance of a relation R A, B, C . img Assuming the instance above is valid, which of the following functional dependencies must be FALSE? I. A →B II. A→C III. AB →C (A) I only (B) II only (C) I and II (D) I and III (E) II and III

E

Five balls are placed randomly into four boxes, labeled A, B, C, and D. Each ball has an equal chance of being placed into any box. What is the expected total number of balls in boxes A and B ? (A) 1 (B) 1.25 (C) 1.5 (D) 2 (E) 2.5

C

Consider a brute-force password-guessing attack that can submit authentication requests at a rate of one every millisecond. Assume that a password consists of 1-6 characters from a 10-symbol alphabet. In the average case, approximately how many seconds would it take to determine the password using this type of attack? (A) 100 (B) 500 (C) 555 (D) 1,000 (E) 1,111

D

Consider a recursive algorithm for sorting an array of n ≥ 2 integers that works as follows. (a) If there are only 2 elements to be sorted, compare them and swap them if they are out of order. (b) Otherwise, do the following steps in order. (1) Recursively sort the first n - 1 elements of the array. (2) In the resulting array, recursively sort the last n - 1 elements. (3) In the resulting array, recursively sort the first 2 elements of the array. What is the asymptotic running time complexity of this algorithm measured in terms of the number of comparisons made? (A) θ(n log n) (B) θ(n²) (C) θ(n³) (D) θ(2ⁿ) (E) θ(3ⁿ)

B

Consider a regular language L over {0, 1}. Which of the following languages over {0, 1} must also be regular? I. {w ε L | length of w is even} II. {w ε L | the length of w is prime} III. {w ε L | the length of w is an integer power of 2} (A) None (B) I only (C) III only (D) I and III only (E) I, II, and III

B

Consider the pseudocode block below. Assume that the variables x and y are integers. // Precondition: ???? x ← x + y y ← x - y x ← x - y // Postcondition: (( x = 3 ) and ( y = 8 )) Which of the following would be an appropriate precondition to guarantee the stated postcondition? (A) ( x = 3 ) and ( y = 8 ) (B) ( x = 8 ) and ( y = 3 ) (C) ( x = 8 ) and ( y = 11 ) (D) ( x = 11 ) and ( y = 3 ) (E) ( x = 11 ) and ( y = 8 )

B

Five wireless nodes—A, B, C, D, and E—are arranged in a line. Any pair of adjacent nodes are within range of each other, and nonadjacent nodes do not interfere. All nodes execute the Carrier Sense Multiple Access/Collision Avoidance (CSMA/CA) protocol with Ready to Send/Clear to Send (RTS/CTS) exchange prior to transmission. If the link bandwidth is L bits per second for successful transmissions and reliable transmission is desired, what is the maximum possible total bandwidth attainable for this network, in bits per second? (A) L (B) 2L (C) 3L (D) 5L (E) 6L

D

Let M₀ , M₁ , M₂ , . . . , be an effective enumeration of all Turing machines. Which of the following problems is (are) decidable? I. Given a natural number n, does Mₙ starting with an empty tape halt in fewer than n steps? II. Given a natural number n, does Mₙ starting with an empty tape halt in exactly n steps? III. Given a natural number n, does Mₙ starting with an empty tape halt after at least n steps? (A) I only (B) II only (C) III only (D) I and II (E) I and III

C

One garbage collection algorithm is semispace copying collection. Which of the following characteristics of garbage collection apply to semispace copying collection? I. Collects dead objects that reference each other II. Incurs overhead on every assignment operation to a reference variable III. Avoids fragmentation (A) None (B) I and II only (C) I and III only (D) II and III only (E) I, II, and III

D

Suppose problem A is NP-complete and problem B is in NP but is not necessarily NP-complete. Which of the following statements is (are) necessarily true? I. A polynomial-time algorithm for A implies P NP. II. A polynomial-time algorithm for B implies P NP. III. A polynomial-time algorithm for A implies a polynomial-time algorithm for B. (A) I only (B) II only (C) I and II only (D) I and III only (E) I, II, and III

A

The subtype principle describes when one type may be substituted for another. Which of the following is true? (A) An instance of a subtype may be used in any expression in which an instance of the supertype may be used because the subtype must support a superset of the operations supported by the supertype. (B) An instance of a subtype may be used in any expression in which an instance of the supertype may be used because the subtype must support a subset of the operations supported by the supertype. (C) An instance of a supertype may be used in any expression in which an instance of the subtype may be used because the subtype must support a superset of the operations supported by the supertype. (D) An instance of a supertype may be used in any expression in which an instance of the subtype may be used because the subtype must support a subset of the operations supported by the supertype. (E) Instances of subtypes and supertypes may be used interchangeably.

A

Two classical algorithms for finding a minimum spanning tree in a graph are Kruskal's algorithm and Prim's algorithm. Which of the following are the design paradigms used by these algorithms? Kruskal's algorithm - Prim's algorithm (A) The greedy method - The greedy method (B) The greedy method - Dynamic programming (C) Dynamic programming - The greedy method (D) Dynamic programming - Divide and conquer (E) Divide and conquer - Dynamic programming

A

Which of the following best describes the difference between paging and segmentation? (A) Paging breaks a process' virtual memory into physical units of the same size, whereas segmentation breaks a process' virtual memory into logical units that are typically of different sizes. (B) Paging suffers from external fragmentation, whereas segmentation suffers from internal fragmentation. (C) Paging requires page tables for address translation, whereas segmentation does not require segment tables for address translation. (D) Paging requires one page table per process, whereas segmentation requires only one global segment table for the entire system. (E) Page tables are typically very small, whereas segment tables are always very large.

B

Which of the following is the most appropriate data structure to store the symbol table of a compiler? (A) Linked list (B) Hash table (C) Priority queue (D) Queue (E) Set

C

Which of the following properties must be true of a Minimum Spanning Tree (MST) of a connected graph G with at least 3 edges? I. The MST must contain the shortest edge of G. II. The MST must contain the second-shortest edge of G. III. The MST can never contain the longest edge of G. (A) None (B) I only (C) I and II only (D) I and III only (E) I, II, and III

E

Which of the following statements about caches is (are) true? I. A direct-mapped cache can have a lower miss rate than an associative cache of the same size (number of blocks). II. Programs with high spatial locality have a low cache miss rate primarily because the exact same addresses are re-referenced. III. Programs with high temporal locality have a low cache miss rate primarily because the exact same addresses are re-referenced. (A) I only (B) II only (C) III only (D) I and II (E) I and III

C

Which of the following statements about fixed-length and variable-length instruction set architectures (ISAs) is (are) true? I. Variable-length ISAs allow for a smaller code size over fixed-length ISAs. II. Fixed-length ISAs simplify instruction fetch and decode over variable-length ISAs. III. Variable-length ISAs require more registers than fixed-length ISAs. (A) I only (B) II only (C) I and II only (D) II and III only (E) I, II, and III

D

Which of the following statements about positive integers is NOT true? (A) If x is a composite integer, then x has a prime divisor less than or equal to the square root of x. (B) There are infinitely many prime integers. (C) Integers a and b are congruent modulo m if and only if there is an integer k such that a = b + km. (D) If a divides bc, then either a divides b or a divides c. (E) If a divides b and b divides c, then a divides c.

A

img

B

img Which of the following grammars over alphabet {x, y} generates the language recognized by the automaton above? (A) S →xT T →xT | xU | yU U →yU | xV (B) S →xT T →xT | xU | yU U →yU | x (C) S →xT | T T →xT | xU | yU T | U U →yU | xV | V | x (D) S →xV T →xT | yU U →yU | xV (E) S →xT T →xT | T U →yU | V V →xV | x


Set pelajaran terkait

Chapter 38: Agents to Control Blood Glucose Levels

View Set

World History Imperialism Test Study Guide (Adams) 15.1,2,4

View Set

Milady Standard Foundations Ch. 1

View Set

Managerial Accounting Ch. 23 & 25

View Set

Ch.7 Evaluating Employee Performance

View Set

Understanding Business Chapter 6

View Set

Practical 1 Anatomical Terms Worksheet

View Set