GATE 2025 (Session 1)
65 questions
MCQ 30 · MSQ 13 · NAT 221-mark 30 · 2-mark 35
Questions 51–55 of 65
A disk of size bytes is divided into blocks of bytes. A file is stored in the disk using linked allocation. Each data block reserves 4 bytes to store the pointer to the next data block. The link part of the last data block contains a NULL pointer (also of 4 bytes). Suppose a file of bytes needs to be stored in the disk. Assume, . The amount of space in bytes that will be wasted due to internal fragmentation is _________. (Answer in integer)
Answer: 65468
The disk block size bytes. With linked allocation, each block, the last one too, keeps bytes for the pointer to the next block. So the data space in one block bytes.
The file size bytes. Blocks needed: . Here , which is bytes less than the file size. So one more block is needed, the th block. The total is blocks.
Total disk space given to the file: bytes. Space that is used (the file data plus the -byte pointer in each of the blocks): bytes.
Space wasted by internal fragmentation: bytes.
Answer: 65468
The file size bytes. Blocks needed: . Here , which is bytes less than the file size. So one more block is needed, the th block. The total is blocks.
Total disk space given to the file: bytes. Space that is used (the file data plus the -byte pointer in each of the blocks): bytes.
Space wasted by internal fragmentation: bytes.
Answer: 65468
Refer to the given 3-address code sequence. This code sequence is split into basic blocks. The number of basic blocks is _________. (Answer in integer)
1001: i = 1
1002: j = 1
1003: t1 = 10*i
1004: t2 = t1+j
1005: t3 = 8*t2
1006: t4 = t3-88
1007: a[t4] = 0.0
1008: j = j+1
1009: if j <= 10 goto 1003
1010: i = i+1
1011: if i <= 10 goto 1002
1012: i = 1
1013: t5 = i-1
1014: t6 = 88*t5
1015: a[t6] = 1.0
1016: i = i+1
1017: if i <= 10 goto 1013
1001: i = 1
1002: j = 1
1003: t1 = 10*i
1004: t2 = t1+j
1005: t3 = 8*t2
1006: t4 = t3-88
1007: a[t4] = 0.0
1008: j = j+1
1009: if j <= 10 goto 1003
1010: i = i+1
1011: if i <= 10 goto 1002
1012: i = 1
1013: t5 = i-1
1014: t6 = 88*t5
1015: a[t6] = 1.0
1016: i = i+1
1017: if i <= 10 goto 1013
Answer: 6
A new basic block starts at every leader. A leader is the first statement, any statement that is the target of a jump or goto, and any statement that comes right after a conditional or unconditional jump.
Now look for the leaders in the code: (the first statement); (the target of at ); (it comes right after the conditional jump at ); (the target of at ); (it comes right after the conditional jump at ); (the target of at ).
So there are leaders. This gives basic blocks: .
Answer: 6
Now look for the leaders in the code: (the first statement); (the target of at ); (it comes right after the conditional jump at ); (the target of at ); (it comes right after the conditional jump at ); (the target of at ).
So there are leaders. This gives basic blocks: .
Answer: 6
A computer has a memory hierarchy consisting of two-level cache (L1 and L2) and a main memory. If the processor needs to access data from memory, it first looks into L1 cache. If the data is not found in L1 cache, it goes to L2 cache. If it fails to get the data from L2 cache, it goes to main memory, where the data is definitely available. Hit rates and access times of various memory units are shown in the figure. The average memory access time in nanoseconds (ns) is _________. (rounded off to two decimal places)
Answer: 11.83 to 11.87
This system uses hierarchical (serial) cache access. To reach L2, the processor must first try L1 and miss. To reach main memory, it must first try L1 and L2 and miss in both. So the access times given for L2 and main memory already include the time spent on the earlier levels. L1 access time: ns. L2 access time (includes the L1 miss time): ns. Main memory access time (includes the L1 and L2 miss times): ns. Hit rates: for L1 and for L2.
The average memory access time is a weighted sum of three cases: hit in L1, miss in L1 then hit in L2, or miss in both and go to main memory:
ns.
Answer: 11.85
The average memory access time is a weighted sum of three cases: hit in L1, miss in L1 then hit in L2, or miss in both and go to main memory:
ns.
Answer: 11.85
In optimal page replacement algorithm, information about all future page references is available to the operating system (OS). A modification of the optimal page replacement algorithm is as follows:
The OS correctly predicts only up to next 4 page references (including the current page) at the time of allocating a frame to a page.
A process accesses the pages in the following order of page numbers:
1, 3, 2, 4, 2, 3, 1, 2, 4, 3, 1, 4.
If the system has three memory frames that are initially empty, the number of page faults that will occur during execution of the process is _________. (Answer in integer)
The OS correctly predicts only up to next 4 page references (including the current page) at the time of allocating a frame to a page.
A process accesses the pages in the following order of page numbers:
1, 3, 2, 4, 2, 3, 1, 2, 4, 3, 1, 4.
If the system has three memory frames that are initially empty, the number of page faults that will occur during execution of the process is _________. (Answer in integer)
Answer: 6
The OS sees only the next 4 references, the current one included. At a fault with no free frame, it removes the page in memory whose next use is farthest inside this window. A page that does not appear in the window counts as farthest.
Reference string (positions 1 to 12): 1, 3, 2, 4, 2, 3, 1, 2, 4, 3, 1, 4. Three frames, all empty at the start.
The first three references fill the empty frames, giving 3 faults.
Reference 4 (position 4): window is 4, 2, 3, 1. Pages in memory are 1, 3, 2, used at positions 7, 6, 5. Page 1 is farthest, so it is replaced.
Reference 1 (position 7): window is 1, 2, 4, 3. Pages in memory are 4, 3, 2, used at positions 9, 10, 8. Page 3 is farthest, so it is replaced.
Reference 3 (position 10): window is 3, 1, 4 (only these are left). Pages in memory are 4, 2, 1. Page 2 is not in the window, so it is replaced.
Total faults (at references 1, 3, 2, 4, 1, 3).
Answer: 6
Reference string (positions 1 to 12): 1, 3, 2, 4, 2, 3, 1, 2, 4, 3, 1, 4. Three frames, all empty at the start.
The first three references fill the empty frames, giving 3 faults.
Reference 4 (position 4): window is 4, 2, 3, 1. Pages in memory are 1, 3, 2, used at positions 7, 6, 5. Page 1 is farthest, so it is replaced.
Reference 1 (position 7): window is 1, 2, 4, 3. Pages in memory are 4, 3, 2, used at positions 9, 10, 8. Page 3 is farthest, so it is replaced.
Reference 3 (position 10): window is 3, 1, 4 (only these are left). Pages in memory are 4, 2, 1. Page 2 is not in the window, so it is replaced.
Total faults (at references 1, 3, 2, 4, 1, 3).
Answer: 6
Consider the following database tables of a sports league.
player(pid,pname,age)
coach(cid,cname)
team(tid,tname,city,cid)
members(pid,tid)
An instance of the table and an SQL query are given.
The value returned by the given SQL query is _________. (Answer in integer)
player(pid,pname,age)
coach(cid,cname)
team(tid,tname,city,cid)
members(pid,tid)
An instance of the table and an SQL query are given.
|
|
|
|
SELECT MIN(P.age)
FROM player P
WHERE P.pid IN (
SELECT M.pid
FROM team T, coach C, members M
WHERE C.cname = 'Mark'
AND T.cid = C.cid
AND M.tid = T.tid
)The value returned by the given SQL query is _________. (Answer in integer)
Answer: 26
Table instances from the question:
: (1,Jasprit,31), (2,Atharva,24), (3,Ishan,26), (4,Axar,30)
: (101,Ricky), (102,Mark), (103,Trevor)
: (10,MI,Mumbai,102), (20,DC,Delhi,101), (30,PK,Mohali,103)
: (1,10), (2,30), (3,10), (4,20)
Solve the inner subquery first. The condition selects the coach . Next, selects the team . Next, selects the members with : and .
So the subquery gives . The outer query now finds among the players with . These are Jasprit (age ) and Ishan (age ).
.
Answer: 26
: (1,Jasprit,31), (2,Atharva,24), (3,Ishan,26), (4,Axar,30)
: (101,Ricky), (102,Mark), (103,Trevor)
: (10,MI,Mumbai,102), (20,DC,Delhi,101), (30,PK,Mohali,103)
: (1,10), (2,30), (3,10), (4,20)
Solve the inner subquery first. The condition selects the coach . Next, selects the team . Next, selects the members with : and .
So the subquery gives . The outer query now finds among the players with . These are Jasprit (age ) and Ishan (age ).
.
Answer: 26