Question 61
Question 62
Consider the following program that attempts to locate an element x in a sorted array a[ ] using binary search. Assume N>1. The program is erroneous. Under what conditions does the program fail?
var i,j,k: integer; x: integer; a: array; [1....N] of integer; begin i:= 1; j:= N; repeat k:(i+j) div 2; if a[k] < x then i:= k else j:= k until (a[k] = x) or (i >= j); if (a[k] = x) then writeln (\'x is in the array\') else writeln (\'x is not in the array\') end;
Question 63
program Example (input, output) var b: integer; procedure test2: begin b:=10; end procedure test1 (a:integer): begin a:=5; writeln (\'point 1: \', a, b); test2; writeln (\'point 2: \', a, b); end begin (*Example*) b:=3; test1(b); writeln(\'point3: \', b); end
Question 64
E → E + E {print “+”} E → E ∗ E {print “.”} E → id {print id.name} E → ( E )An LR-parser executes the actions associated with the productions immediately after a reduction by the corresponding production. Draw the parse tree and write the translation for the sentence (a+b)∗(c+d), using the SDTS given above.
Question 65
N = 2 M = 2 fork L3 fork L4 S1 L1:join N S3 L2:join M S5 L3:S2 goto L1 L4:S4 goto L2 next:
Question 66
A computer system uses the Banker’s Algorithm to deal with deadlocks. Its current state is shown in the table below, where P0, P1, P2 are processes, and R0, R1, R2 are resources types.
[caption width="800"] [/caption]a) Show that the system can be in this state. b) What will the system do on a request by process P0 for one unit of resource type R1?
Question 67
Question 68
Question 69
A hard disk is connected to a 50 MHz processor through a DMA controller. Assume that the initial set-up of a DMA transfer takes 1000 clock cycles for the processor, and assume that the handling of the interrupt at DMA completion requires 500 clock cycles for the processor. The hard disk has a transfer rate of 2000 Kbytes/sec and average block transferred is 4 K bytes. What fraction of the processor time is consumed by the disk, if the disk is actively transferring 100% of the time?
[caption width="800"] [/caption].
Question 70
There are 75 questions to complete.