You are on page 1of 5

14/03/13

https://sites.google.com/site/jonathanmercutio/ecaes?tmpl=%2Fsystem%2Fapp%2Ftemplates%2Fprint%2F&showPrintDialog=1

Ecaes Solucion

ECAES
7. Dada la siguiente instruccin for (A y D son condiciones; C y E son instrucciones; A, D, C, E no modifican el valor de i): for (i= 1; i<=1000; i= i+1) if (A) C; else if (D) E; else C;

Si A es cierta con probabilidad 0.6 y D es cierta con probabilidad 0.8, el nmero esperado de ejecuciones de C, es A. B. C. D. 80 480 600 920

E. 680

10. Indique cul de los siguientes fragmentos de programa es correcto con respecto a la especificacin (x mod y es el residuo de la divisin entera de x por y): Pre: Existe k (k>=0): pot == 2^k Pos: pot == 1 A. while (pot/2 == 0) pot= pot mod 2;

B. while (pot mod 2 == 0) pot= pot/2;


C. while (2 mod pot == 0) pot= pot/2; D. if (pot mod 2 == 0) pot= 1; else pot= 0; E. if (pot/2 == 0) pot= 1; else pot= 0; Dado que mientras sea de la forma 2^k, lo divide por 2. Si no tiene esa forma va a salir del ciclo y no va a retornar pot==1. 12. Mara escoge un nmero entre 1 y 64. Pedro debe identificar el nmero haciendo preguntas que se responden con un s o con un no. Pedro sabe que Mara siempre responde con la verdad. Si Pedro usa una estrategia ptima cuntas preguntas debe hacer en el peor de los casos? A. 1 B. 32

C. 6
D. 5 E. 7
https://sites.google.com/site/jonathanmercutio/ecaes?tmpl=%2Fsystem%2Fapp%2Ftemplates%2Fprint%2F&showPrintDialog=1 1/5

14/03/13

https://sites.google.com/site/jonathanmercutio/ecaes?tmpl=%2Fsystem%2Fapp%2Ftemplates%2Fprint%2F&showPrintDialog=1

Pedro puede hacerlo como una busqueda binaria donde va dividiendo el numero en dos. Dado que Log(2)64=6, la cantidad de preguntas son 6. 13. El siguiente programa calcula en r el producto de dos nmeros a y b mediante sumas: /* Q: b > 0 */ r= 0; n= b; while (n!=0){ r= r+a; n= n-1; } /* R: r == ab */ De las siguientes aserciones, es un invariante para el ciclo A. r == b(a-n)

B. r == a(b-n)
C. r == b2 -bn D. r == ab-n E. r == an-ab La respuesta es la B, dado que se multiplica a por la cantidad de veces que ha entrado al ciclo( b-n).

GRE COMPUTER SCIENCE


2. Which of the following decimal numbers has an exact representation in binary notation? a) 0.1 b) 0.2 c) 0.3 d) 0.4

e) 0.5

La representacion mas compacta en notacion binaria es 0.510 cuya representacion binaria es 0.12 3. Bob writes down a number between 1 and 1000. Mary must identify that number by asking "yes/no" questions of Bob. Mary knows that Bob always tells the truth. If mary uses an optimall extrategy, then she determine the answer at the end of exactly how many questions in the worst case? (A) 1000 (B) 999 (C) 500 (D) 32

(E) 10

Basandonos en una estrategia de busqueda binaria, podemos creer que el resultado puede ser Log(2) 1000 aprox 10. 4. x is a string x ^r is the reversal then (xy)^r is:

(B)yx^r
5. a procedure that printed the binary tree in postorder

(C) DBEAFC
6. which of the following is not a binary search tree?
https://sites.google.com/site/jonathanmercutio/ecaes?tmpl=%2Fsystem%2Fapp%2Ftemplates%2Fprint%2F&showPrintDialog=1 2/5

14/03/13

https://sites.google.com/site/jonathanmercutio/ecaes?tmpl=%2Fsystem%2Fapp%2Ftemplates%2Fprint%2F&showPrintDialog=1

(C)
7. Consider the following Pascal-like program fragment: var i,j : integer; procedure P(k,m : integer) ; begin k : =k-m m : =k+m k : =m-k end; i:=2; j: = 3; P(i,j) ; If both parameters to P are passed by reference, what are the values of i and j at the end of the program fragment? (A) i=0 , j=2 (B) i = 1, j = 5 (C) i = 2 , j = 3

(D) i = 3 , j = 2 (E) None of the above

Podemos ponerle subindices a el fragmento de algoritmo.

8. a starvation-free job-schenduling policy guarantees that no job waits indefinitely for service. which of the following job-schenduling policies is starvation-free?. (A) round-robin (B)priority queuing (C) shortest job first (D)youngest job first

(E) None of the above


9. The time of which of the following operations depends on the length of the list? 10. p : = 1 ; k : = 0 ; while k<n do: Begin p : = p * 2; k: =k+1 ; end; For the program fragment above involving integer p, k and n, which of the following is a loop invariant; (A) p=k+1 (B) p=(k+1)^2 (C) (k+1)2^k

(D) p=2^k (E) p=2^(k+1)


3/5

https://sites.google.com/site/jonathanmercutio/ecaes?tmpl=%2Fsystem%2Fapp%2Ftemplates%2Fprint%2F&showPrintDialog=1

14/03/13

https://sites.google.com/site/jonathanmercutio/ecaes?tmpl=%2Fsystem%2Fapp%2Ftemplates%2Fprint%2F&showPrintDialog=1

Dado que en el ciclo siempre hay un multiplo de 2, y este se hace k veces. el resultado es 2^k 13. How many lines of output does the program produce? (A) 0-9

(B) 10-19 (C) 20-29 (D) 30-39 (E) more than 39

Este fragmento de programa se ejecuta mientras j<2000.

ya que:

14. Which of the followings is the integer that best approximates the last number printed?

(A) 0 (B) 1

(C) 2 (D) 3 (E) 4

15. An integer c is common divisor of two integers x and y if and only if, c is a divisor of x and c is a divisor of y; Which of the following sets of integers if could possibly be the set of all common divisors of two integers. (A) {-6,-2,-1,1,2,6} (B) {-6,-2,-1,0,1,2,6}

(C){-6,-3,-2,-1,1,2,3, 6}

(D) {-6,-3,

-2,-1,0,1,2,3,6} (E) {-6,-4,-3,-2,-1,1,2,3,4,6} Dado que en los conjuntos de soluciones todos son comn divisor de todos, y el mximo numero es 6, entonces las respuestas son los comnes divisores de esos nmeros. 17. A particular parallel program computation requires 100 seconds when executed on a single processor. if 40 percent of this computation is "inherently sequential" (will not benefit from additional processors), then the theoretically best possible elapsed times for this program running with 2 and 4 processors, respectively, are (A) 20 and 10 sec (B) 30 and 15 sec (C) 50 and 25 sec sec 40+60/2=70 and 40+60/4=55 20. Let P be a procedure that for some inputs call itself. If P is guaranteed to terminate, which of the following statements must be true? I. P has a local variable. II. P has an execution path where it does not call itself. III. P either refers to a local variable or has at least one parameter. (A)I only (B) II ONLY. (C) I and II Only

(D) 70 and 55 sec (E) 80 and 70

(D) II and III

only (E) I,II and III

Si queremos garantizar que un algoritmo recursivo tiene que tener un caso base que no se llame a s mismo. y adems tiene que utilizar una variable como parametro para que vaya cambiando, o una variable local. 23, A particular disk unit uses a bit string to record the ocupancy o vacancy of its tracks. with 0 denoting vacant and 1 occupied . for D4FE2003, the percentage of occupied is

https://sites.google.com/site/jonathanmercutio/ecaes?tmpl=%2Fsystem%2Fapp%2Ftemplates%2Fprint%2F&showPrintDialog=1

4/5

14/03/13

https://sites.google.com/site/jonathanmercutio/ecaes?tmpl=%2Fsystem%2Fapp%2Ftemplates%2Fprint%2F&showPrintDialog=1

(A)12% (B) 25% (C) 38% (D) 44% (E) 62%


26. Let S be the statement for i : =1 to N do V[i] := V[i]+1 (A) I only (B) II only

(C) III only (D) II and III only (E) I, II and III

Aunque todos empiezan a cambiar el vector V desde la posicin 1, el primero termina en N+1; el segundo en N-1, y el tercero en N. El for del problema empeza a sumar 1 al vector V desde la posicin 1 hasta la N, por tanto la nica solucin es III. 27. var i,j,x: integer; i:=1; j:=1; while i<10 do begin j:=j*i; i:= i +1; if i = X then exit end for the program fragment above, which of the following statements about the variables i and j must be true after of the fragment? La primera opcion si x>10 es que la salida de j = 9 ! e i = 10 y la otra es que sale del ciclo cuando x es igual a i, o sea que tiene como salida de j = (x-1)! e i = x E) ((j=9!) y (i>=10)) o ((j= (x-1)!) y (i=x)) 63. In a 2 - ordered array of 2N elements, what is the maximum number of positions that an element can be from its positions if the array were 1 - ordered? (A) 2N-1 (B) 2 (C) N/2 (D) 1

(E) N

En el peor caso es que en el vector 2-ordenado de 2N posiciones el maximo numero de la pocisin impar sea menor que la minima posicin par, por tanto la si se organizara este vector en uno 1-ordenado y la cantidad de digitos que hay antes de l es N. 64. In an array of 2N elements that is both 2- and 3- ordered, wht is the maximum number of positions that an element can be from its position if the array were 1-ordered.

(A) 2N-1 (B) 2 (C) N/2 (D) 1 (E) N


Si el arreglo de 2N es 3 ordenado significa que el elemento 2N-3 es menor o igual que 2N. A su vez como es 2 ordenado significa que ese elemento 2N-3 es menor que 2N-1, por tanto la nica forma de libertad es que el elemento 2N sea menor que 2N-1 por tanto al ordenarlo con forma 1-ordenado, ser la posicin 2N-1.

https://sites.google.com/site/jonathanmercutio/ecaes?tmpl=%2Fsystem%2Fapp%2Ftemplates%2Fprint%2F&showPrintDialog=1

5/5

You might also like