The PYQ practice room
GATE CS 2021 Set 1
All 65 solved GATE CS 2021 Set 1 questions in exam order. Open a question, commit to an answer, and learn from the step-by-step solution. One question at a time.
Go beyond PYQs with Success TrackerAI-powered personalised practice and doubt support. Unlimited practice on eligible plans; AI usage limits apply.Questions
65
Paper marks
100
Question formats
3
MCQ · NAT · MSQ
Revision mode
Self-paced
No timer. Focus on understanding.
Explore the questions
General Aptitude (GA)
91
Q1MCQ1 markEasyThe ratio of boys to girls in a class is 7 to 3. Among the options below, an acceptable value for the total number of students in the class is:Think it through. Then check your answer.Question
The ratio of boys to girls in a class is 7 to 3.Among the options below, an acceptable value for the total number of students in the class is:Correct answer
(C) 50
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Given the ratio of boys to girls is .
Let the number of boys be and the number of girls be , where is a positive integer.
The total number of students = .
This implies that the total number of students must be a multiple of 10.Checking the options:
(A) 21 is not divisible by 10.
(B) 37 is not divisible by 10.
(C) 50 is divisible by 10 ().
(D) 73 is not divisible by 10.Thus, 50 is an acceptable value for the total number of students.2
Q2MCQ1 markEasyA polygon is convex if, for every pair of points, P and Q belonging to the polygon, the line segment PQ lies completely inside or on the polygon. Which one of the following is…Think it through. Then check your answer.Question
A polygon is convex if, for every pair of points, P and Q belonging to the polygon, the line segment PQ lies completely inside or on the polygon.Which one of the following is NOT a convex polygon?Correct answer
(A) [figure]
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
A convex polygon is defined as a polygon where the line segment connecting any two points inside the polygon lies entirely within the polygon. Equivalently, all interior angles are less than 180 degrees.- Option (A) shows a polygon with an indentation (a reflex angle > 180 degrees). A line segment connecting points on opposite sides of the indentation would pass outside the polygon. Thus, it is concave (not convex).
- Option (B) is a triangle, which is always convex.
- Option (C) is a square/rectangle, which is convex.
- Option (D) is a trapezoid, which is convex.
3
Q3MCQ1 markEasyConsider the following sentences: (i) Everybody in the class is prepared for the exam. (ii) Babu invited Danish to his home because he enjoys playing chess. Which of the following…Think it through. Then check your answer.Question
Consider the following sentences:(i) Everybody in the class is prepared for the exam.
(ii) Babu invited Danish to his home because he enjoys playing chess.Which of the following is the CORRECT observation about the above two sentences?Correct answer
(C) (i) is grammatically correct and (ii) is ambiguous
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Sentence (i): "Everybody in the class is prepared for the exam." This sentence is grammatically correct. 'Everybody' is a singular indefinite pronoun and takes the singular verb 'is'.Sentence (ii): "Babu invited Danish to his home because he enjoys playing chess." This sentence is ambiguous because the pronoun "he" could refer to either Babu or Danish. It is unclear who enjoys playing chess.Therefore, (i) is grammatically correct and (ii) is ambiguous.4
Q4MCQ1 markMediumA circular sheet of paper is folded along the lines in the directions shown. The paper, after being punched in the final folded state as shown and unfolded in the reverse order of…Think it through. Then check your answer.Question
A circular sheet of paper is folded along the lines in the directions shown. The paper, after being punched in the final folded state as shown and unfolded in the reverse order of folding, will look like ______.
Correct answer
(A) [figure]
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The folding process is as follows:1.The circle is folded vertically (right to left) to form a semicircle.2.The semicircle is folded horizontally (top to bottom) to form a quadrant.3.The quadrant is folded along the diagonal to form a triangular shape (an octant).The punching involves:1.A cut at the vertex corresponding to the center of the circle. This unfolds to a square hole in the center.2.A square cut on the vertical edge. This edge corresponds to the vertical fold from step 1. A cut on a fold opens up to a hole on the axis. Since this edge is the boundary of the folded shape, the cut appears on the vertical axis.3.A square cut on the horizontal edge. This edge corresponds to the horizontal fold from step 2. A cut here opens up to a hole on the horizontal axis.Unfolding:- The center cut becomes a central square hole.
- The cut on the vertical edge (which is a fold) unfolds to a hole on the vertical axis. Due to symmetry across the horizontal fold, this appears on both the top and bottom vertical radii.
- The cut on the horizontal edge (which is a fold) unfolds to a hole on the horizontal axis. Due to symmetry across the vertical fold, this appears on both the left and right horizontal radii.
5
Q5MCQ1 markEasy____ is to surgery as writer is to ____ Which one of the following options maintains a similar logical relation in the above sentence?Think it through. Then check your answer.Question
____ is to surgery as writer is to ____Which one of the following options maintains a similar logical relation in the above sentence?Correct answer
(C) Doctor, book
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The analogy is based on the relationship: Professional : Primary Work/Output.- Doctor performs surgery.
- Writer writes a book.
(A) Plan is a preparatory step, not the agent.
(B) Hospital is a place, not the agent.
(D) Medicine is a field, not the agent.6
Q6MCQ2 marksMediumWe have 2 rectangular sheets of paper, M and N, of dimensions 6 cm x 1 cm each. Sheet M is rolled to form an open cylinder by bringing the short edges of the sheet together. Sheet…Think it through. Then check your answer.Question
We have 2 rectangular sheets of paper, M and N, of dimensions 6 cm x 1 cm each. Sheet M is rolled to form an open cylinder by bringing the short edges of the sheet together. Sheet N is cut into equal square patches and assembled to form the largest possible closed cube. Assuming the ends of the cylinder are closed, the ratio of the volume of the cylinder to that of the cube is __________Correct answer
(C) (9)/(π)
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Let's analyze the formation of the cylinder and the cube separately.1. Cylinder from Sheet M:- The dimensions of sheet M are 6 cm x 1 cm.
- It is rolled by bringing the short edges (1 cm) together.
- This means the height of the cylinder will be the length of the short edge, so cm.
- The circumference of the base of the cylinder will be the length of the long edge, so cm.
- The formula for the circumference of a circle is , where is the radius.
- So, cm.
- The volume of a cylinder is given by the formula .
- Substituting the values of and :
- The dimensions of sheet N are 6 cm x 1 cm.
- The total area of sheet N is cm².
- This sheet is used to form the largest possible closed cube.
- A closed cube has 6 identical square faces.
- Let the side length of the cube be 'a'. The area of one face is .
- The total surface area of the cube is .
- The material for this surface area comes from sheet N. So, the total surface area of the cube must be equal to the area of the sheet.
- cm.
- We can cut six 1 cm x 1 cm square patches from a 6 cm x 1 cm rectangular sheet.
- The volume of the cube is given by the formula .
- Substituting the value of :
- The required ratio is the volume of the cylinder to the volume of the cube.
- Ratio = .
7
Q7MCQ2 marksMediumItems | Cost (₹) | Profit % | Marked Price (₹) |---|---|---|---| | P | 5,400 | --- | 5,860 | | Q | --- | 25 | 10,000 | Details of prices of two items P and Q are presented in the…Think it through. Then check your answer.Question
Details of prices of two items P and Q are presented in the above table. The ratio of cost of item P to cost of item Q is 3:4. Discount is calculated as the difference between the marked price and the selling price. The profit percentage is calculated as the ratio of the difference between selling price and cost, to the costThe discount on item Q, as a percentage of its marked price, is ________Items Cost (₹) Profit % Marked Price (₹) P 5,400 --- 5,860 Q --- 25 10,000 Correct answer
(C) 10
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Given:1.Cost of item P () = 5,400.2.Ratio of cost of P to Q is . So, .3.Profit % for Q is 25%. Selling Price of Q () = .4.Marked Price of Q () = 10,000.Discount on Q = .
Discount % = .8
Q8MCQ2 marksMediumThere are five bags each containing identical sets of ten distinct chocolates. One chocolate is picked from each bag. The probability that at least two chocolates are identical is…Think it through. Then check your answer.Question
There are five bags each containing identical sets of ten distinct chocolates. One chocolate is picked from each bag.The probability that at least two chocolates are identical is ________Correct answer
(C) 0.6976
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Let be the number of distinct chocolates in each bag, so .
Let be the number of bags, so .
Since each bag contains the same set of distinct chocolates, picking one from each is equivalent to picking a sequence of length 5 from 10 items with replacement allowed.
Total number of outcomes = .We want the probability that at least two chocolates are identical. It is easier to calculate the complement: the probability that all chocolates are distinct.
Number of ways to pick 5 distinct chocolates from 10 types = .Probability (all distinct) = .Probability (at least two identical) = .9
Q9MCQ2 marksHardGiven below are two statements 1 and 2, and two conclusions I and II. Statement 1: All bacteria are microorganisms. Statement 2: All pathogens are microorganisms. Conclusion I:…Think it through. Then check your answer.Question
Given below are two statements 1 and 2, and two conclusions I and II.Statement 1: All bacteria are microorganisms.
Statement 2: All pathogens are microorganisms.Conclusion I: Some pathogens are bacteria.
Conclusion II: All pathogens are not bacteria.Based on the above statements and conclusions, which one of the following options is logically CORRECT?Correct answer
(C) Either conclusion I or II is correct.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Let be the set of bacteria, be the set of pathogens, and be the set of microorganisms.From Statement 1: All bacteria are microorganisms .
From Statement 2: All pathogens are microorganisms .We are analyzing the relationship between and . Since both are subsets of , they might be disjoint (), they might overlap (), or one might be a subset of the other. The premises do not force any specific relationship between and .Conclusion I: "Some pathogens are bacteria" implies . This does not necessarily follow.
Conclusion II: "All pathogens are not bacteria" is standardly interpreted in syllogisms as "No pathogens are bacteria" (). This does not necessarily follow.However, the two conclusions are contradictories (assuming is not empty): either and have a non-empty intersection (Conclusion I) or they have an empty intersection (Conclusion II). One of these must be true. Therefore, logically, Either conclusion I or II is correct.Note: The official GATE 2021 answer key accepts both (C) and (D). Option (D) is valid if one interprets the question as asking which conclusion deductively follows from the premises (neither does). Option (C) is valid if one considers the logical truth that one of the two complementary possibilities must hold.
Computer Science and Information Technology (CS, Set-1)
5610
Q10MCQ2 marksEasySome people suggest anti-obesity measures (AOM) such as displaying calorie information in restaurant menus. Such measures sidestep addressing the core problems that cause obesity:…Think it through. Then check your answer.Question
Some people suggest anti-obesity measures (AOM) such as displaying calorie information in restaurant menus. Such measures sidestep addressing the core problems that cause obesity: poverty and income inequality.Which one of the following statements summarizes the passage?Correct answer
(D) AOM are addressing the problem superficially.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The passage states that Anti-Obesity Measures (AOM) like displaying calorie information "sidestep addressing the core problems" (poverty and income inequality).1.Option (A) claims AOM addresses core problems, which directly contradicts the passage.2.Option (B) suggests obesity causes poverty, whereas the passage implies poverty causes obesity ("problems that cause obesity: poverty").3.Option (C) claims AOM addresses core problems, which contradicts the passage.4.Option (D) states AOM addresses the problem superficially. Since the measures ignore the "core problems" and focus on secondary aspects like menus, they are by definition superficial.Therefore, Option (D) is the correct summary.11
Q11MCQ1 markEasySuppose that is a regular language and is a context-free language. Which one of the following languages is NOT necessarily context-free?Think it through. Then check your answer.Question
Suppose that is a regular language and is a context-free language. Which one of the following languages is NOT necessarily context-free?Correct answer
(C) L₁ - L₂
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Let's analyze the closure properties for each option:- (A) : The intersection of a regular language and a context-free language is always a context-free language.
- (B) : The concatenation of a regular language and a context-free language is always a context-free language.
- (D) : The union of a regular language and a context-free language is always a context-free language.
- (C) : This can be written as . Since context-free languages are not closed under complementation, is not necessarily context-free. Therefore, the intersection of a regular language and a non-context-free language is not necessarily context-free. For example, if and is a context-free language whose complement is not context-free, then is not context-free.
12
Q12MCQ1 markMediumLet be an array containing integers. Let be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values…Think it through. Then check your answer.Question
Let be an array containing integers. Let be the lowest upper bound on the number of comparisons of the array elements, required to find the minimum and maximum values in an arbitrary array of elements. Which one of the following choices is correct?Correct answer
(C) t n and t ≤ 3 (n)/(2)
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The optimal number of comparisons required to find both the minimum and maximum elements in an array of size is given by:- If is even:
- If is odd:
13
Q13MCQ1 markMediumConsider the following three functions. Which one of the following options arranges the functions in the increasing…Think it through. Then check your answer.Question
Consider the following three functions.Which one of the following options arranges the functions in the increasing order of asymptotic growth rate?Correct answer
(D) f₂, f₃, f₁
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
To compare the growth rates, we can take the logarithm of each function:
Therefore, the increasing order of growth rate is:14
Q14MCQ1 markEasyConsider the following statements. : The sequence of procedure calls corresponds to a preorder traversal of the activation tree. : The sequence of procedure returns…Think it through. Then check your answer.Question
Consider the following statements.
: The sequence of procedure calls corresponds to a preorder traversal of the activation tree.
: The sequence of procedure returns corresponds to a postorder traversal of the activation tree.Which one of the following options is correct?Correct answer
(C) S₁ is true and S₂ is true
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
In an activation tree, each node represents an activation of a procedure.1.A procedure call corresponds to entering a node in the tree. Since we visit a node before its children in a preorder traversal, the sequence of calls corresponds to a preorder traversal.2.A procedure return corresponds to leaving a node after all its sub-calls (children) have completed. This matches the definition of a postorder traversal, where a node is visited after all its descendants.Therefore, both and are true.15
Q15MCQ1 markMediumConsider the following statements. : Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1). : For any context-free grammar,…Think it through. Then check your answer.Question
Consider the following statements.
: Every SLR(1) grammar is unambiguous but there are certain unambiguous grammars that are not SLR(1).
: For any context-free grammar, there is a parser that takes at most time to parse a string of length .Which one of the following options is correct?Correct answer
(C) S₁ is true and S₂ is true
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
is true: All LR parsers, including SLR(1), can only handle unambiguous grammars. However, the class of SLR(1) grammars is a proper subset of unambiguous grammars (e.g., some unambiguous grammars are LR(1) but not SLR(1)).
is true: General parsing algorithms like the Cocke-Younger-Kasami (CYK) algorithm or Earley's algorithm can parse any context-free grammar in time, where is the length of the input string.16
Q16MCQ1 markEasyLet the representation of a number in base 3 be 210. What is the hexadecimal representation of the number?Think it through. Then check your answer.Question
Let the representation of a number in base 3 be 210. What is the hexadecimal representation of the number?Correct answer
(A) 15
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Step 1: Convert the base 3 number to decimal.Step 2: Convert the decimal number to hexadecimal.
Divide 21 by 16:
Quotient = 1, Remainder = 5.
So, .The hexadecimal representation is 15.17
Q17MCQ1 markEasyLet and be two propositions. Consider the following two formulae in propositional logic. …Think it through. Then check your answer.Question
Let and be two propositions. Consider the following two formulae in propositional logic.Which one of the following choices is correct?Correct answer
(B) S₁ is a tautology but S₂ is not a tautology.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Using distributive law: .
So is . Since is true only when is true, the implication is always true. Thus, is a tautology..
If is true and is true, then becomes . Thus, is not a tautology.18
Q18MCQ1 markEasyConsider the following two statements. : Destination MAC address of an ARP reply is a broadcast address. : Destination MAC address of an ARP request is a broadcast…Think it through. Then check your answer.Question
Consider the following two statements.
: Destination MAC address of an ARP reply is a broadcast address.
: Destination MAC address of an ARP request is a broadcast address.Which one of the following choices is correct?Correct answer
(C) S₁ is false and S₂ is true.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
: An ARP reply is a unicast message sent directly to the requester. Its destination MAC address is the specific MAC address of the host that sent the ARP request. Therefore, is false.
: An ARP request is a broadcast message because the requester does not know which host has the target IP address. Its destination MAC address is the broadcast address (FF:FF:FF:FF:FF:FF). Therefore, is true.19
Q19MCQ1 markMediumConsider the following array. | 23 | 32 | 45 | 69 | 72 | 73 | 89 | 97 | |----|----|----|----|----|----|----|----| Which algorithm out of the following options uses the least…Think it through. Then check your answer.Question
Consider the following array.Which algorithm out of the following options uses the least number of comparisons (among the array elements) to sort the above array in ascending order?23 32 45 69 72 73 89 97 Correct answer
(C) Insertion sort
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The given array is already sorted in ascending order. Let .
(A) Selection sort: Always performs comparisons regardless of the initial order.
(B) Mergesort: Always performs comparisons. For , it is approximately comparisons.
(C) Insertion sort: For an already sorted array, it only performs comparisons (one for each element from the second onwards to check against its predecessor).
(D) Quicksort (last element as pivot): For a sorted array, this is the worst-case scenario, resulting in comparisons.
Insertion sort uses the least number of comparisons.20
Q20MCQ1 markEasyA binary search tree contains distinct elements. What is the time complexity of picking an element in that is smaller than the maximum element in ?Think it through. Then check your answer.Question
A binary search tree contains distinct elements. What is the time complexity of picking an element in that is smaller than the maximum element in ?Correct answer
(D) Θ(1)
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
To find an element smaller than the maximum in a Binary Search Tree (BST) with distinct elements ():1.Check the root. If the root has a right child, then the root is smaller than the maximum element (which would be in the right subtree). Return the root.2.If the root does not have a right child, then the root is the maximum element. Since , the root must have a left child. The left child (and any node in the left subtree) is smaller than the root. Return the left child.Both checks and operations take constant time . Thus, the time complexity is .21
Q21MSQ1 markMediumIn the context of operating systems, which of the following statements is/are correct with respect to paging?Think it through. Then check your answer.Question
In the context of operating systems, which of the following statements is/are correct with respect to paging?Correct answer
(A) Paging helps solve the issue of external fragmentation.; (C) Paging incurs memory overheads.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
(A) Correct: Paging allocates memory in fixed-size frames, which eliminates external fragmentation because any free frame can be allocated to a process needing a page.
(B) Incorrect: Page size directly impacts internal fragmentation. On average, the last page of a process is half-filled. Larger page sizes lead to more internal fragmentation.
(C) Correct: Paging requires data structures like page tables to map logical addresses to physical addresses. These tables consume memory, creating overhead.
(D) Incorrect: Multi-level paging is primarily used to reduce the memory size of the page table itself for large address spaces, not necessarily to support pages of different sizes (though some architectures might, it is not the defining necessity).22
Q22MSQ1 markMediumLet denote an encoding of an automaton . Suppose that . Which of the following languages is/are NOT recursive?Think it through. Then check your answer.Question
Let denote an encoding of an automaton . Suppose that . Which of the following languages is/are NOT recursive?Correct answer
(D) L = \ M M is a PDA such that L(M) = Σ^ \
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
We analyze the decidability (recursiveness) of each language:
(A) Emptiness of a DFA is decidable. We can check reachability from the start state to any final state. Thus, is recursive.
(B) Universality of a DFA () is decidable. We can construct the complement DFA and check if . Thus, is recursive.
(C) Emptiness of a PDA is decidable. We can convert the PDA to a Context-Free Grammar (CFG) and check if the start symbol generates any terminal string. Thus, is recursive.
(D) Universality of a PDA () is undecidable. The problem of determining whether a CFG generates all strings is undecidable. Thus, is NOT recursive.The question asks for languages that are NOT recursive.23
Q23MSQ1 markMediumSuppose a database system crashes again while recovering from a previous crash. Assume checkpointing is not done by the database either during the transactions or during recovery.…Think it through. Then check your answer.Question
Suppose a database system crashes again while recovering from a previous crash. Assume checkpointing is not done by the database either during the transactions or during recovery.
Which of the following statements is/are correct?Correct answer
(A) The same undo and redo list will be used while recovering again.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The correct answer is (A).Reasoning:1.Idempotence of Recovery: Database recovery processes (such as ARIES) are designed to be idempotent. This means that if the system crashes during the recovery phase, the recovery process can simply be restarted from the beginning (or the last valid checkpoint) without causing inconsistency. The end result will be the same as if the recovery had succeeded on the first attempt.2.Log Invariance: The transaction log is stored on stable storage. When the system crashes during recovery, the log records from the original transactions remain unchanged. Since no new user transactions are processed during recovery, the history of operations to be analyzed remains the same.3.Absence of Checkpoints: The question states that no checkpointing is done. This forces the recovery process to scan the log from the beginning (or the start of the earliest uncommitted transaction) every time it restarts.4.Same Lists: Because the log content is identical and the starting point is the same, the Analysis Phase of the recovery algorithm will identify the exact same set of "winner" (to be redone) and "loser" (to be undone) transactions. Consequently, the undo and redo lists constructed will be identical to those from the previous (failed) recovery attempt.Thus, the system can recover successfully, operations will be re-applied/undone as necessary (idempotently), and consistency will be restored.24
Q24MSQ1 markMediumWhich of the following standard C library functions will always invoke a system call when executed from a single-threaded process in a UNIX/Linux operating system?Think it through. Then check your answer.Question
Which of the following standard C library functions will always invoke a system call when executed from a single-threaded process in a UNIX/Linux operating system?Correct answer
(A) exit; (C) sleep
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
A system call is a mechanism for a user-level process to request a service from the operating system's kernel.- (A) exit: The
exit()function terminates the process. This requires kernel intervention to deallocate resources (memory, file descriptors, process control block, etc.) and update system-wide data structures. Therefore,exit()must make a system call (e.g.,exitorexit_groupin Linux). - (B) malloc: The
malloc()function is a C library function for dynamic memory allocation. It manages a region of memory on the heap for the process. It requests large chunks of memory from the kernel using system calls likebrkormmapand then dispenses smaller pieces to the application from this pool. If a suitable free block is already available in its managed pool,malloc()can satisfy a request without making a system call. A system call is only made when the library's internal pool is exhausted and needs to be expanded. Thus,malloc()does not always invoke a system call. - (C) sleep: The
sleep()function suspends the process's execution for a specified duration. Process scheduling (putting a process to sleep and waking it up) is a fundamental kernel responsibility. The process must make a request to the kernel to be removed from the ready queue and be woken up later. This always requires a system call (e.g.,nanosleep). - (D) strlen: The
strlen()function computes the length of a string. The string resides in the process's own address space. The function simply reads memory from the starting address until it finds a null terminator. This entire operation is performed in user space and does not require any kernel services. Thus,strlen()never invokes a system call.
exitandsleepare the functions that will always invoke a system call.- (A) exit: The
25
Q25MSQ1 markMediumConsider a linear list based directory implementation in a file system. Each directory is a list of nodes, where each node contains the file name along with the file metadata,…Think it through. Then check your answer.Question
Consider a linear list based directory implementation in a file system. Each directory is a list of nodes, where each node contains the file name along with the file metadata, such as the list of pointers to the data blocks. Consider a given directoryfoo.
Which of the following operations will necessarily require a full scan offoofor successful completion?Correct answer
(A) Creation of a new file in foo; (C) Renaming of an existing file in foo
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The directory is a linear list of entries, which is not specified as being sorted. We need to determine which operations require scanning the entire list for successful completion.- (A) Creation of a new file in
foo: To create a new file, the file system must ensure that a file with the same name does not already exist in the directoryfoo. Since the list is unsorted, the only way to guarantee uniqueness is to search the entire list from beginning to end. If a duplicate is found, the creation fails. If no duplicate is found after checking all entries, the new file entry can be added. Thus, a full scan is necessary for successful creation. - (B) Deletion of an existing file from
foo: To delete a file, the system searches the list for the file's entry. If the file is found, say at the beginning or in the middle of the list, its entry is removed, and the operation is successfully completed. The search can stop as soon as the file is found. A full scan is only needed in the worst case (the file is the last entry) or if the file does not exist. It is not necessarily required for a successful deletion. - (C) Renaming of an existing file in
foo: Renaming a file fromold_nametonew_nameis a composite operation. It involves:
old_name. This part, like deletion, doesn't necessarily require a full scan.
2. Ensuring thatnew_namedoes not already exist in the directory to avoid a name collision. This check for uniqueness, just like in file creation, requires a full scan of the entire linear list.
Therefore, the overall renaming operation necessarily requires a full scan to guarantee correctness.- (D) Opening of an existing file in
foo: Opening a file requires finding its entry in the directory to access its metadata (e.g., location of data blocks). Similar to deletion, the search can stop as soon as the entry is found. A full scan is not necessary if the file is not the last item in the list. Thus, a full scan is not necessarily required for a successful open.
- (A) Creation of a new file in
26
Q26NAT1 markEasyIn an undirected connected planar graph , there are eight vertices and five faces. The number of edges in is _______.Think it through. Then check your answer.Question
In an undirected connected planar graph , there are eight vertices and five faces. The number of edges in is _______.Correct answer
11 to 11
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
For a connected planar graph, Euler's formula is given by , where is the number of vertices, is the number of edges, and is the number of faces.
Given:
Substituting these values into the formula:
Thus, the number of edges in is 11.27
Q27NAT1 markMediumConsider the following undirected graph with edge weights as shown: [figure] The number of minimum-weight spanning trees of the graph is _______.Think it through. Then check your answer.Question
Consider the following undirected graph with edge weights as shown:The number of minimum-weight spanning trees of the graph is _______.
Correct answer
3 to 3
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
To find the number of minimum-weight spanning trees (MSTs), we consider the edges with the minimum weight, which is 0.1.
Let the vertices be labeled as follows:
Top row:
Bottom row: From the graph, the edges with weight 0.1 are:1.2.3.4.5. (diagonal)6. (diagonal)There are 6 edges with weight 0.1. Let's check for cycles among these edges:- The edges form a cycle of length 3.
- No other cycles are formed by these 6 edges, and they connect all 6 vertices.
- Removing leaves a tree.
- Removing leaves a tree.
- Removing leaves a tree.
28
Q28NAT1 markEasyThe lifetime of a component of a certain type is a random variable whose probability density function is exponentially distributed with parameter . For a randomly picked…Think it through. Then check your answer.Question
The lifetime of a component of a certain type is a random variable whose probability density function is exponentially distributed with parameter . For a randomly picked component of this type, the probability that its lifetime exceeds the expected lifetime (rounded to decimal places) is ___________.Correct answer
0.35 to 0.39
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The probability density function (PDF) of an exponential distribution with parameter is given by:Given the parameter .The expected lifetime (mean) of an exponential distribution is:We need to find the probability that the lifetime exceeds the expected lifetime :The probability for an exponential distribution is given by the survival function:Substituting and :Calculating the numerical value:Rounding to decimal places, we get . The official answer key provides an acceptable range of to .29
Q29NAT1 markMediumThere are 6 jobs with distinct difficulty levels, and 3 computers with distinct processing speeds. Each job is assigned to a computer such that: - The fastest computer gets the…Think it through. Then check your answer.Question
There are 6 jobs with distinct difficulty levels, and 3 computers with distinct processing speeds. Each job is assigned to a computer such that:- The fastest computer gets the toughest job and the slowest computer gets the easiest job.
- Every computer gets at least one job.
Correct answer
65 to 65
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Let the jobs be ordered by difficulty (toughest to easiest).
Let the computers be ordered by speed (fastest to slowest).Constraints:1.Fastest computer () gets toughest job ().2.Slowest computer () gets easiest job ().3.Every computer gets at least one job.Analysis:- already has .
- already has .
- currently has 0 jobs.
- Remaining jobs to assign: (4 distinct jobs).
- Remaining computers available: .
.30
Q30NAT1 markEasyConsider the following expression. The value of the above expression (rounded to 2 decimal places) is __________.Think it through. Then check your answer.Question
Consider the following expression.The value of the above expression (rounded to 2 decimal places) is __________.Correct answer
0.25 to 0.25
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Let .Substitute :
Numerator:
Denominator:
Since the limit is in the form , we can apply L'Hopital's Rule.Differentiate numerator and denominator with respect to :
Numerator:
Denominator: Now, evaluate the limit again:31
Q31NAT1 markEasyConsider the following sequence of operations on an empty stack. [code] Consider the following sequence of operations on an empty queue. [code] The value of s + q is __________.Think it through. Then check your answer.Question
Consider the following sequence of operations on an empty stack.Consider the following sequence of operations on an empty queue.push(54); push(52); pop(); push(55); push(62); s = pop();The value of s + q is __________.enqueue(21); enqueue(24); dequeue(); enqueue(28); enqueue(32); q = dequeue();Correct answer
86 to 86
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Stack Operations (LIFO - Last In First Out):1.push(54)Stack: [54]2.push(52)Stack: [54, 52] (Top is 52)3.pop()Removes 52. Stack: [54]4.push(55)Stack: [54, 55]5.push(62)Stack: [54, 55, 62] (Top is 62)6.Queue Operations (FIFO - First In First Out):s = pop()Removes 62. s = 62. Stack: [54, 55]1.enqueue(21)Queue: [21]2.enqueue(24)Queue: [21, 24] (Front is 21)3.dequeue()Removes 21. Queue: [24]4.enqueue(28)Queue: [24, 28]5.enqueue(32)Queue: [24, 28, 32] (Front is 24)6.Result:q = dequeue()Removes 24. q = 24. Queue: [28, 32]32
Q32NAT1 markEasyConsider a computer system with a byte-addressable primary memory of size bytes. Assume the computer system has a direct-mapped cache of size 32 KB…Think it through. Then check your answer.Question
Consider a computer system with a byte-addressable primary memory of size bytes. Assume the computer system has a direct-mapped cache of size 32 KB ( bytes), and each cache block is of size 64 bytes.
The size of the tag field is __________ bits.Correct answer
17 to 17
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
To find the size of the tag field in a direct-mapped cache, we first determine the total number of bits in the memory address and how they are partitioned.1.Total Address Bits: The primary memory is bytes and is byte-addressable. Therefore, the physical address size is bits.2.Block Offset Bits: The cache block size is 64 bytes, which is bytes. The number of bits required for the block offset is bits.3.Index Bits: The total cache size is 32 KB, which is bytes.The number of blocks (lines) in the cache is:
In a direct-mapped cache, the number of index bits is bits.4.Tag Bits: The physical address is divided into [Tag | Index | Offset].Therefore, the size of the tag field is 17 bits.33
Q33NAT1 markMediumA relation in a relational database has 1200 tuples. The attribute has integer values ranging from 6 to 20, and the attribute has integer values ranging from 1…Think it through. Then check your answer.Question
A relation in a relational database has 1200 tuples. The attribute has integer values ranging from 6 to 20, and the attribute has integer values ranging from 1 to 20. Assume that the attributes and are independently distributed.The estimated number of tuples in the output of is ___________.Correct answer
819 to 820
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Total number of tuples .
Attribute ranges from 6 to 20. Total distinct values = .
Attribute ranges from 1 to 20. Total distinct values = .
Probability (values are 11, 12, ..., 20).
Probability .
Since and are independent, the probability of the disjunction is:
.
Estimated number of tuples = .34
Q34NAT1 markMediumConsider the following representation of a number in IEEE 754 single-precision floating point format with a bias of 127.…Think it through. Then check your answer.Question
Consider the following representation of a number in IEEE 754 single-precision floating point format with a bias of 127.Here and denote the sign, exponent and fraction components of the floating point representation.The decimal value corresponding to the above representation (rounded to 2 decimal places) is ___________.Correct answer
-7.75
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
To find the decimal value of the given IEEE 754 single-precision floating point representation:1.Identify the components:- Sign bit (): . Since , the number is negative.
- Biased Exponent (): . Converting this to decimal:
- Fraction (): . This represents the fractional part of the mantissa.
The bias for single-precision is .
.3.Calculate the mantissa ():In normalized form, the mantissa is .
.4.Calculate the final decimal value:
.The decimal value is .35
Q35NAT1 markEasyThree processes arrive at time zero with CPU bursts of 16, 20 and 10 milliseconds. If the scheduler has prior knowledge about the length of the CPU bursts, the minimum achievable…Think it through. Then check your answer.Question
Three processes arrive at time zero with CPU bursts of 16, 20 and 10 milliseconds. If the scheduler has prior knowledge about the length of the CPU bursts, the minimum achievable average waiting time for these three processes in a non-preemptive scheduler (rounded to nearest integer) is ________ milliseconds.Correct answer
12 to 12
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
To minimize the average waiting time in a non-preemptive scheduler, the Shortest Job First (SJF) scheduling algorithm is optimal.Given CPU bursts: ms, ms, ms.Order of execution (SJF):1. (10 ms)2. (16 ms)3. (20 ms)Waiting times:- starts at 0. Waiting time ms.
- starts after finishes (at 10). Waiting time ms.
- starts after finishes (at ). Waiting time ms.
36
Q36MCQ2 marksMediumConsider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT) actions, given as pseudo-code:…Think it through. Then check your answer.Question
Consider the following grammar (that admits a series of declarations, followed by expressions) and the associated syntax directed translation (SDT) actions, given as pseudo-code:With respect to the above grammar, which one of the following choices is correct?P -> D* E* D -> int ID {record that ID.lexeme is of type int} D -> bool ID {record that ID.lexeme is of type bool} E -> E1 + E2 {check that E1.type = E2.type = int; set E.type := int} E -> !E1 {check that E1.type = bool; set E.type := bool} E -> ID {set E.type := int}Correct answer
(B) The actions can be used to type-check syntactically correct integer variable declarations and integer expressions.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Analyze the SDT actions:- The rule
E -> ID {set E.type := int}unconditionally sets the type of any identifier expression toint, regardless of how the identifier was declared (even though the declaration rules record the correct type). - Integer expressions: If we have an expression like
x + y,xandyare reduced toEwith typeint. The ruleE -> E1 + E2checks if operands areint, which they are. This works correctly for integers. - Boolean expressions: If we have an expression like
!bwherebis a boolean variable,bis reduced toEviaE -> ID, settingE.typetoint. The ruleE -> !E1checks ifE1.typeisbool. Since it isint, the type check fails.
- The rule
37
Q37MCQ2 marksMediumThe following relation records the age of 500 employees of a company, where (indicating the employee number) is the key: Consider the following…Think it through. Then check your answer.Question
The following relation records the age of 500 employees of a company, where (indicating the employee number) is the key:Consider the following relational algebra expression:What does the above expression generate?Correct answer
(C) Employee numbers of all employees whose age is not the minimum.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Let be the relation .
The expression is , where is a copy of renamed with attributes .The join condition selects tuples from where the employee's age is strictly greater than the age of some employee in (which is just ).- If an employee has the minimum age in the company, there is no employee such that . Thus, employees with the minimum age will NOT be selected.
- If an employee has an age greater than the minimum, there exists at least one employee (the one with minimum age) such that . Thus, all such employees will be selected.
38
Q38MCQ2 marksMediumConsider a 3-bit counter, designed using T flip-flops, as shown below: Assuming the initial state of the counter given by PQR as 000, what are the next three states? [figure]Think it through. Then check your answer.Question
Consider a 3-bit counter, designed using T flip-flops, as shown below:Assuming the initial state of the counter given by PQR as 000, what are the next three states?
Correct answer
(A) 011, 101, 000
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The circuit consists of three T flip-flops () with outputs . The T inputs are all connected to logic 1 (implied by the common rail usually connected to ). The clocking arrangement is:- is clocked by the external Clock Pulse.
- is clocked by the output of the first flip-flop.
- is clocked by the inverted output of the second flip-flop.
- sees a rising edge. Since , toggles: .
- The clock input of is . Since goes (rising edge), triggers. Since , toggles: .
- The clock input of is . Since goes , goes (falling edge). does not trigger. holds: .
- Next State: .
- sees a rising edge. toggles: .
- clock () goes (falling edge). does not trigger. holds: .
- clock () sees no change (since held). holds: .
- Intermediate State: . (Note: This state appears in the sequence but might be skipped in the options or considered transient if the question implies a specific sampling. However, let's check the next toggle).
- sees a rising edge. toggles: .
- clock () goes (rising edge). triggers. toggles: .
- clock () goes (rising edge, since went ). triggers. toggles: .
- Next State: .
- sees rising edge. toggles: .
- clock () sees falling edge. Holds.
- clock () sees no change. Holds.
- Intermediate State: .
- sees rising edge. toggles: .
- clock () sees rising edge. toggles: .
- clock () sees falling edge. Holds.
- Next State: .
39
Q39MCQ2 marksMediumAssume that a 12-bit Hamming codeword consisting of 8-bit data and 4 check bits is , where the data bits and the check bits are given in the…Think it through. Then check your answer.Question
Assume that a 12-bit Hamming codeword consisting of 8-bit data and 4 check bits is , where the data bits and the check bits are given in the following tables:Data bitsCheck bits1 1 0 0 1 0 1 Which one of the following choices gives the correct values of and ?0 1 0 Correct answer
(A) x is 0 and y is 0.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
In a standard Hamming code, the check bits are located at positions that are powers of 2 (). The given sequence is . Mapping these to positions 12 down to 1 (left to right):- Position 12:
- Position 11:
- Position 10:
- Position 9:
- Position 8:
- Position 7:
- Position 6:
- Position 5:
- Position 4:
- Position 3:
- Position 2:
- Position 1:
Bits:
Values:
Sum for even parity: .Check bit (Position 2): Checks positions with the 2nd bit set (2, 3, 6, 7, 10, 11).
Bits:
Values:
Sum: . (Consistent)Check bit (Position 4): Checks positions with the 3rd bit set (4, 5, 6, 7, 12).
Bits:
Values:
Sum: . (Consistent)Check bit (Position 8): Checks positions with the 4th bit set (8, 9, 10, 11, 12).
Bits:
Values:
Substituting :
Sum for even parity: .Thus, and .40
Q40MCQ2 marksMediumConsider the following recurrence relation. Which one of the following…Think it through. Then check your answer.Question
Consider the following recurrence relation.Which one of the following options is correct?Correct answer
(C) T(n) = Θ(n)
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The given recurrence relation is for . This is a divide-and-conquer recurrence of the form .1.Identify parameters: Here, and . The work done at each level is .2.Check the sum of coefficients:3.Apply Generalized Master Theorem / Akra-Bazzi: Since the sum of the coefficients , the work done at the root level, , dominates the recurrence. Specifically, if and , then .4.Conclusion: Since , the complexity is .Alternatively, using the substitution method, we can show that for some constant , proving . Since is trivial due to the term, we have .41
Q41MCQ2 marksMediumConsider the following context-free grammar where the set of terminals is . …Think it through. Then check your answer.Question
Consider the following context-free grammar where the set of terminals is .The following is a partially-filled LL(1) parsing table.Which one of the following choices represents the correct combination for the numbered cells in the parsing table ("blank" denotes that the corresponding cell is empty)?S (1) (2) T (3) (4) R Correct answer
(A) (1) S arrow R f (2) S arrow R f (3) T arrow ε (4) T arrow ε
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
To determine the entries in the LL(1) parsing table, we first compute the FIRST and FOLLOW sets for the non-terminals.Grammar:1.2.3.4.5.6.7.Step 1: Compute FIRST sets- (from rules 6, 7)
- (from rules 3, 4, 5)
- So,
- contains (start symbol).
- From , .
- From , .
- From , .
- From , . Since , .
- From , .
- From , .
- . Also .
- .
- Thus, .
- Cell (1):
- Look at . . So add .
- Cell (2):
- Look at . . So add .
- Cell (3):
- Look at . Since , add .
- Cell (4):
- Look at . Since , add .
- (1)
- (2)
- (3)
- (4)
42
Q42MCQ2 marksMediumLet and denote read and write operations respectively on a data item by a transaction . Consider the following two schedules.…Think it through. Then check your answer.Question
Let and denote read and write operations respectively on a data item by a transaction . Consider the following two schedules.Which one of the following options is correct?Correct answer
(B) S₁ is not conflict serializable, and S₂ is conflict serializable.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
A schedule is conflict serializable if its precedence graph (also known as serializability graph) is acyclic. The precedence graph contains a node for each transaction. An edge is drawn from transaction to () if an operation in conflicts with a subsequent operation in . Two operations conflict if they are on the same data item, belong to different transactions, and at least one of them is a write operation.Analysis of Schedule :
Let's find the conflicting pairs of operations:1. and : comes before . This creates an edge .2. and : comes before . This creates an edge .The precedence graph for has a cycle: . Therefore, is not conflict serializable.Analysis of Schedule :
Let's find the conflicting pairs of operations:1. and : comes before . This creates an edge .2. and : comes before . This creates an edge .The precedence graph for has only one directed edge . Since the graph is acyclic, is conflict serializable. It is equivalent to the serial schedule .Based on the analysis, is not conflict serializable, and is conflict serializable. This corresponds to option (B).43
Q43MCQ2 marksMediumConsider the relationR(P, Q, S, T, X, Y, Z, W)with the following functional dependencies. Consider…Think it through. Then check your answer.Question
Consider the relationR(P, Q, S, T, X, Y, Z, W)with the following functional dependencies.Consider the decomposition of the relation into the constituent relations according to the following two decomposition schemes.Which one of the following options is correct?Correct answer
(A) D₁ is a lossless decomposition, but D₂ is a lossy decomposition.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
A decomposition is lossless if for every pair of joined relations and , the common attributes form a superkey for at least one of the relations ( or ).Given FDs:1.PQ → X2. andP → X3.Q → Y4. andAnalyzing Decomposition :Y → W
Relations: , , , .1.Join and :- Common attribute: .
- From FD
Y → ZW, is a key for . - Join is lossless. Result: .
- Common attributes: .
- From FD
P → X, we can inferPT → X. Thus, is a superkey for . - Join is lossless. Result: .
- Common attribute: .
- From FD
Q → YandY → ZW, by transitivityQ → YZW. Thus, is a key for . - Join is lossless.
Relations: , , , .1.Join and is lossless (same as above). Result: .2.Join and is lossless (common ,Q → YZW). Result: .3.Join and :- Common attributes: None.
- The intersection is empty. A join with no common attributes is a Cartesian product, which is inherently lossy in this context (we cannot reconstruct the original tuples reliably).
44
Q44MCQ2 marksMediumLet be a group of order 6, and be a subgroup of such that . Which one of the following options is correct?Think it through. Then check your answer.Question
Let be a group of order 6, and be a subgroup of such that . Which one of the following options is correct?Correct answer
(B) G may not be cyclic, but H is always cyclic.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
To determine the correct option, we analyze the properties of the group and its subgroup based on their orders.1. Analysis of the Subgroup
We are given that is a subgroup of and its order satisfies:By Lagrange's Theorem, the order of a subgroup must divide the order of the group. Since , the possible values for are the divisors of strictly between and . Thus:Since both and are prime numbers, the order of is prime.
A well-known theorem in group theory states that every group of prime order is cyclic. Therefore, must be cyclic.2. Analysis of the Group
The group has order . Up to isomorphism, there are exactly two groups of order 6:1.The cyclic group (which is abelian and cyclic).2.The symmetric group (which is non-abelian and non-cyclic).Since can be isomorphic to , is not always cyclic (i.e., may not be cyclic).Conclusion
- may not be cyclic (e.g., when ).
- is always cyclic because its order is a prime number ( or ).
45
Q45MCQ2 marksMediumConsider the two statements. : There exist random variables and such that :…Think it through. Then check your answer.Question
Consider the two statements.
: There exist random variables and such that: For all random variables and ,Which one of the following choices is correct?Correct answer
(D) Both S₁ and S₂ are false.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
To determine the correctness of the statements and , we analyze them individually using the principles of probability theory.---Analysis of Statement
The term inside the square on the left-hand side of the inequality is the covariance of and :$\text{Cov}[X, Y] = \text{E}[(X - \text{E}[X])(Y - \text{E}[Y])]$Thus, the inequality in can be written as:$(\text{Cov}[X, Y])^2 > \text{Var}[X] \text{Var}[Y]$By the Cauchy-Schwarz inequality for random variables, for any two real-valued random variables and with finite second moments:$(\text{E}[UV])^2 \le \text{E}[U^2] \text{E}[V^2]$Setting and , we get:$(\text{E}[(X - \text{E}[X])(Y - \text{E}[Y])])^2 \le \text{E}[(X - \text{E}[X])^2] \text{E}[(Y - \text{E}[Y])^2]$Since and , this simplifies to:$(\text{Cov}[X, Y])^2 \le \text{Var}[X] \text{Var}[Y]$This inequality holds universally for all random variables and . Therefore, it is impossible for any random variables and to satisfy:$(\text{Cov}[X, Y])^2 > \text{Var}[X] \text{Var}[Y]$Thus, is false.---Analysis of Statement
Statement asserts that for all random variables and :$\text{Cov}[X, Y] = \text{E}[|X - \text{E}[X]| |Y - \text{E}[Y]|]$Let us test this statement with a counterexample. Let and be two random variables such that , where is a non-constant random variable. For simplicity, let be a standard normal random variable, . Then:- and .
- and .
1.Left-Hand Side (LHS):$ \text{Cov}[X, Y] = \text{E}[XY] = \text{E}[X(-X)] = -\text{E}[X^2] = -1$2.Right-Hand Side (RHS):$ \text{E}[|X - \text{E}[X]| |Y - \text{E}[Y]|] = \text{E}[|X| |-X|] = \text{E}[|X|^2] = \text{E}[X^2] = 1$Since and , we have . Thus, the equality does not hold for all random variables, which means is false.---Conclusion
Both statements and are false.Correct Option: D46
Q46MCQ2 marksMediumLet be an undirected unweighted connected graph. The diameter of is defined as:…Think it through. Then check your answer.Question
Let be an undirected unweighted connected graph. The diameter of is defined as:Let be the adjacency matrix of .
Define graph on the same set of vertices with adjacency matrix , whereWhich one of the following statements is true?Correct answer
(A) diam(G₂) ≤ diam(G)/2
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
To find the relationship between the diameter of the original graph and the modified graph , we analyze the definition of the adjacency matrix of .1. Understanding the Construction of
Let denote the shortest path distance between vertices and in , and denote the shortest path distance in .The adjacency matrix of is defined as:N_{ij} = 1 \iff M_{ij} > 0 \quad \text{or} \quad (M^2)_{ij} > 0 \quad (\text{for } i $\neq$ j)- means there is a path of length between and in .
- means there is a path of length between and in .
2. Relationship Between Distances in and
Let and be any two vertices in . Suppose the shortest path between and in has length .
We can write this path as a sequence of vertices:where for all .We can construct a shorter path in by skipping every alternate vertex:- Since , there is an edge between and in .
- Since , there is an edge between and in .
- In general, for any even step, .
3. Relating the Diameters
The diameter of a graph is the maximum of the shortest path distances between any pair of vertices. Let be the pair of vertices in that realizes the diameter of :$\text{diam}(G_2) = d_{G_2}(u^*, v^*)$Using the inequality derived above:$\text{diam}(G_2) = d_{G_2}(u^*, v^*) \le \lceil d_G(u^*, v^*) / 2 \rceil$Since is at most the diameter of (), we have:$\text{diam}(G_2) \le \lceil \text{diam}(G) / 2 \rceil$This inequality holds strictly or with equality for all connected undirected graphs. Therefore, Option A is the correct statement.47
Q47MCQ2 marksMediumConsider the following ANSI C program. [code] Which one of the following options is correct?Think it through. Then check your answer.Question
Consider the following ANSI C program.Which one of the following options is correct?#include <stdio.h> int main() { int i, j, count; count = 0; i = 0; for (j = -3; j <= 3; j++) { if ((j >= 0) && (i++)) count = count + j; } count = count + i; printf("%d", count); return 0; }Correct answer
(B) The program will compile successfully and output 10 when executed.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Let's trace the execution of the program:1.Initializecount = 0andi = 0.2.The loop runs for .3.Inside the loop, the condition is(j >= 0) && (i++). Due to short-circuit evaluation of&&:- For :
j >= 0is false.i++is not executed.countremains 0. - For :
j >= 0is true.i++is executed. The post-increment returns the old value ofi(which is 0).true && 0is false.ibecomes 1.countremains 0. - For :
j >= 0is true.i++is executed. It returns 1.true && 1is true.ibecomes 2.count = 0 + 1 = 1. - For :
j >= 0is true.i++is executed. It returns 2.true && 2is true.ibecomes 3.count = 1 + 2 = 3. - For :
j >= 0is true.i++is executed. It returns 3.true && 3is true.ibecomes 4.count = 3 + 3 = 6.
count = count + i = 6 + 4 = 10.5.The program outputs 10.- For :
48
Q48MCQ2 marksEasyConsider the following language. Which one of the following deterministic finite automata accepts ?Think it through. Then check your answer.Question
Consider the following language.Which one of the following deterministic finite automata accepts ?Correct answer
(D) [figure]
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The language consists of all strings over that end with the substring . To construct a DFA for this language, the states typically represent the longest suffix of the input string read so far that matches a prefix of .Let the states be:- : No part of the suffix has been matched (or the last symbol was but not preceded by ).
- : The string ends in .
- : The string ends in .
- : The string ends in (accepting state).
- From : input , input .
- From : input , input .
- From : input (since ends in ), input .
- From : input (since ends in ), input (since ends in ).
49
Q49MCQ2 marksMediumFor a Turing machine , denotes an encoding of . Consider the following two languages.…Think it through. Then check your answer.Question
For a Turing machine , denotes an encoding of . Consider the following two languages.Which one of the following options is correct?Correct answer
(A) Both L₁ and L₂ are decidable.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
To determine if a Turing machine takes more than 2021 steps on an input , we only need to simulate on for at most 2022 steps. Crucially, if takes more than 2021 steps, it can only read at most the first 2021 symbols of the input tape. Therefore, the behavior of for the first 2021 steps depends only on the first 2021 symbols of the input. Since the input alphabet is finite, there are only a finite number of input prefixes of length 2021 (specifically, ).- For : We can check all inputs of length up to 2021. If takes steps on all of them, it will take steps on any input (as any longer input shares a prefix that was already checked). This is a finite check, so is decidable.
- For : Similarly, we can check all inputs of length up to 2021. If takes steps on at least one of them, then is satisfied. This is also a finite check, so is decidable.
50
Q50MSQ2 marksMediumDefine to be the maximum amount earned by cutting a rod of length meters into one or more pieces of integer length and selling them. For , let denote the…Think it through. Then check your answer.Question
Define to be the maximum amount earned by cutting a rod of length meters into one or more pieces of integer length and selling them. For , let denote the selling price of a rod whose length is meters. Consider the array of prices:Which of the following statements is/are correct about ?Correct answer
(A) R₇ = 18; (C) R₇ is achieved by three different solutions.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The rod cutting problem can be solved using dynamic programming with the recurrence relation , where .Given the prices: .Calculating values step-by-step:- .
1.From : (a single piece of length 7)2.From : (two pieces of lengths 1 and 6)3.From : (three pieces of lengths 2, 2, and 3)Note: also yields , which is the same set as above. Similarly, yields .There are exactly 3 different solutions. Option (C) is correct.Since is a valid solution consisting of three pieces, option (D) is incorrect.51
Q51MSQ2 marksMediumAn articulation point in a connected graph is a vertex such that removing the vertex and its incident edges disconnects the graph into two or more connected components. Let …Think it through. Then check your answer.Question
An articulation point in a connected graph is a vertex such that removing the vertex and its incident edges disconnects the graph into two or more connected components.
Let be a DFS tree obtained by doing DFS in a connected undirected graph . Which of the following options is/are correct?Correct answer
(B) Root of T is an articulation point in G if and only if it has 2 or more children.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Standard properties of DFS trees in undirected graphs:
(A) False. The root is an articulation point if it has at least two children in the DFS tree.
(B) True. This is a well-known property: the root of a DFS tree is an articulation point iff it has more than one child.
(C) False. A leaf in a DFS tree of an undirected graph can never be an articulation point because all edges are either tree edges or back edges, and removing a leaf cannot disconnect the graph.
(D) False. While is an articulation point, it doesn't necessarily separate all its descendants from its ancestors. It only separates descendants in subtrees that have no back-edges to ancestors of . If is in a subtree that has a back-edge to , then there is a path from to not passing through .52
Q52MSQ2 marksMediumConsider the following Boolean expression. Which of the following Boolean expressions is/are equivalent to …Think it through. Then check your answer.Question
Consider the following Boolean expression.Which of the following Boolean expressions is/are equivalent to (complement of )?Correct answer
(B) XY + Z; (C) (X + Z)(Y + Z); (D) XY + YZ + XYZ
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Given the Boolean expression:Step 1: Simplify the expression for
Using the distributive law :Since :Expanding the product:Since and :Factoring out :Since :Step 2: Find the complement
Using De Morgan's laws:Step 3: Evaluate the given options- Option (A): is the dual of , not the complement. It is not equivalent to .
- Option (B): is exactly the simplified form of . Thus, it is correct.
- Option (C): . Thus, it is correct.
- Option (D): . Thus, it is correct.
53
Q53MSQ2 marksMediumA relation R is said to be circular if and together imply . Which of the following options is/are correct?Think it through. Then check your answer.Question
A relation R is said to be circular if and together imply . Which of the following options is/are correct?Correct answer
(C) If a relation S is reflexive and circular, then S is an equivalence relation.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
An equivalence relation must be reflexive, symmetric, and transitive.1.Option (A): Reflexive and symmetric does not imply transitivity. For example, on set , is reflexive and symmetric but not transitive as but .2.Option (B): Circular and symmetric implies transitivity (), but not necessarily reflexivity on the entire domain. If , it is circular and symmetric but not reflexive.3.Option (C): If is reflexive and circular:- Symmetry: Let . Since is reflexive, holds. Then by circularity. So is symmetric.
- Transitivity: Let . By circularity, holds. Since is symmetric, . So is transitive.
- Since it is also reflexive, is an equivalence relation.
54
Q54MSQ2 marksHardA TCP server application is programmed to listen on port number on host . A TCP client is connected to the TCP server over the network. Consider that while the TCP…Think it through. Then check your answer.Question
A TCP server application is programmed to listen on port number on host . A TCP client is connected to the TCP server over the network. Consider that while the TCP connection was active, the server machine crashed and rebooted. Assume that the client does not use the TCP keepalive timer. Which of the following behaviors is/are possible?Correct answer
(A) If the client was waiting to receive a packet, it may wait indefinitely.; (B) The TCP server application on S can listen on P after reboot.; (C) If the client sends a packet after the server reboot, it will receive a RST segment.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
When a server crashes and reboots, all active connection states (TCBs) are lost.- (A) is possible: Without a keepalive timer, if the client is simply waiting for data, it has no mechanism to detect that the server has crashed and will continue to wait indefinitely.
- (B) is possible: After the machine reboots, the server application can be restarted and bind to the same port to listen for new connections.
- (C) is possible: If the client sends a segment for the old connection, the rebooted server will have no record of it. According to TCP specifications, receiving a segment for an unknown connection results in the server sending a RST (Reset) segment to the client.
- (D) is impossible: A FIN segment is used for a graceful shutdown of an established connection. Since the server has lost all state, it cannot initiate a graceful close for a connection it doesn't recognize.
55
Q55MSQ2 marksHardConsider two hosts and connected through a router . The maximum transfer unit (MTU) value of the link between and is 1500 bytes, and between and is 820…Think it through. Then check your answer.Question
Consider two hosts and connected through a router . The maximum transfer unit (MTU) value of the link between and is 1500 bytes, and between and is 820 bytes. A TCP segment of size 1400 bytes was transferred from to through , with IP identification value as 0x1234. Assume that the IP header size is 20 bytes. Further, the packet is allowed to be fragmented, i.e., Don't Fragment (DF) flag in the IP header is not set by . Which of the following statements is/are correct?Correct answer
(A) Two fragments are created at R and the IP datagram size carrying the second fragment is 620 bytes.; (C) If the second fragment is lost, P is required to resend the whole TCP segment.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
1.Datagram Analysis:- TCP segment size = 1400 bytes.
- IP header = 20 bytes.
- Total IP datagram size from to = bytes.
- MTU of link = 820 bytes.
- Maximum payload per fragment = bytes (which is a multiple of 8).
- Fragment 1: Payload = 800 bytes, Total size = 820 bytes, Offset = 0, MF = 1.
- Fragment 2: Payload = bytes, Total size = bytes, Offset = 100, MF = 0.
- Thus, (A) is correct.
- IP is an unreliable protocol; routers do not retransmit lost fragments. Thus, (B) is incorrect.
- If any fragment is lost, the destination cannot reassemble the datagram. TCP at the source () will eventually timeout and retransmit the entire original segment. Thus, (C) is correct.
- The TCP header (containing port numbers) is only present in the first fragment (offset 0). Subsequent fragments do not contain the TCP header. Thus, (D) is incorrect.
56
Q56MSQ2 marksHardConsider the following pseudocode, where is a semaphore initialized to 5 in line#2 and counter is a shared variable initialized to 0 in line#1. Assume that the increment…Think it through. Then check your answer.Question
Consider the following pseudocode, where is a semaphore initialized to 5 in line#2 and counter is a shared variable initialized to 0 in line#1. Assume that the increment operation in line#7 is not atomic.If five threads execute the function parop concurrently, which of the following program behavior(s) is/are possible?1. int counter = 0; 2. Semaphore S = init(5); 3. void parop(void) 4. { 5. wait(S); 6. wait(S); 7. counter++; 8. signal(S); 9. signal(S); 10.}Correct answer
(A) The value of counter is 5 after all the threads successfully complete the execution of parop.; (B) The value of counter is 1 after all the threads successfully complete the execution of parop.; (D) There is a deadlock involving all the threads.
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
1.Deadlock Analysis: Each thread requires 2 units of the semaphore to proceed past line 6. The semaphore is initialized to 5. If all 5 threads execute line 5 concurrently, they each acquire 1 unit, reducing to 0. Consequently, all 5 threads will block at line 6, waiting for a unit that will never be released. Thus, a deadlock is possible. (Option D is correct).2.Counter Value Analysis: If the threads do not deadlock (e.g., they execute sequentially or in a manner that allows some to finish), they will each attempt to increment the counter.- Since the increment
counter++is not atomic (it involves a read, increment, and write), standard race conditions apply. - If they execute sequentially, the final value will be 5. (Option A is correct).
- If they execute concurrently, a thread might read the initial value 0, then other threads finish their increments (bringing the counter to 4), and finally the first thread writes back its calculated value (0 + 1 = 1). Thus, the final value can be 1. (Option B is correct).
- A value of 0 is impossible if all threads successfully complete, as at least one write-back of a value must occur. (Option C is incorrect).
- Since the increment
57
Q57MSQ2 marksHardConsider a dynamic hashing approach for 4-bit integer keys: 1. There is a main hash table of size 4. 2. The 2 least significant bits of a key is used to index into the main hash…Think it through. Then check your answer.Question
Consider a dynamic hashing approach for 4-bit integer keys:1.There is a main hash table of size 4.2.The 2 least significant bits of a key is used to index into the main hash table.3.Initially, the main hash table entries are empty.4.Thereafter, when more keys are hashed into it, to resolve collisions, the set of all keys corresponding to a main hash table entry is organized as a binary tree that grows on demand.5.First, the least significant bit is used to divide the keys into left and right subtrees.6.To resolve more collisions, each node of the binary tree is further sub-divided into left and right subtrees based on the least significant bit.7.A split is done only if it is needed, i.e., only when there is a collision.Consider the following state of the hash table.
Which of the following sequences of key insertions can cause the above state of the hash table (assume the keys are in decimal notation)?Correct answer
(C) 10, 9, 6, 7, 5, 13
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The hashing scheme uses the 2 least significant bits (LSB) for the main table index. Collisions are resolved by building a tree using the LSB, and then the LSB if needed.Analyzing the given state:- Index 00: Empty. No keys end in
00. - Index 01: Points to a tree. The root (split on bit) has a left child (0) and a right child (1). The right child is further split (on bit) into left (0) and right (1).
- This implies: One key with bit 0. Two keys with bit 1 (one with bit 0, one with bit 1).
- Index 10: Points to a tree. The root (split on bit) has a left child (0) and a right child (1). Both are leaves.
- This implies: One key with bit 0. One key with bit 1.
- Index 11: Points to a single leaf node.
- This implies: One key ending in
11.
Let's convert keys to 4-bit binary:- 10 (): Ends in
10. bit is 0. Goes to Index 10, Left branch. - 9 (): Ends in
01. bit is 0. Goes to Index 01, Left branch. - 6 (): Ends in
10. bit is 1. Goes to Index 10, Right branch. - 7 (): Ends in
11. Goes to Index 11. - 5 (): Ends in
01. bit is 1. Goes to Index 01, Right branch. ( bit is 0). - 13 (): Ends in
01. bit is 1. Goes to Index 01, Right branch. ( bit is 1).
- Index 00: Empty. (Matches)
- Index 01: Contains 9 (), 5 (), 13 (). The collision between 5 and 13 on the bit forces a split on the bit. (Matches diagram)
- Index 10: Contains 10 () and 6 (). Split on bit. (Matches diagram)
- Index 11: Contains 7. (Matches diagram)
- (A) Contains 4 (), which would go to Index 00. The diagram shows Index 00 is empty.
- (B) Contains 1 () and 9 (). Both end in
01and have bit 0. This would cause a collision and split in the left branch of Index 01. The diagram shows no split there. - (D) Contains 6 () and 14 (). Both end in
10and have bit 1. This would cause a collision and split in the right branch of Index 10. The diagram shows no split there.
- Index 00: Empty. No keys end in
58
Q58NAT2 marksMediumConsider the following ANSI C function. [code] Let be an array of 10 elements with , for all such that . The value returned by…Think it through. Then check your answer.Question
Consider the following ANSI C function.Let be an array of 10 elements with , for all such that . The value returned by SimpleFunction() is ________.int SimpleFunction(int Y[], int n, int x) { int total = Y[0], loopIndex; for (loopIndex = 1; loopIndex <= n - 1; loopIndex++) total = x * total + Y[loopIndex]; return total; }Correct answer
1023 to 1023
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The function implements Horner's method to evaluate a polynomial where the array elements are coefficients. For and , the function calculates:Given for all and , this becomes a geometric series:Using the formula for the sum of a geometric progression :59
Q59NAT2 marksMediumConsider the sliding window flow-control protocol operating between a sender and a receiver over a full-duplex error-free link. Assume the following: * The time taken for…Think it through. Then check your answer.Question
Consider the sliding window flow-control protocol operating between a sender and a receiver over a full-duplex error-free link. Assume the following:- The time taken for processing the data frame by the receiver is negligible.
- The time taken for processing the acknowledgement frame by the sender is negligible.
- The sender has infinite number of frames available for transmission.
- The size of the data frame is 2,000 bits and the size of the acknowledgement frame is 10 bits.
- The link data rate in each direction is 1 Mbps ( bits per second).
- One way propagation delay of the link is 100 milliseconds.
Correct answer
50 to 52
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Given parameters:- Data frame size bits
- Acknowledgement frame size bits
- Bandwidth bits/sec
- Propagation delay ms s
- Transmission time for data frame: s ms
- Transmission time for acknowledgement: s ms
In a sliding window protocol over a full-duplex link, the time from the start of transmission of a frame until the receipt of its acknowledgement is:
msStep 3: Calculate the window size for 50% utilization.
Utilization
Step 4: Round to the nearest integer.
.60
Q60NAT2 marksMediumConsider the following C code segment: [code] In a compiler, this code segment is represented internally as a directed acyclic graph (DAG). The number of nodes in the DAG is…Think it through. Then check your answer.Question
Consider the following C code segment:In a compiler, this code segment is represented internally as a directed acyclic graph (DAG). The number of nodes in the DAG is __________.a = b + c; e = a + 1; d = b + c; f = d + 1; g = e + f;Correct answer
6 to 6
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
To find the number of nodes in the DAG, we identify unique sub-expressions and leaf nodes (variables/constants):1.a = b + c: Creates leaf nodes forbandc, and an internal node+with children(b, c). Node count: 3.2.e = a + 1: Creates a leaf node for1, and an internal node+with children(node_a, 1). Node count: .3.d = b + c: The expressionb + cis already represented by the node fora. No new nodes are created;dis just another label for that node.4.f = d + 1: Sincedis the same asa,d + 1is the same asa + 1. No new nodes are created;fis another label for the node fore.5.Summary of nodes:g = e + f: Sinceeandfrefer to the same node, this isnode_e + node_e. We create one new internal node+with both children pointing tonode_e. Node count: .- Leaves:
b,c,1(3 nodes) - Internal (operations):
+(forb+c),+(fora+1),+(fore+f) (3 nodes)
- Leaves:
61
Q61NAT2 marksHardIn a pushdown automaton , a transition of the form, [figure] where , , and…Think it through. Then check your answer.Question
In a pushdown automaton , a transition of the form,where , , and , representsConsider the following pushdown automaton over the input alphabet and stack alphabet .
The number of strings of length 100 accepted by the above pushdown automaton is __________.
Correct answer
50 to 50
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Let's analyze the transitions of the PDA:1.: Pushes the bottom-of-stack marker and moves to .2.: For every 'a' read, an 'A' is pushed onto the stack. After 'a's, the stack is .3.: Non-deterministically moves to without consuming input or changing the stack.4.: For every 'b' read, an 'A' is popped from the stack. To eventually reach , all 'A's must be popped by reading exactly 'b's.5.: Once the stack top is (meaning all 'A's are popped), it pops and moves to the final state . The stack is now empty.6.: This loop requires an 'A' on the stack to proceed. However, the stack is empty upon entering . Thus, this transition is unreachable.The language accepted is .
For a string of length 100, we have .
The only string of length 100 in is .
Therefore, the number of such strings is 1.62
Q62NAT2 marksMediumConsider the following matrix. The largest eigenvalue of the above matrix is…Think it through. Then check your answer.Question
Consider the following matrix.The largest eigenvalue of the above matrix is ___________.Correct answer
3 to 3
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The given matrix is:This matrix can be written as , where is a all-ones matrix and is the identity matrix.
The eigenvalues of (a rank-1 matrix with trace 4) are .
Since , the eigenvalues of are .
Thus, the eigenvalues of are:
The eigenvalues are .
The largest eigenvalue is .63
Q63NAT2 marksMediumA five-stage pipeline has stage delays of 150, 120, 150, 160 and 140 nanoseconds. The registers that are used between the pipeline stages have a delay of 5 nanoseconds each. The…Think it through. Then check your answer.Question
A five-stage pipeline has stage delays of 150, 120, 150, 160 and 140 nanoseconds. The registers that are used between the pipeline stages have a delay of 5 nanoseconds each.
The total time to execute 100 independent instructions on this pipeline, assuming there are no pipeline stalls, is ___________ nanoseconds.Correct answer
17160 to 17160
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The clock cycle time () is determined by the slowest stage plus the register delay.
Maximum stage delay = ns.
Register delay = ns.
ns.For a -stage pipeline executing instructions without stalls, the total time is given by:
Given and :
ns.64
Q64NAT2 marksMediumA sender (S) transmits a signal, which can be one of the two kinds: and with probabilities 0.1 and 0.9 respectively, to a receiver (R). In the graph below, the weight of…Think it through. Then check your answer.Question
A sender (S) transmits a signal, which can be one of the two kinds: and with probabilities 0.1 and 0.9 respectively, to a receiver (R).
In the graph below, the weight of edge is the probability of receiving when is transmitted, where . For example, the probability that the received signal is given the transmitted signal was , is 0.7.If the received signal is , the probability that the transmitted signal was (rounded to 2 decimal places) is ___________.
Correct answer
0.04 to 0.04
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
Let denote the transmitted signal and denote the received signal.
Given probabilities:
From the graph/text:
We need to find using Bayes' theorem:First, calculate the total probability of receiving , :Now, calculate the conditional probability:The probability is .65
Q65NAT2 marksHardConsider the following instruction sequence where registers R1, R2 and R3 are general purpose and MEMORY[X] denotes the content at the memory location X. | Instruction | Semantics…Think it through. Then check your answer.Question
Consider the following instruction sequence where registers R1, R2 and R3 are general purpose and MEMORY[X] denotes the content at the memory location X.Assume that the content of the memory location 5000 is 10, and the content of the register R3 is 3000. The content of each of the memory locations from 3000 to 3010 is 50. The instruction sequence starts from the memory location 1000. All the numbers are in decimal format. Assume that the memory is byte addressable.After the execution of the program, the content of memory location 3010 is __________.Instruction Semantics Instruction Size (bytes) MOV R1, (5000) R1 MEMORY[5000] 4 MOV R2, (R3) R2 MEMORY[R3] 4 ADD R2, R1 R2 R1+R2 2 MOV (R3), R2 MEMORY[R3] R2 4 INC R3 R3 R3+1 2 DEC R1 R1 R1-1 2 BNZ 1004 Branch if not zero to the given absolute address 2 HALT Stop 1 Correct answer
50 to 50
Turn this into a strength.Explore AI-powered practice and doubt support with Success Tracker.Step-by-step solution
The program executes as follows:1.Initialization:-
MOV R1, (5000): Loads value 10 into R1. - R3 is given as 3000.
- Memory locations 3000 to 3010 are initialized to 0.
The loop starts at address 1004 and continues while R1 is not zero (BNZ 1004).- Iteration 1:
-
MOV R2, (R3): R2 = Mem[3000] = 0. -
ADD R2, R1: R2 = 0 + 10 = 10. -
MOV (R3), R2: Mem[3000] = 10. -
INC R3: R3 becomes 3001. -
DEC R1: R1 becomes 9. - Iteration 2:
-
MOV R2, (R3): R2 = Mem[3001] = 0. -
ADD R2, R1: R2 = 0 + 9 = 9. -
MOV (R3), R2: Mem[3001] = 9. -
INC R3: R3 becomes 3002. -
DEC R1: R1 becomes 8. - ...
- Iteration 10:
- R1 is 1. R3 is 3009.
-
MOV R2, (R3): R2 = Mem[3009] = 0. -
ADD R2, R1: R2 = 0 + 1 = 1. -
MOV (R3), R2: Mem[3009] = 1. -
INC R3: R3 becomes 3010. -
DEC R1: R1 becomes 0. -
BNZ 1004: R1 is 0, so the branch is NOT taken.
- The program halts.
- The memory location 3010 was never written to (the last write was to 3009).
- Since Mem[3010] was initialized to 0, it remains 0.
-