0% found this document useful (0 votes)
11 views36 pages

Mock 41243 1712322751002

The document contains a series of multiple-choice questions related to computer science topics such as algorithms, data structures, operating systems, and programming. Each question presents a scenario or code snippet, followed by several answer options. The questions cover a range of concepts including knapsack problems, sorting algorithms, memory management, and graph theory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views36 pages

Mock 41243 1712322751002

The document contains a series of multiple-choice questions related to computer science topics such as algorithms, data structures, operating systems, and programming. Each question presents a scenario or code snippet, followed by several answer options. The questions cover a range of concepts including knapsack problems, sorting algorithms, memory management, and graph theory.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

www.byjusexamprep.

com

Mock Test Solutions in English

Questions

1. Consider the following table with weight of the items and their corresponding profit, Knapsack has capacity
50, the maximum profit that can be achieved through fractional Knapsack is using greedy algorithm
________.

A. 290 B. 320
C. 330 D. 350
2. Consider a system having ‘m’ resources of same type. These resources are shared by 4 processes P0,
P1, P2 and P3, which have peak demand 6, 9, 7 and 14 respectively. The maximum value of ‘m’, so
deadlock may occur ____.
A. 30 B. 32
C. 20 D. 33
3. Consider a n processes running on CPU without any deadlock. Each process need common resource to
execute successfully among n processes, 7 process requires maximum of 12 resources, remaining
process require maximum of 10 resources. Total 186 resources are available. How many maximum
number of processes are running in the CPU ?
4. Consider the C code given below:

#include <stdio.h>

#include <string.h>

void f(char * p) {

if (*p! = 0){

printf(“%c”, *p);
www.byjusexamprep.com

f(p + 1);

printf “%c”, *p);

int main()

char S[5] = “GATE”;

f(s);

return 0;

The output is _____ .


A. GATEGATE B. ETAGETAG
C. ETAGGATE D. GATEETAG
5. Which of the following statement(s) is/are true regarding the sorting?
A. The main advantage of bubble sort oven other
B. The bubble sort average-case time complexity for
sorting techniques is to detect whether the input is
n element is O(n2).
already sorted
C. The advantage of selection sort over other sorting
techniques is it does not require additional storage D. The selection sort is scalable.
space.
6. Consider the following C program:

# include<stdio.h>

int main ()

{
www.byjusexamprep.com

int a[] = {10, 20, 30, 40, 50};

int *p[] = {a+1, a, a+4, a+3, a+2};

int **ptr = p;

ptr++;

printf (“%d %d”, ++ptr-p, **ptr);

The output of the program is ____.


7. Consider an operating system having 64 bits virtual address space and 64 MB physical memory. If the
page size is 16 KB, what is the approximate size of the page table in PB(Petabytes)?
8. Consider the graph:

The number of topological sorts that are possible from the above graph is ____.
9. void main () {

int i = ‘a’;
www.byjusexamprep.com

switch(i)

case ‘a’:

printf(“Hello”);

case 97:

printf(“world”);

break;

default:

print(“nothing”);

What is the output of the code


A. Hello world B. World
C. nothing D. compile error
10. Consider the set of processes.

Assume that the processes are scheduled using the Longest non-pre-emptive Longest Job First(LJF)
algorithm. What are the average turnaround time and average waiting time?
A. 10,5 B. 9,8
www.byjusexamprep.com

C. 10,4 D. 9,5
11. Consider the following

code snippet

int a = 7, b = 6, c;

c = a>>2 + 3 * 8 == 8 * 8 + b;

printf(“%d”, c);

value printed by printf statement is


A. 1 B. 0
C. 2 D. 3
12. The number of bits required for encoding the message “IITBBITSIISC” using the Huffman coding
technique is?
13. The operating system provided with algorithm for managing concurrency, ensuring mutual exclusion, and
preventing deadlocks among the n processes and n number of resources in the system. That algorithm
typically involves appropriate synchronization protocol using these operating system primitives to allow
processes or threads to safely and efficiently access the shared resources chopsticks without conflicts or
deadlocks. Which of the following pseudocode represents the correct implementation of that algorithm that
provides the necessary synchronization mechanisms and services that can be used to devise a solution to
the problem to ensure proper resource allocation and synchronization in a concurrent system?

Note: take_resource(k) allocates the resource k

put_resource(k) releases the resource k


A. B.

void process { void process {

while(1) { while(1) {

Wait( take_resource[(i+1) % n] ) ; Signal( put_resource[i] );

Wait( take_resource[i] ); Signal( put_resource[ (i+1)] ) ;


www.byjusexamprep.com

. Perform task . Perform task

Signal( put_resource[ (i+1) % n] ) ; Wait( take_resource[i] );

Signal( put_resource[i] ); Wait( take_resource[(i+1)] ) ;

} }

} }
C. D.

void process { void process {

while(1) { while(1) {

Wait( take_resource[i] ); Wait( take_resource[i] );

Signal( put_resource[ (i+1) % n] ) ; Wait( take_resource[(i+1) % n] ) ;

. Perform task . Perform task

Wait( take_resource[(i+1) % n] ) ; Signal( put_resource[i] );

Signal( put_resource[i] ); Signal( put_resource[ (i+1) % n] ) ;

} }

} }
14. int * fun (int x)

int y = x + 10%

return (&y);

void main()
www.byjusexamprep.com

int * x;

x = fun (10);

printf(“%d”, *x);

What does above code prints?


A. 10 B. 20
C. 0 D. Runtime error
15. Consider two strings, A = “GATEEXAM” and B = “EXAMGATE”. Let x be the length of the longest common
subsequence (not necessarily contiguous) between A and B and let y be the number of such longest
common subsequences between A and B. Then x + 10y = ___.
16. Consider the following two-dimensional array D in the C programming language, which is stored in row-
major order:

int D[128][128];

Demand paging is used for allocating memory and each physical page frame holds 512 elements of the
array D. The Least Recently Used (LRU) page-replacement policy is used by the operating system. A total
of 30 physical page frames are allocated to a process which executes the following code snippet:

for (int i = 0; i < 128; i++)

for (int j = 0; j < 128; j++)

D[j][i] *= 10;

The number of page faults generated during the execution of this code snippet is _______.
17. Suppose there are two singly linked lists both of which intersect at some point and become a single linked
list. The head or start pointers of both the lists are known, but the intersecting node and lengths of lists are
not known.
www.byjusexamprep.com

What is worst case time complexity of optimal algorithm to find intersecting node from two intersecting
linked lists?
B. Θ(n2), where m>n and m, n are lengths of given
A. Θ(n*m), where m, n are lengths of given lists
lists
C. Θ(m+n), where m, n are lengths of given lists D. Θ(min(n, m)), where m, n are lengths of given lists
18. A file system with 512 GB disk uses a file descriptor with 16 direct block addresses, 1 indirect block
address, 1 doubly indirectly block address and 1 triple indirect block addresses. Size of each disk block is
256 bytes and the size of each disk block address is 8 bytes. The maximum possible file size is
__________ (in MB).
19. Consider the following page reference string with 3 frames:

2, 4, 3, 1, 5, 3, 2, 5, 3, 1, 4, 2

Number of page fault occurs if FIFO page replacement algorithm is used ________.
20. The following C function takes single linked list as parameter and rearranges the elements of the list. The
function is called with list containing integers 1, 2, 3, 4, 5, 6 in order.

What will be the content of the list after function completes execution?
A. 2, 1, 4, 3, 6, 5 B. 1, 3, 3, 5, 5, 6
www.byjusexamprep.com

C. 1, 1, 1, 1, 1, 6 D. 1, 1, 1, 1, 1, 1
21. Algorithms A and B use T (n) = c n log n and T (n) = c n2 elementary operations for a problem of size
A A 2 B B

n. Find the fastest algorithm for processing n = 220 data items if A and B spend 10 and 1 operations,
respectively, to process 210 items.
A. Algorithm A B. Algorithm B
C. Both are equal D. None
22. Consider the following pseudo code. (Assume that n > 1)

The output of the above pseudo code for x = 9 is _____.


23. Using open addressing with linear probing. We sequentially insert three distinct keys K1, K2, K3 into a
hash table of size m. Assuming simple uniform hashing. What is the probability that we will need three
probes, when inserting the third key K3?
A. 3/m2 B. 3/m3
C. m/k3 D. m/k2
24. Consider the following array of elements <40, 35, 20, 10, 15, 16, 17, 8, 4, 30>. The minimum number of
interchanges needed to convert it into a min-heap is _________ using built heap method.
25. A n-array tree has m leaf nodes. What is the total number of nodes in the n-array tree?
A. mn-1/ n-1 B. n-1/mn-1
C. m-1/ n-1 D. n-1
26. An OS uses virtual memory with demand paging. For each process OS reserves at least X number of
frames. X is either 5% OR 10% of total frames required by process, whichever is minimum. Consider there
are enough number of frames to meet the minimum reservation requirement of all processes and still
www.byjusexamprep.com

there are 4 extra frames which can be used by any process once all reserved frames are loaded with
pages by a process. Page size is 1 KB .

Following is the reference string in the form < Process, PageNo> in the sequence:

<P1,100>, <P1,101>, <P1,102>, <P2,103>, <P2,101>

<P2,100>, <P2,105>, <P2,106>, <P1,103>, <P1,101>

<P1,104>, <P1,105>, <P1,106>, <P3,102>, <P3,101>

<P3,100>, <P3,99>, <P3,98>, <P4,100>, <P4,101>, <P4,99>

<P1,106>, <P4,98>, <P2,106>, <P3,102>, <P3,99>, <P2,107>

The total number of page faults by all processes if LRU is used for page replacement is ____.
27. Consider the partially given function in the C programming language is used to find the median of two
sorted arrays A and B each of size n (n can be even or odd) but of same size:
median (A, B, a_low, a_high, b_low, b_high)

median (A, B, a_low, a_high, b_low, b_high)


{

a_mid = (a_low + a_high)/2;

b_mid = (b_low + b_high)/2;

if (a_low == a_high)

return min(A[a_low], 8[b_low)]

else if ((a_high — a_low) % 2 == 0)


www.byjusexamprep.com

if (A[a_mid] < B[(b_mid)]

return (S1);

else

return median (A, B, a_low, a_mid, B_low, b_mid);

else

if (A[a_mid] < 8[(b_mid)]

return median (A, B, a_low + 1, a_high, b_low, b_high - 1);

else

return (S2);

The missing argument lists are respectively


A. median ( , a_mid, a_high , b_low, b_mid)
and B. median ( , a_mid, a_high, b_mid, b_high) and
median ( , a_low, a_high median low, a_high , b_mid, high)
high)
C. median ( , a_mid, a_high, low, b_mid) and D. median ( , a_mid, a_high, b_low, b_mid) and
median , a_low, a_high median , a_mid, a_high , b_mid, high
high )
28. Which of the following permutations can be obtained in the output (in the same order) using a stack
assuming that the input is the sequence 5, 7, 8, 4, 6 in that order?
A. 6, 8, 4, 7, 5 B. 6, 4, 5, 7, 8
C. 6, 4, 7, 8, 5 D. 7, 8, 4, 6, 5
29. A quadratic algorithm with processing time T(n) = cn2 spends for processing N data items. How much time
will be spent for processing n = 5000 data items if N=100 and T(N) = 1ms?
A. 2500 B. 250
C. 5000 D. 1000
30. Suppose we have a graph with negative edge weights. We take the largest magnitude negative edge
www.byjusexamprep.com

weight –k and reset each edge weight w to w+k+1. Which of the following is true?
B. Minimum cost spanning trees in the original graph
A. Kruskal's algorithm will identify the same
will not correspond to minimum cost spanning trees
spanning tree on the new graph as on the old graph.
in the new graph.
C. Prim's algorithm will not work on the original D. There are more minimum cost spanning trees in
graph but will work on the modified graph. the modified graph than in the original graph
31. Consider an array consisting of the following elements in unsorted order (placed randomly), but 60 as first
element.
60, 80, 15, 95, 7, 12, 35, 90, 55
Quick sort partition algorithm is applied by choosing first element as pivot element. How many total
number of arrangements of array integers is possible preserving the effect of first pass of partition
algorithm.
A. 718 B. 720
C. 724 D. 728
32. The number of different orders are possible for elements 1, 2, 3, 4, 5, 6, 7 to be inserted in to empty AVL
tree such that no rotation will be done and element ‘4’ is root are ________.
33. Which of the following is the correct decomposition of the directed graph given below into its strongly
connected components?

A. {P, Q, R, S} {T} {U} {V} B. {P, Q, R, S, T, V} {U}


C. {P, Q, S, T, V} {R} {U} D. {P, Q, R, S, T, U, V}
34. Banker's algorithm is used by OS to avoid the deadlock. The following table shows the current allocation
and maximum demand by processes P1, P2, P3 & P4 for the instances of resources A, B and C.
www.byjusexamprep.com

There are still 2, 1, 2 instances of A, B and C are available respectively. Following requests are made by
processes in the sequence.

Request_1: P1 requests 1, 1, 1 of A, B and C respectively.

Request_2: P4 requests 1, 0, 1 of A, B and C respectively.

Which of these requests are granted?


A. Request_1 but not Request_2 B. Request_2 but not Request_1
C. Both are granted D. Neither are granted
35. In a connected and undirected graph of 200 vertices and 400 edges. The weight of MST of that graph is
600. When the weight of each edge of graph is increased by '4'. then weight of MST of graph becomes
________.
36. A binary tree T has n leaf nodes. The number of nodes of degree 2 in T is:
A. log2n B. n – 1
C. n D. 2n
37. Which of the following statement(s) is/are TRUE?

(i). Suppose that Dijkstra’s algorithm is run using a priority queue data structure for which insert and
decrease key operations take O(log V) time, the extract-min operation takes O(V) time, then the running
time of Dijkstra’s algorithm on a directed weighted graph G = (V, E) containing non-negative edges will be
O(V + E log V)

(ii). If a topological sort exists for the vertices in a directed graph, then a DFS on the graph will produce no
back edges.
A. None of the above B. Both (i) and (ii)
C. Only (i) D. Only (ii)
www.byjusexamprep.com

38. Consider the following set of processes with their arrival and CPU burst time.

What is the average waiting time of these processes when shortest job first policy is used ________?
39. Consider a computer system with 57-bit virtual addressing using multi-level tree-structured page tables
with L levels for virtual to physical address translation.

The page size is 4 KB (1 KB = 1024 B) and a page table entry at any of the levels occupies 8 bytes.

The value of L is ________.


40. Consider the following Expression tree

Each leaf represents a numerical value, which can either be 2 or


www.byjusexamprep.com

Over all possible choices of the values at the leaves, the minimum possible values of the expression
represented by the tree is _______.
www.byjusexamprep.com

Solutions

1. B
Sol.

Items is descending profit/weight are I1, I3, I5, I2, I4

First I1, I3, I5 is chosen.

Profit = 180 + 30 + 70

Weight = 20 + 5 + 15 = 40

Remaining weight = 50 – 40 = 10

Some fraction of I2 is inserted in Knapsack

Total profit = 180 + 30 + 70 + 40 = 320

2. B
Sol. (I) To avoid the deadlock the minimum resources required will be:

(II) Hence, to make the system go into deadlock, subtract one extra resource that we provided to start the
execution of any processes.
www.byjusexamprep.com

(III) If we give one more resource to any processes then one process must complete its execution and
release consumed resources and other processes to complete their execution subsequently.

So, maximum value of m = 5 + 8 + 6 + 13 = 32.


3. 19
Sol. The condition for deadlock free

⇒ r >= n (m – 1) + 1

r = no. or resources = 40

n = no. of process

m = max. no. of recourses required by process

7 process requires max of 12 resources

n – 6 process requires max of 10 resources.

186 ≥ 7 (12 – 1) + (n – 7) (10 – 1) + 1

186 ≥ 77 + 9n – 63 + 1

186 ≥ 15 + 9n

171 ≥ 9n

9n ≤ 171

n ≤ 19

4. D
Sol.
www.byjusexamprep.com

After tracking the above tree


output is GATEETAG
5. A,B,C
Sol. Option A is true. Bubble sort is one of the simplest sorting techniques, and perhaps the only advantage it
has over other techniques is that it can detect whether the input is already sorted.

Option B is true. The time complexity of bubble sort in the best case is O(n) and in the worst and average
case is O(n2).

Option C is true. Since selection sort is an in-place sorting algorithm, it does not require additional storage.

Option D is false. The selection sort is not scalable. As the input size increases, the performance of the
selection sort decreases.
6. 250
Sol. (I) Construction array a[] with elements 10, 20, 30, 40, 50.

Now,
www.byjusexamprep.com

(II) ptr++; ⇒ ptr will pointing to second element of array P.

++ptr – P = ((P + 1) + 1) – P = 2

So, above statement find the number of elements between the two pointers.(since unary operator has
higher precedence then binary operator).

(III) **ptr = *(*(P + 2)) = *(a + 4) = 50

Hence, output is 2, 50 which is 250.


7. 2
Sol. I. Page table size = (# entries in page table) × (page table entry size)
Now,
• Number of entries in page table

• Page size is equal to frame size


∴ Number of frames in physical memory

II. Now, frame bits to locate pages in physical memory = log2 212 = 12 bits
∴ Page table entry size = frame bits = 12 bits 2 bytes
III. Now, page table size = 250 * 21 bytes
= 251 bytes
= 2 Peta bytes.
www.byjusexamprep.com

8. 12
Sol. Since the given graph has 8 vertices.
So, the topological sort consists of order 8, that is:
A __ __ D __ __ __ H
The vertices A, D and H are fixed as there is no other choice. In the remaining vacant places, we have the
choices.
So, the number of topological sorts = 2!*3! = 2 × 6 = 12.

Hence, 12 topological sorts are possible.

9. D
Sol. case labels cannot be duplicate
and in the above code
case labels are duplicate
i.e.

and inside switch case labels cannot be same


so it will give error
∴ option D is correct.
10. A
Sol. Gantt chart.

Average waiting time

Average turnaround time

Therefore, option A is correct.


11. B
www.byjusexamprep.com

Sol. First arthmetic operation will execute


Second bitwise operator (>>)
This Relational operator (==)
c = 7>>2 + 3 * 8 = = 8 * 8 + 6
c = 7>>2 + 24 = = 8 * 8 + 6
c = 7 >> 24 = 64 + 6
c =7 >> 26 = = 70
c = 0 = = 70
c=0
∴ option B is correct.

12. 26
Sol. Given message:’IITBBITSIISC.”

Now, we identify the distinct characters and their frequency:

Now, we arrange these in ascending order and merge them using the optimal merge pattern and derive
the Huffman tree.
www.byjusexamprep.com

Total bits = Σ (frequency * No. of bits)

= (5 × 1) + (2 × 3) + (2 × 3) + (2 × 3) + (1 × 3)

= 5 + 6 + 6 + 6 + 3 = 26.

13. A,D
Sol. The problem defined in the question is Dining Philosopher problem with chopsticks

The correct implementation of Dining Philosopher problem with chopsticks is

void process {

while(1) {

Wait( take_resource[i] );

Wait( take_resource[(i+1) % n] ) ;

. Perform task

Signal( put_resource[i] );

Signal( put_resource[ (i+1) % n] ) ;

}
www.byjusexamprep.com

The code snippet provided represents the solution to the Dining Philosophers problem using the given
pseudocode. Let's break down the code and explain how it addresses the problem:

The code is inside an infinite loop, indicating that the philosopher process will keep repeating its actions
indefinitely.

The first Wait(take_resource[i]) call represents the philosopher trying to acquire the left chopstick. If the
chopstick is available, the philosopher proceeds to the next line; otherwise, it waits until the chopstick
becomes available.

The second Wait(take_resource[(i+1) % n]) call represents the philosopher attempting to acquire the right
chopstick. Similarly, it waits until the right chopstick becomes available.

After successfully acquiring both chopsticks, the philosopher can proceed to perform its task. This is
where the actual eating or any other action the philosopher needs to perform takes place.

Once the task is completed, the philosopher releases the left chopstick using Signal(put_resource[i]) and
the right chopstick using Signal(put_resource[(i+1) % n]). These signals indicate that the chopsticks are
now available for other philosophers to use.

After releasing the chopsticks, the philosopher enters the thinking state, which is not explicitly shown in
the given code snippet. The thinking state represents the period when the philosopher is not actively trying
to eat but instead contemplating or waiting for the next opportunity to eat.

This code follows a solution approach where the philosopher waits until both its left and right chopsticks
are available before proceeding to eat. By utilizing the provided synchronization primitives (such as Wait
and Signal), the code ensures that the philosophers acquire the necessary resources (chopsticks) without
causing conflicts or deadlocks.

So Option A and D are correct.


14. D
Sol. In above question we are returning the address of a local variable
∴ it is not valid it will throw an error
As we cannot return an address of a local variable
www.byjusexamprep.com

∴ option D is correct.
15. 24
Sol. The common subsequence of longest length is:

i. GATE

ii. EXAM

So, the length of such LCS is 4.

Now, x = 4 and y = 2.

Hence: x + 10y = 4 + 10 × 2 = 24.

16. 4096
Sol. Given that, 1 frame hold 512 Element,
Array size is 128 × 128 = 214 elements.

Hence, to hold array Total frames = 32 frames needed,


But, Given 30 frames only allocated to process, So, replacement occurs
1 frame can hold 512 elements ⇒ 4 rows.
Array is accessed column wise in the given code.
So, For each row, 1 fault occur initially.
D[0][0] fault ⇒ copy D[0][0] - [0] [127]
D[1][0] – [1][127]
D[2][0] – [2] [127]
D[3][0] – [3] [127] in a frame.
So, for 4 rows 1 fault.
But, as Array need Extra 2 frames they keep replacing frames in LRU order.
So, Total faults = Number of frames required for array * Number of columns.
= 32 × 128
= 25 × 27 = 4096
17. C
www.byjusexamprep.com

Sol. This takes Θ(m+n) time and O (1) space in the worst case, where M and N are the total lengths of the
linked lists.

1. Traverse the two linked lists to find m and n.

2. Get back to the heads, then traverse |m − n| nodes on the longer list.

3. Now walk in both the linked list and compare the nodes until you found the common ones.

So, option (C) is correct.

18. 8
Sol. Direct block addressing = 16 × 256 ⇒ 4 KB

Number of pointers in a block = 256 B / 8 B = 32.

Single indirect block addressing =32*256B

= 25 * 28 B

= 213 B ⇒ 8 KB

1 doubly indirect block addressing ⇒ 32*32*256B

= (25)2 * 28 B

= 210 * 28 B

⇒ 256 KB

1 triple indirect block addressing ⇒ 256/8=32*32*32*256B

= (25)3 * 28 B

= 215 * 28 B
www.byjusexamprep.com

⇒ 223 B

⇒ 8 MB

19. 10
Sol.

Total 10 page faults.


20. B
Sol. Consider the linked list:
www.byjusexamprep.com

Final output: 1, 3, 3, 5, 5, 6 after the function completes its execution.

21. A
Sol. T (210) = 10 ⇒ c = = 2–10
A A

TB(210) = 1 ⇒ cB = = 2–20

TA(220) = 2–10 . 20 . 220 = 20.210

TB(220) = 2–20 . 240 = 220

Algoritm B is taking more time in comparision to Algorithm A

so algorithm A is faster.

22. 3
Sol.
www.byjusexamprep.com

23. A
Sol. Here uniform hashing is given so even though its linear probing we won't reduce the size.
For K1 = m/m=1 (it can place anywhere)
For K2 = we have 3 possibilities above K1 below K1 or at same slot as K1 & the collision happen so here
probability is k2 = 3/m
So for K3 there is only one possibility = 1/m
So total probability = 1 * 3/m * 1/m = 3/m2.
So, option (A) is correct.
24. 7
Sol.

Constructing the Binary Tree,


www.byjusexamprep.com

In Build-heap method, it is assumed that the leaf nodes are satisfying heap property and heapify
procedure starts from second last level.

So, total 7 interchanges are done.


25. A
Sol. Let consider the number of internal nodes = k
Total nodes = k+m
For n-array tree number of leaf nodes with k internal nodes = (n-1)k +1
m= (n-1)k+1
k= m-1 / n-1
www.byjusexamprep.com

Total nodes
= (m-1 / n-1) + m
= (mn-1)/n-1
So, option (A) is correct.
26. 24
Sol. According to the question four frames are there, therefore we have first four-page fault as in the sequence
starting four pages are distinct.
After the 4 pages resides in the frame than another page comes in the sequence and replace the
<P1,100> with <P2,101> and the page fault becomes 5.
As in the sequence no page is repeating in the four pages therefore the total number of pages fault is 24.
27. A
Sol. To find the median of two sorted arrays A and B each of size n(n can be even or odd) but of
same size:
median ( , a_mid, a_high , b_low, b_mid) and
median ( , a_low, a_high high)
Option A is the correct answer.
28. D
Sol.

(a)6, 8, 4, 7, 5 :

After popping element 6, only 4 can be popped, hence this permutation is not possible.

(b)6, 4, 5, 7, 8 :
www.byjusexamprep.com

After performing the pop operation on elements 6, 4 now only element 8 can be popped. Hence, this
permutation is not possible.

(c)6, 4, 7, 8, 5 :

After 6, 4 elements are popped, now element 7 can only be popped if and only if 8 has already been
popped. Hence, this permutation is not possible.

(d)7, 8, 4, 6, 5 :

Hence, the option D is correct as we get the output as the order mentioned in the option.
29. A
Sol.
T(n) = c.n2
N=100, T(N)= 1ms
1ms = c*(100)2
Now, n= 5000
T(n)= (1/ (100)2) * (5000)2
=2500 ms.
So, option (A) is correct.
30. A
Sol. The ascending order of edge weights is unchanged if each edge weight is increased by k+1,
so Kruskal's algorithm runs exactly the same way as before and produces the same tree. In
www.byjusexamprep.com

general, since every spanning tree has exactly n-1 edges, the increase in weight uniformly
affects all spanning trees, so the minimum cost of spanning trees are unchanged. Prim's
algorithm is not affected by negative weights
So, option (A) is correct.
31. B
Sol. We have to choose first element as pivot.
Here 60 is given as first element.
After first pass, the pivot element goes to it’s exact location.
Here 60 goes to 6th place.
All the elements less than 60 go to left of 60 and all the elements greater than 60 go to right
of 60.
After 1st pass

⟹ 720 possible arrangements.


32. 48
Sol. Since 4 is root element , so

(1, 3, 5, 7) can be inserted in any order since these are leaf nodes. However, 6 needs to be inserted
before 5 and 7 and 2 needs to be inserted before 1 and 3.
4 being the root node, needs to be inserted first of all.
2 and 6 can be inserted in 2! Ways, leaf nodes 1,3,5,7 can be inserted in 4! Ways.
Total Possibilities = 2! * 4! = 2* 24= 48
33. B
Sol. If then i and j belongs to same strongly connected components where i and j are
vertices and means there is a path from i to j.
www.byjusexamprep.com

Solving by elimination

Option (d): P (U → T) does not exists thus false.

Option (c) : From R we can reach P Q V S T and from P Q V S T we can reach R thus R should not be
separated thus false.
34. A
Sol. If we allocate 1, 1, 1 to P1 then the current availability will be 1, 0, 1.

with this availability, we can have a safe sequence as P2, P3, P1, P4.

Therefore, the request is granted.

For request_2, P4 need for resource C is 0, but it is requesting

1 instance of C. Thus, it’s not granted.

35. 1396
Sol. Given that |V| = 200

|E| = 400

And weight of MST = 600

By using properties of MST, every MST contain (V - 1) number of edges. So, we have 199 edges in MST.

Total increase of weight of MST = 600 + (199 × 4) = 600 + 796 = 1396


36. B
Sol. Now for a degree 2 node, every time 2 leaf nodes are added, then the number of nodes with degree 2
increases by 1.

Thus, number of nodes with degree 2 is always one less than number of leaf nodes present in tree.

So, nodes of degree 2 in T = n - 1.


www.byjusexamprep.com

37. B
Sol. (i). There are V extract-min operations, and E decreases key operations for Dijkstra’s
algorithm using a priority queue. So, the time complexity is O(V + E log V)
(ii). Both parts of the statement hold if and only if the graph is acyclic.
So, option (B) is correct.
38. 3
Sol.

39. 5
Sol.
www.byjusexamprep.com

• Page table size


= No. of PTE’s * PTE size
= 245 * 8 bytes = 248 bytes …(1)

• To store 248 bytes page table, No. of pages required =


236 pages, page table size
= 236 PTE’s * 8 bytes
= 239 bytes …(2)
• To store 239 bytes table, page required

=
227 pages, page table size
= 227 PTE’s * 8 bytes
= 230 bytes …(3)

• 230 bytes table is divided into


• 218 pages, page table size = 218 PTE’s * 8 bytes = 221 bytes …(4)

• 221 bytes table is divided into


29 pages, page table size = 29 * 8 bytes = 212 bytes …(5)
Hence, it can be stored in one frame of main memory.
So, number of levels of paging, L = 5
40. 6
Sol. Minimum Expanded as
((2+2)-(3-2))+((2-3)+(2+2))=6

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy