GATE 2015 (Session 1)
65 questions
MCQ 45 · NAT 201-mark 30 · 2-mark 35
Questions 56–60 of 65
Suppose the following disk request sequence (track numbers) for a disk with 100 tracks is given: 45, 20, 90, 10, 50, 60, 80, 25, 70. Assume that the initial position of the R/W head is on track 50. The additional distance that will be traversed by the R/W head when the Shortest Seek Time First (SSTF) algorithm is used compared to the SCAN (Elevator) algorithm (assuming that SCAN algorithm moves towards 100 when it starts execution) is____________ tracks.
Answer: 10
SSTF always serves the request nearest to the head. Starting at 50 the order is 50, 45, 60, 70, 80, 90, 25, 20, 10. (From 45 the nearest is 60, at distance 15, against 25 at distance 20. After 90 the nearest is 25.)
Movement tracks.
SCAN first moves towards 100, serving requests on the way. Here the head is taken to turn back at the last request on that side, track 90, and not to run on to the end of the disk. Then it sweeps down to the lowest request, 10. (If it ran on to track 99 before turning, the distances would change; this answer uses the turn at 90.)
Movement tracks.
Extra distance for SSTF tracks.
Answer: 10
Movement tracks.
SCAN first moves towards 100, serving requests on the way. Here the head is taken to turn back at the last request on that side, track 90, and not to run on to the end of the disk. Then it sweeps down to the lowest request, 10. (If it ran on to track 99 before turning, the distances would change; this answer uses the turn at 90.)
Movement tracks.
Extra distance for SSTF tracks.
Answer: 10
Consider a main memory with five page frames and the following sequence of page references: 3, 8, 2, 3, 9, 1, 6, 3, 8, 9, 3, 6, 2, 1, 3. Which one of the following is true with respect to page replacement policies First In First Out (FIFO) and Least Recently Used (LRU)?
Answer: (A)
FIFO (the oldest loaded page leaves first). Frames are listed oldest first:
3, 8, 2 fault; 3 hit; 9, 1 fault: 3, 8, 2, 9, 1 (5 faults)
6 faults, replaces 3: 8, 2, 9, 1, 6
3 faults, replaces 8: 2, 9, 1, 6, 3
8 faults, replaces 2: 9, 1, 6, 3, 8
9, 3, 6 hit
2 faults, replaces 9: 1, 6, 3, 8, 2
1, 3 hit
Total = 5 + 4 = 9 faults
LRU (the page used longest ago leaves first). Frames are listed least recently used first:
3, 8, 2 fault; 3 hit; 9, 1 fault: 8, 2, 3, 9, 1 (5 faults)
6 faults, replaces 8: 2, 3, 9, 1, 6
3 hit: 2, 9, 1, 6, 3
8 faults, replaces 2: 9, 1, 6, 3, 8
9, 3, 6 hit: 1, 8, 9, 3, 6
2 faults, replaces 1: 8, 9, 3, 6, 2
1 faults, replaces 8: 9, 3, 6, 2, 1
3 hit
Total = 5 + 4 = 9 faults
Both have 9 faults.
Answer: (A)
3, 8, 2 fault; 3 hit; 9, 1 fault: 3, 8, 2, 9, 1 (5 faults)
6 faults, replaces 3: 8, 2, 9, 1, 6
3 faults, replaces 8: 2, 9, 1, 6, 3
8 faults, replaces 2: 9, 1, 6, 3, 8
9, 3, 6 hit
2 faults, replaces 9: 1, 6, 3, 8, 2
1, 3 hit
Total = 5 + 4 = 9 faults
LRU (the page used longest ago leaves first). Frames are listed least recently used first:
3, 8, 2 fault; 3 hit; 9, 1 fault: 8, 2, 3, 9, 1 (5 faults)
6 faults, replaces 8: 2, 3, 9, 1, 6
3 hit: 2, 9, 1, 6, 3
8 faults, replaces 2: 9, 1, 6, 3, 8
9, 3, 6 hit: 1, 8, 9, 3, 6
2 faults, replaces 1: 8, 9, 3, 6, 2
1 faults, replaces 8: 9, 3, 6, 2, 1
3 hit
Total = 5 + 4 = 9 faults
Both have 9 faults.
Answer: (A)
_________.
Answer: -1
Take the integrand . Put , so that .
The limits change too. The lower limit is now and the upper limit is now . The integral is now:
The antiderivative of is . Using the fundamental theorem of calculus, we get:
The limits change too. The lower limit is now and the upper limit is now . The integral is now:
The antiderivative of is . Using the fundamental theorem of calculus, we get:
Consider the following 2x2 matrix A where two elements are unknown and are marked by a and b. The eigenvalues of this matrix are -1 and 7. What are the values of a and b?
.
.
Answer: (D)
For the eigenvalues are and .
Trace = sum of eigenvalues: , so .
Determinant = product of eigenvalues: . Put in : , so .
Check: has trace 6 and determinant .
Answer: (D)
Trace = sum of eigenvalues: , so .
Determinant = product of eigenvalues: . Put in : , so .
Check: has trace 6 and determinant .
Answer: (D)
An algorithm performs find operations, insert operations, delete operations, and decrease-key operations on a set of data items with keys drawn from a linearly ordered set. For a delete operation, a pointer is provided to the record that must be deleted. For the decrease-key operation, a pointer is provided to the record that has its key decreased. Which one of the following data structures is the most suited for the algorithm to use, if the goal is to achieve the best total asymptotic complexity considering all the operations?
Answer: (A)
Add up the cost of all operations for each structure, with finds, N inserts, and deletes and decrease-keys.
Unsorted array: an insert is O(1), so N inserts cost O(N). A find scans the array, O(N), so finds cost . With a pointer, a delete (swap with the last element) and a decrease-key are O(1) each, so they cost in total. Total: .
Min-heap: an insert is O(log N) in the worst case, so N inserts cost . This is already more than the unsorted array. (A find still takes O(N) in a heap.)
Sorted array or sorted doubly linked list: an insert must find the position and shift or walk, O(N) each, so N inserts cost .
Since , the unsorted array is best.
Answer: (A)
Unsorted array: an insert is O(1), so N inserts cost O(N). A find scans the array, O(N), so finds cost . With a pointer, a delete (swap with the last element) and a decrease-key are O(1) each, so they cost in total. Total: .
Min-heap: an insert is O(log N) in the worst case, so N inserts cost . This is already more than the unsorted array. (A find still takes O(N) in a heap.)
Sorted array or sorted doubly linked list: an insert must find the position and shift or walk, O(N) each, so N inserts cost .
Since , the unsorted array is best.
Answer: (A)