The arrow means increasing intensity. Complete the analogy dry → arid → parched, diet → fast → ___. Options: A starve; B reject; C feast; D deny.
Your answer
Answer & solution
Official answer: A
Approach: Match both the subject of the words and the direction of the progression. 1. “Dry”, “arid” and “parched” describe increasingly severe lack of moisture. The last word should therefore intensify the idea introduced by the first two words in the second sequence. 2. In the intended food-related sense, to diet is to restrict eating, to fast is to abstain from eating, and to starve is to suffer extreme deprivation of food. “Starve” completes that progression. 3. “Reject” and “deny” concern refusal but do not specifically describe a stronger degree of food deprivation. “Feast” means eating abundantly and reverses the direction. Answer: A, starve. The analogy uses the intended semantic scale, rather than claiming that every voluntary diet necessarily develops into fasting or starvation.
Distinct nonzero real variables x and y satisfy that x+y is proportional to x−y. What can be said about x/y? A It depends on xy. B It depends only on x. C It depends only on y. D It is constant.
Your answer
Answer & solution
Official answer: D
Approach: Replace “proportional” with an equation involving one fixed proportionality constant. 1. Write x+y=k(x−y), where k does not change with the variables. The distinction x≠y ensures that the quantity to which x+y is proportional is nonzero. 2. Expand and collect terms: x+y=kx−ky, so (k−1)x=(k+1)y. 3. Because y≠0, division by y is allowed. Also k cannot equal 1: substituting k=1 into the original equation gives 2y=0, contrary to the premise. 4. Consequently x/y=(k+1)/(k−1). Its value depends only on the fixed k, not on the particular allowed pair x,y. Answer: D. A useful distinction is that x and y may vary while their ratio stays fixed.
Find the median of 9, 18, 11, 14, 15, 17, 10, 69, 11, 13. Options: A 13.5; B 14; C 11; D 18.7.
Your answer
Answer & solution
Official answer: A
Approach: A median uses positions in the sorted data, not the arithmetic average of every observation. 1. Arrange all ten observations in nondecreasing order, retaining the repeated 11: 9, 10, 11, 11, 13, 14, 15, 17, 18, 69. 2. For an even sample size n, the two middle positions are n/2 and n/2+1 when counted from 1. Here they are positions 5 and 6. 3. Those observations are 13 and 14. The median is their average, (13+14)/2=13.5. Answer: A. The unusually large observation 69 affects the mean much more than the median. Option D, 18.7, is the mean because the sample sum is 187; it is not the requested statistic.
The counts of ₹1, ₹5 and ₹10 coins are in the ratio 5:3:13. What percentage of the total money is in ₹5 coins? Options: A 21%; B 14 2/7%; C 10%; D 30%.
Your answer
Answer & solution
Official answer: C
Approach: The ratio is a ratio of numbers of coins, so weight each count by its denomination before computing a money percentage. 1. Let the counts be 5t, 3t and 13t for some positive common factor t. 2. Their monetary contributions are ₹(1×5t)=₹5t, ₹(5×3t)=₹15t and ₹(10×13t)=₹130t. 3. The total amount is ₹(5t+15t+130t)=₹150t. The ₹5 coins therefore contribute the fraction 15t/150t=1/10. 4. Multiplying by 100 gives 10%. Answer: C. Using 3/(5+3+13)=1/7 would give the fraction of coins that have denomination ₹5, not the fraction of the money they represent; that is the distractor 14 2/7%.
For positive p and q, log(p²+q²)=log p+log q+2 log 3. Find (p⁴+q⁴)/(p²q²). Options: A 79; B 81; C 9; D 83. All logarithms use the same valid base.
Your answer
Answer & solution
Official answer: A
Approach: First remove the logarithms using product and power laws, then use the square of a sum. 1. The right side is log p+log q+log 9=log(9pq). Positivity makes every logarithm well-defined. 2. A logarithm with a fixed valid base is one-to-one, so equality of the logarithms gives p²+q²=9pq. 3. Square both sides: p⁴+2p²q²+q⁴=81p²q². Subtract the cross term to obtain p⁴+q⁴=79p²q². 4. Divide by p²q², which is nonzero, giving the requested value 79. Answer: A. The value 81 would result from forgetting the term 2p²q² when expanding (p²+q²)². It is unnecessary to solve separately for p or q.
Choose the sequence for: Steve was advised to keep his head (i) before heading (ii) to bat; while he had a head (iii) batting, he needed a cool head (iv) his shoulders. A down, down, on, for; B on, down, for, on; C down, out, for, on; D on, out, on, for.
Your answer
Answer & solution
Official answer: C
Approach: Test each blank within its complete idiomatic phrase, rather than selecting a preposition in isolation. 1. “Keep his head down” is the established expression for remaining focused or avoiding distraction. This fixes (i) as down. 2. “Heading out to bat” describes going out to begin batting, so (ii) is out. 3. “Have a head for” a subject or activity means having an aptitude for it. Thus (iii) is for, giving “a head for batting”. 4. A person has a head “on his shoulders”; the same construction is used figuratively for composure or good judgment. Hence (iv) is on. The sequence is down, out, for, on, which is C. It is the only option that satisfies all four phrases together.
A 54 cm by 4 cm rectangular sheet is rolled into a cylindrical tube by joining its two longer edges. A cube has total surface area equal to the sheet area. Find cylinder volume divided by cube volume. A 1/π; B 2/π; C 3/π; D 4/π.
Your answer
Answer & solution
Official answer: A
Approach: Decide which sheet dimension becomes the circumference before applying volume formulas. 1. Joining the two 54-cm edges makes them the seam running along the tube. The cylinder therefore has height 54 cm and circumference 4 cm, not the reverse. 2. From 2πr=4, its radius is r=2/π cm. Its enclosed volume is πr²h=π(2/π)²×54=216/π cm³. 3. The sheet area is 54×4=216 cm². If the cube has side s, its total surface area is 6s², so 6s²=216 and s=6 cm. 4. The cube volume is s³=216 cm³. The ratio is (216/π)/216=1/π. Answer: A. The sheet supplies the lateral surface of the open tube; the question does not require circular end caps. For the cube, however, the stated surface area includes all six faces.
A 2,000 kcal diet gets 35% of its energy from carbohydrates, 20% from proteins, 20% from unsaturated fat, 20% from saturated fat and 5% from trans fat. Carbohydrates and proteins supply 4 kcal/g; each fat supplies 9 kcal/g. Find total fat consumed in grams. A 44.4; B 77.8; C 100; D 3,600.
Your answer
Answer & solution
Official answer: C
Approach: The chart gives shares of energy, not shares of mass. Add the fat energy contributions, then divide by fat energy density. 1. The three fat categories account for 20%+20%+5%=45% of total energy. The remaining 55% comes from carbohydrates and proteins and must not be counted as fat. 2. Fat energy is 0.45×2,000=900 kcal. 3. Each listed type of fat has the same density, 9 kcal per gram. Therefore their combined mass is 900 kcal ÷ (9 kcal/g)=100 g. Answer: C. As a check, saturated and unsaturated fats each contribute 400/9 g, and trans fat contributes 100/9 g. Adding these gives 900/9=100 g. Multiplying energy by density would have the wrong units.
A 20 cm by 8 cm rectangular paper is folded three times. Every fold is along a symmetry line perpendicular to the current longer edge. Find the final folded rectangle's perimeter in centimetres. A 18; B 24; C 20; D 21.
Your answer
Answer & solution
Official answer: A
Approach: A fold perpendicular to the longer edge halves the longer dimension. The longer dimension may change during the process. 1. Initially the dimensions are 20 and 8 cm. Fold 1 halves 20, leaving a 10×8 rectangle. 2. The longer dimension is now 10 cm. Fold 2 halves it, leaving a 5×8 rectangle. 3. The longer dimension has switched: it is now 8 cm, not 5 cm. Fold 3 therefore halves 8, leaving a 5×4 rectangle. 4. The perimeter of this final outline is 2(5+4)=18 cm. Answer: A. Halving the original 20-cm direction three times would ignore the instruction to use the current long edge. The perimeter is of the folded sheet's outside boundary, not of all layers separately.
Six equal unit squares are drawn relative to a horizontal line AB. Number aligned grid columns 1 through 5 from left to right. In the first row above AB, column 2 is occupied. In the first row below AB, columns 1, 4 and 5 are occupied. In the second row below AB, columns 2 and 5 are occupied. All other cells are empty; no square crosses AB. What is the fewest squares to add to make AB a symmetry axis? A 6; B 4; C 5; D 7.
Your answer
Answer & solution
Official answer: A
Approach: Reflection across a horizontal axis preserves a square's column and reverses its vertical distance from the axis. 1. The upper square in column 2 needs a partner in the first row below AB, column 2. That cell is empty: the existing lower square in column 2 is in the second row and is not its reflection. 2. The three squares immediately below AB in columns 1, 4 and 5 need three squares immediately above AB in those same columns. None is present. 3. The two squares in the second row below AB, columns 2 and 5, need two squares in the second row above AB. Neither is present. 4. These six missing reflected cells are all different. Each is necessary for symmetry, and adding exactly these six makes every square have its partner. Answer: A, 6. This gives both a lower bound and a construction attaining it; simply counting visually nearby squares can miss the gap beneath the existing upper square.
Let f(x)=max{x,x³} for every real x. At exactly which points is f not differentiable? A {−1,1,2}; B {−2,−1,1}; C {0,1}; D {−1,0,1}.
Your answer
Answer & solution
Official answer: D
Approach: A maximum of smooth branches can have a corner where the winning branch changes. Find the crossings, then compare one-sided derivatives. 1. Solve x³=x: x(x−1)(x+1)=0, giving candidates −1, 0 and 1. Away from these points the larger expression is one fixed polynomial and is differentiable. 2. Testing the intervals gives f(x)=x for x<−1, f(x)=x³ for −1<x<0, f(x)=x for 0<x<1, and f(x)=x³ for x>1. 3. At −1, the left derivative is 1 and the right derivative is 3(−1)²=3. They differ. 4. At 0, the left derivative is 0 and the right derivative is 1. At 1, the left derivative is 1 and the right derivative is 3. These also differ. Answer: D, {−1,0,1}. Equal function values at a crossing ensure continuity here, but do not ensure equal slopes.
Find the product of all eigenvalues of the matrix with rows (1,2,3), (4,5,6), (7,8,9). Options: A −1; B 0; C 1; D 2.
Your answer
Answer & solution
Official answer: B
Approach: The product of a square matrix's eigenvalues, counting algebraic multiplicities, equals its determinant. There is no need to solve its characteristic cubic. 1. Denote the rows by R1, R2 and R3. Observe R2−R1=(3,3,3) and R3−R2=(3,3,3). 2. Therefore R1−2R2+R3=0. This is a nontrivial linear dependence among the rows, so the matrix is singular and its determinant is zero. 3. Hence at least one eigenvalue is zero, making their product zero. Answer: B. A direct determinant check gives 1(45−48)−2(36−42)+3(32−35)=−3+12−9=0. The sum of eigenvalues would instead be the trace 1+5+9=15; that is a different quantity.
Signed integers use five-bit two's complement. A is 01010 and B is 11010. Which operation overflows or underflows this representation? A A+B; B A−B; C B−A; D 2B.
Your answer
Answer & solution
Official answer: B
Step through it (4 options)
Approach: Decode the operands as signed values, perform ordinary integer arithmetic, and compare each mathematical result with the representable interval. 1. With five bits, two's complement represents −2⁴ through 2⁴−1, namely −16 through 15. 2. A has leading bit 0, so A=10. B has unsigned value 26 and leading bit 1, so its signed value is 26−32=−6. 3. The four results are A+B=4; A−B=16; B−A=−16; and 2B=−12. 4. Only 16 falls outside [−16,15]. Its five-bit pattern would wrap to 10000, which represents −16 rather than the intended positive 16. Answer: B. The value −16 in option C is exactly the valid lower endpoint, not an underflow. Two's complement has one more negative value than positive nonzero values.
A permutation of {1,2,…,n}, n≥4, is chosen uniformly. X means 1 occurs before 2; Y means 3 occurs before 4. Which statement is true? A X and Y are mutually exclusive. B They are independent. C At least one must occur. D X is more likely than Y.
Your answer
Answer & solution
Official answer: B
Approach: Use symmetry of label swaps; other elements and their positions do not affect the two order comparisons. 1. Swapping labels 1 and 2 pairs every permutation satisfying X with one not satisfying X. Thus P(X)=1/2. Similarly, swapping 3 and 4 shows P(Y)=1/2. 2. The first swap does not change Y, and the second does not change X. Starting from any permutation, independently applying these swaps produces all four truth combinations (X,Y), (X,not Y), (not X,Y), and (not X,not Y), each equally often. 3. Therefore P(X∩Y)=1/4=P(X)P(Y), proving independence. Answer: B. The order 1,2,3,4 shows both events can occur, disproving mutual exclusivity. The order 2,1,4,3 shows both can fail, disproving C. Their equal probabilities disprove D.
Which statement is false? A Cycle-stealing DMA transfers one word between an I/O device and memory in a stolen cycle. B Burst DMA offers higher bulk-transfer throughput than cycle stealing. C Programmed I/O uses the CPU better than interrupt-driven I/O. D Vectored interrupts can start their service routine faster than non-vectored interrupts.
Your answer
Answer & solution
Official answer: C
Approach: Compare what the CPU must do while an I/O device is not ready, then check the other hardware statements. 1. In programmed I/O the CPU repeatedly polls device status and performs the transfer itself. Time spent waiting or polling is unavailable for useful work on other tasks. 2. With interrupt-driven I/O, the CPU can execute other work until the device signals that attention is required. In the standard comparison used here, this improves CPU utilization. Thus C reverses the expected relationship and is false. 3. Cycle stealing grants DMA a bus cycle for a word transfer, supporting A. Burst DMA keeps the bus for a block, reducing repeated arbitration overhead and supporting B for bulk traffic. 4. A vectored interrupt identifies the appropriate handler through a vector, whereas a non-vectored mechanism needs additional identification or dispatch. This supports D. Answer: C. These are textbook comparisons under comparable conditions, not a claim that interrupt overhead is zero for every workload.
A browser fetches an index page and its embedded images from one server over one TCP connection. DNS and browser caches start empty. Put these outgoing packets in chronological order: (i) GET index, (ii) DNS request, (iii) GET image, (iv) TCP SYN. A iv,ii,iii,i; B ii,iv,iii,i; C ii,iv,i,iii; D iv,ii,i,iii.
Your answer
Answer & solution
Official answer: C
Approach: Identify what information or connection each operation needs before it can happen. 1. The browser begins with the server's name but, because the DNS cache is empty, must resolve that name to an IP address. The DNS request (ii) comes first. 2. Once the address is known, TCP connection establishment begins with the SYN packet (iv). HTTP requests use the established connection. 3. The browser requests the top-level index document (i). It must receive and parse that document to discover the embedded image references in this model. 4. It can then request an image object (iii), reusing the one TCP connection. Answer: C, ii → iv → i → iii. DNS replies and the rest of the TCP handshake occur between these events, but are not among the four packets the question asks us to order.
An algorithm checks whether an N-element integer array is sorted in either ascending or descending order by one pass comparing adjacent elements. Its worst-case running time is: A both O(N) and Ω(N); B O(N) but not Ω(N); C Ω(N) but not O(N); D neither.
Your answer
Answer & solution
Official answer: A
Approach: Big-O and big-Omega describe upper and lower bounds on the same worst-case running-time function; they are not synonyms for worst case and best case. 1. Maintain whether any adjacent pair increases and whether any adjacent pair decreases. Each of the N−1 adjacent pairs requires only constant work. The single pass therefore takes at most cN+d operations, giving O(N). 2. On an already sorted array, no early contradiction occurs. The algorithm must examine through the final adjacent pair to certify the property. Such an input requires a number of comparisons proportional to N, giving a worst-case Ω(N) lower bound. 3. Together these bounds give Θ(N). Answer: A. Some unsorted inputs may allow early termination, but that does not remove the linear worst-case lower bound.
A C program initializes int a=6, b=0, then executes while(a<10) { a=a/12+1; a+=b; }, followed by printf("%d",a). What happens in the intended execution model? A prints 9; B prints 10; C infinite loop; D prints 6.
Your answer
Answer & solution
Official answer: C
Approach: Trace the first iteration, then determine whether the loop reaches a repeating state. Both operands of a/12 are integers. 1. The initial test 6<10 is true. Integer division gives 6/12=0, so a=a/12+1 sets a to 1. 2. The following a+=b adds zero, because b was initialized to 0 and is never changed. The first iteration ends with a=1, b=0. 3. If an iteration starts with a=1, then 1/12=0, and the same two assignments leave a=1 again. This state is therefore preserved indefinitely. 4. The condition a<10 remains true, so control never reaches the printf after the loop. Answer: C. The expression contains “+1”, but it does not mean a is incremented each time: a is first replaced by the quotient a/12. This is the textbook execution interpretation of the supplied program. The printed program uses typographic double quotation marks. Taken literally these are not valid C delimiters, so the program does not compile as printed. The answer above follows the intended textbook interpretation with ASCII quote delimiters.
main calls fX once. The function has local char a; it reads a=getchar(), recursively calls fX if a is not newline, then prints a with putchar if a is not newline. Input is 1234 followed by newline. A no termination; B termination with no output; C termination with 4321; D termination with 1234.
Your answer
Answer & solution
Official answer: C
Approach: Distinguish the order in which recursive calls read characters from the order in which suspended calls resume printing. 1. The first call stores '1' in its own local a and calls fX again before reaching putchar. The next calls similarly store '2', '3' and '4'. Each call has a separate local variable. 2. A fifth call reads the newline. Both conditions are false, so this call neither recurses nor prints and returns immediately. 3. The suspended call holding '4' now continues at its second condition and prints 4. Returning again prints 3, then 2, then 1. 4. Once the first call returns, main terminates. The newline itself is never printed. Answer: C, output 4321. Printing before the recursive call would preserve input order; printing after it reverses order. The explicitly supplied newline is the stopping condition, so no assumption about reading past end-of-file is needed. The printed program uses typographic single quotation marks. Taken literally these are not valid C delimiters, so the program does not compile as printed. The answer above follows the intended textbook interpretation with ASCII quote delimiters.
Choose the ER diagram for: instructors teach courses; students register for courses; courses receive classrooms; instructors guide students. Rectangles denote entities and diamonds denote relationships. A diagram (i) uses a Student diamond and Registration rectangle. B diagram (ii) uses a Projects entity in place of Student. C diagram (iii) directly links Classroom to Course while its Allocation diamond is attached only to Course. D diagram (iv) has entities Instructor, Course, Student, Classroom and relationships Teaches(Instructor,Course), Registration(Student,Course), Allocation(Course,Classroom), Guides(Instructor,Student).
Your answer
Answer & solution
Official answer: D
Approach: Identify the objects first, then check the two endpoint entities of each relationship. 1. The four object categories are Instructor, Course, Student and Classroom. These must be entity rectangles. The verbs or associations become relationship diamonds: Teaches, Registration, Allocation and Guides. 2. Teaches must connect Instructor to Course; Registration must connect Student to Course; Allocation must connect Course to Classroom; Guides must connect Instructor to Student. Diagram (iv) satisfies all four requirements. 3. Diagram (i) interchanges the semantic roles of Student and Registration, using the wrong kinds of symbols. Diagram (ii) introduces Projects instead of the specified Student entity. 4. Diagram (iii) has a direct Classroom–Course edge and does not connect Classroom through Allocation; the named allocation relationship is therefore not properly represented. Answer: D. The specification does not give cardinality constraints such as one-to-many, so there is no need to invent them when selecting the diagram.
In a B+ tree, which nodes are exempt from the general requirement of at least 50% occupancy? A Only the root; B all leaves; C all internal nodes; D only the leftmost leaf.
Your answer
Answer & solution
Official answer: A
Approach: Separate the root's special role from the minimum-occupancy rules for ordinary nodes. 1. A B+ tree keeps nonroot nodes sufficiently full so that the number of nodes, and hence the height and search cost, stay controlled. Splitting, redistribution and merging maintain these lower bounds after updates. 2. The root needs an exception. If the entire tree fits in one leaf, that root leaf can contain only a few records. If the root is internal, it may have just two children even when the ordinary minimum for an internal node is larger. 3. Giving all leaves or all internal nodes the same exemption would abandon the normal occupancy guarantee. Being the leftmost leaf does not create an exception either. Answer: A. Precise key-versus-child counts depend on the chosen order convention, but the special status of the root does not.
Which claims about a relation R in first normal form are true? A R may have a multi-attribute key. B R cannot have a foreign key. C R cannot have a composite attribute. D R cannot have more than one candidate key.
Select all that apply
Answer & solution
Official answer: A, C
Approach: First normal form concerns the form of attribute values, not the number of columns in a key or the number of valid identifiers. 1. In the usual relational model, a 1NF relation stores one atomic value in each attribute position. An undivided composite attribute, such as an Address object containing separate Street and City components, must be represented using suitable atomic columns. Thus C is true in the intended terminology. 2. Several individually atomic columns can together uniquely identify a row. For example, (StudentID,CourseID) can be a key of an enrollment relation. This is a composite key, not a composite attribute, so A is true. 3. A foreign key simply constrains values to reference another relation. It is compatible with atomic values, so B is false. 4. Different columns or column sets may each identify rows uniquely. First normal form does not forbid multiple candidate keys, so D is false. Answer: A and C.
L1 and L2 are regular languages and L3 is not regular, over a common alphabet. Which statements always hold? A L1=L2 iff L1∩complement(L2)=∅. B L1∪L3 is nonregular. C complement(L3) is nonregular. D complement(L1)∪complement(L2) is regular.
Select all that apply
Answer & solution
Official answer: C, D
Approach: Use closure under complement and union to prove universal claims, and a single legal counterexample to reject each false universal claim. 1. A is false. L1∩complement(L2)=∅ means only L1⊆L2. For instance L1=∅ and L2={a} satisfy this condition without being equal. Equality would require both inclusions. 2. B is false. Choose L1=Σ*, which is regular. Its union with any L3 is Σ*, so the union can be regular even though L3 is not. 3. C is true by contradiction. If complement(L3) were regular, complementing it again would make L3 regular, since regular languages are closed under complement. This contradicts the premise. 4. D is true because complement(L1) and complement(L2) are each regular, and their union is regular by union closure. Answer: C and D. A nonregular input does not automatically make the result of every language operation nonregular.
Separate per-thread state from shared process state
Processes, Threads & System Calls
Tap to enlarge
Which thread statements are true? A Threads can exist only in kernel space. B Every thread has its own open-file descriptor table. C All threads of a process share one execution stack. D Threads in one process are not protected from each other by default.
Select all that apply
Answer & solution
Official answer: D
Approach: A process supplies a shared resource environment; a thread supplies a separate flow of execution inside it. 1. Thread management can be implemented by a user-space library, by the kernel, or by a combination. Kernel space is not the only possibility, so A is false. 2. Threads of a process normally share the process's open-file descriptor table. One thread's file operations can therefore affect descriptors available to the others. B is false. 3. Each thread needs its own program counter, register state and execution stack so that its calls and local execution can progress independently. A common address space does not mean a common stack, so C is false. 4. The stacks and other memory still lie in the shared address space. Ordinary thread boundaries do not provide the protection boundaries that separate processes have; a thread can access or corrupt another thread's memory. Thus D is true. Answer: D only.
In the standard process-state model, which direct transitions are not possible? A Running→Ready; B Waiting→Running; C Ready→Waiting; D Running→Terminated.
Select all that apply
Answer & solution
Official answer: B, C
Approach: Recall the distinction between being eligible to run, actually executing, and being blocked for an event. 1. Running→Ready is possible when the scheduler preempts a process, for example when its time slice expires. The process can still execute, but no longer holds the CPU. Thus A is not selected. 2. Waiting→Running is not a direct transition in this model. Completion of the awaited event makes the process Ready; only a later scheduling/dispatch action makes it Running. Select B. 3. Ready→Waiting is also not direct. A ready process is not executing and therefore cannot issue the blocking operation that makes it wait. It must first be dispatched to Running. Select C. 4. Running→Terminated is possible when a process exits, so D is not selected. Answer: B and C. The question is about edges of the abstract state diagram, not whether a waiting process can eventually run after passing through Ready.
Which are bottom-up parsers? A Shift-reduce; B Predictive; C LL(1); D LR.
Select all that apply
Answer & solution
Official answer: A, D
Approach: Ask whether parsing starts with the input's terminal symbols and reduces upward, or starts with the grammar's start symbol and expands downward. 1. A shift-reduce parser shifts input symbols onto a stack, then reduces recognized handles to nonterminals. Repeated reductions construct the parse from leaves toward the root. Hence A is bottom-up. 2. An LR parser is a systematic shift-reduce parser. It reads input from left to right and reconstructs a rightmost derivation in reverse, so D is bottom-up as well. 3. Predictive parsing chooses productions while expanding from the start symbol toward the input. It is top-down, making B false. 4. LL(1) is a predictive, top-down method using one lookahead symbol. Its second L refers to a leftmost derivation, not to upward reduction. C is false. Answer: A and D. LR and LL both scan left to right, so scan direction alone does not distinguish bottom-up from top-down.
P(A)=0.3, P(B)=0.5 and P(A∩B)=0.1. Select all true claims: A A and B are independent; B P(A∪B)=0.7; C P(A∩Bᶜ)=0.2; D P(Aᶜ∩Bᶜ)=0.4.
Select all that apply
Answer & solution
Official answer: B, C
Approach: Compute the four disjoint regions of the probability space and check independence separately. 1. The overlap A∩B has probability 0.1. The part only in A has probability 0.3−0.1=0.2. This is A∩Bᶜ, so C is true. 2. The part only in B has probability 0.5−0.1=0.4. Adding the two exclusive parts and the overlap gives P(A∪B)=0.2+0.4+0.1=0.7, so B is true. 3. The region in neither event has probability 1−0.7=0.3, not 0.4. Hence D is false. The value 0.4 belongs to B without A, not to the complement of the union. 4. Independence would require P(A∩B)=P(A)P(B)=0.3×0.5=0.15. The supplied overlap is 0.1, so A is false. Answer: B and C. As a check, the four disjoint probabilities 0.1, 0.2, 0.4 and 0.3 sum to 1.
Input X branches directly to one input of an AND gate and through a NOT gate to the other; the AND output is Y. Wires have no delay and signal edges are instantaneous; gates may have delays. Which claims are correct? A With zero delays Y is always 0. B With zero delays Y is always 1. C With delays a 0→1 change of X can cause a brief 1 at Y. D With delays a 1→0 change of X can cause a brief 0 glitch at Y.
Select all that apply
Answer & solution
Official answer: A, C
Approach: Distinguish the stable Boolean function from the timing behavior of two unequal signal paths. 1. With no delays, the two AND inputs are X and its exact complement. Their product is X·NOT X=0 for both X=0 and X=1. Therefore A is true and B is false. 2. Just before X rises, the inputs are (0,1). The direct input changes immediately to 1, but the inverter's output can remain 1 until its propagation delay expires. During that interval the AND sees (1,1). 3. If this overlap is long enough to propagate through the AND gate, Y briefly becomes 1 before returning to 0. The word “can” allows this timing condition; C is true, without claiming every pulse survives an inertial gate delay. 4. When X falls, the direct input becomes 0 immediately. The other input later rises from 0 to 1, but at no point are both 1. Y's stable level is already 0, so an interval at 0 is not a negative glitch. Answer: A and C.
Client P successfully connects to TCP server Q. NP is the sequence number in P's SYN; NQ is the acknowledgment number in Q's SYN-ACK. Which claims are correct? A NP is randomly chosen by P. B NP is always 0 for a new connection. C NQ=NP. D NQ=NP+1.
Select all that apply
Answer & solution
Official answer: A, D
Approach: Separate the choice of the initial sequence number from the rule for acknowledging a SYN. 1. A new TCP connection does not always begin at sequence number zero. The initial sequence number is chosen by the endpoint using a scheme intended to make it difficult to predict and to separate old connection traffic from new traffic. This is the randomized or pseudorandom selection described by A; B is false. 2. TCP acknowledgment numbers identify the next sequence number expected from the peer. A SYN consumes one position in sequence space even though it is not an ordinary payload byte. 3. After receiving a SYN with sequence NP, Q therefore acknowledges NP+1, with arithmetic modulo 2³². This makes D true and C false. Answer: A and D. Actual initial-sequence algorithms may combine a clock with a keyed pseudorandom function; the key's “randomly” should not be read as requiring a fresh independent uniform draw.
A processor has IF, ID, EX, MEM and WB pipeline stages. Which forwarding claims are correct? A An earlier instruction's result is passed from a source stage to a later instruction's destination stage. B MEM output can feed the next instruction's EX input. C Forwarding does not prevent every pipeline stall. D Forwarding needs no extra hardware.
Select all that apply
Answer & solution
Official answer: A, B, C
Approach: Forwarding supplies a computed value before the normal register-file writeback/read sequence has completed. 1. A later instruction may need a value that an earlier instruction has produced but has not yet written to the architectural register file. A bypass path sends that result directly to the consumer's appropriate stage. This is A. 2. A result available at the output of MEM can be routed to an EX input in a following cycle through pipeline registers and bypass selection. Thus B describes a valid forwarding path. 3. Availability still matters: in the usual five-stage pipeline, a load's value arrives too late for the immediately following instruction's EX stage without a load-use bubble. Control hazards and resource conflicts are not universally removed either. Therefore C is true. 4. Forwarding requires extra wires, multiplexers, register-number comparators and control logic to choose the correct source. D is false. Answer: A, B and C. Forwarding reduces some data-hazard stalls; it does not eliminate timing constraints.
For a packet moving from an internal network to an external network through ordinary source NAT, which listed IP-header fields are modified? A Source IP; B Destination IP; C Header Checksum; D Total Length.
Select all that apply
Answer & solution
Official answer: A, C
Approach: Identify the address translated by outbound NAT, then consider which dependent header field must be repaired. 1. Outbound source NAT replaces the private/internal source address with an externally visible source address. The remote recipient needs an address to which replies can be routed. Select A. 2. The destination remains the remote host requested by the sender in this standard source-NAT scenario. Destination translation is a different function, so B is not selected. 3. IPv4's header checksum covers the IPv4 header, including the source address. Altering that address requires a checksum update so the new header validates. Select C. 4. Replacing one fixed-width address with another neither inserts nor removes bytes. Total Length therefore does not change merely because of NAT; D is false. Answer: A and C. A device performing port translation also updates relevant transport-header fields, but those are not among these choices. The checksum option identifies the intended IPv4 model.
Nonempty finite sets A and B admit bijections A→B and A×A→A∪B. How many different values of |A| are possible?
Answer & solution
Official answer: 2
Approach: Turn the bijections into cardinality equations, use the range of the intersection size, and then prove that every remaining candidate is achievable. 1. The first bijection gives |A|=|B|=n for an integer n≥1. Put t=|A∩B|, so 0≤t≤n. 2. The second bijection gives |A×A|=|A∪B|. Therefore n²=2n−t. 3. Since t≥0, n²≤2n. Dividing by positive n yields n≤2. Thus only n=1 and n=2 can work. 4. For n=1, choose A=B={a}. Then n²=1=|A∪B| and both bijections exist. For n=2, choose disjoint sets A={a,b} and B={c,d}; both A×A and A∪B have four elements, so a bijection exists between them. Answer: 2 possible values. The question asks for the number of possible cardinalities, not the number of choices of the sets themselves.
Evaluate 3+1+5*2/7+2−4−7−6/2 using these rules: + has highest precedence and associates left; − is next and associates right; * is next and associates right; / is lowest and associates right. All arithmetic is integer arithmetic.
Answer & solution
Official answer: 6
Approach: Build the grouping from the stated table, not from ordinary mathematical or C precedence. Associativity decides grouping only among operators at the same precedence. 1. Highest-precedence additions group (3+1+5)=9 and (7+2)=9. The expression becomes 9*2/9−4−7−6/2. 2. Subtraction has higher precedence than multiplication and division and is right-associative. Its group is 9−(4−(7−6)). Evaluate inward: 7−6=1, 4−1=3, 9−3=6. 3. The expression is now 9*2/6/2. Multiplication is next, giving 18/6/2. 4. Division is right-associative, so this means 18/(6/2), not (18/6)/2. The inner quotient is 3 and the result is 18/3=6. Answer: 6. A fully parenthesized form is ((3+1)+5)*2 / (((7+2)−(4−(7−6)))/2). Both actual divisions are exact, so no integer-rounding issue arises.
How many spanning trees does the complete graph on four labelled vertices A, B, C and D have?
Answer & solution
Official answer: 16
Approach: A spanning tree uses all vertices, is connected and has no cycle. Since the graph is complete, every labelled tree on these vertices is available. 1. Cayley's formula states that the complete graph Kn has nn−2 labelled spanning trees. Substituting n=4 gives 4²=16. 2. We can verify this without the formula by classifying four-vertex tree shapes. A tree has three edges. It is either a star with one vertex of degree 3 or a path with degrees 1,2,2,1. 3. There are four stars, one for each choice of centre. For a path, arrange all four labels in an order. Reversing the order describes the same undirected path, so there are 4!/2=12 paths. 4. These shapes are disjoint and exhaustive, giving 4+12=16. Answer: 16. Counting arbitrary three-edge subsets would also include disconnected or cyclic selections, so not every such subset is a spanning tree.
R(A,B) has rows (10,20),(20,30),(30,40),(30,50),(50,95). S(A,C) has rows (10,90),(30,45),(40,80). Join R and S on equal A values, then keep rows with B<C. How many tuples remain?
Answer & solution
Official answer: 2
Approach: First match rows using the join condition, then test the selection condition for each resulting pair. 1. At A=10, R's B=20 matches S's C=90. The equijoin row is (R.A,B,S.A,C)=(10,20,10,90), and 20<90 is true. Below, write the equal A columns once as shorthand (A,B,C). 2. At A=30, there are two R rows and one S row. They produce (30,40,45) and (30,50,45). The first passes 40<45; the second fails 50<45. 3. R's A=20 and A=50 rows find no matching S row. S's A=40 row finds no R partner. An ordinary inner equijoin does not retain these unmatched rows. 4. The join therefore creates three tuples, of which exactly two survive the B<C filter. Answer: 2. Repeated A values in R must not be collapsed: each matching row contributes its own joined tuple before selection.
A file of 10⁶ bytes travels P→Q→R in consecutive 10³-byte chunks. Each link is 10⁶ bits/s. Chunk headers, propagation, processing and queueing are negligible; chunks are below the MTU. Router Q forwards each complete received packet and can receive one while transmitting another. P starts at t=0. When does R finish receiving? A 8.000 s; B 8.008 s; C 15.992 s; D 16.000 s.
Your answer
Answer & solution
Official answer: B
Approach: Separate the time to fill the two-link pipeline from the steady interval between completed packets. 1. The file has 10⁶/10³=1,000 chunks. Each chunk contains 1,000×8=8,000 bits, so one link serializes it in τ=8,000/10⁶=0.008 s. 2. Q receives the first complete chunk at t=τ and transmits it on the second link during the next interval. R therefore finishes the first chunk at 2τ. 3. While Q transmits chunk 1, it receives chunk 2. Both links have the same rate, so each later chunk finishes at R exactly τ after its predecessor. Chunk k finishes at (k+1)τ. 4. The last chunk therefore finishes at 1,001×0.008=8.008 s. Answer: B. Multiplying the whole-file time by two ignores pipelining; using only 8.000 s ignores the final second-link serialization. Negligible propagation does not mean zero transmission time.
An SDD uses S→DHTU with S.val equal to the sum of the four child values. D→M D1 adds 5 to D1.val, while D→ε has value −5. H→L H1 adds 50, while H→ε has value −10. T→C T1 adds 500, while T→ε has value −5. U→K has value 5. For input MMLK, find S.val. A 45; B 50; C 55; D 65.
Your answer
Answer & solution
Official answer: A
Step through it (14 steps)
Approach: Split the input according to the grammar and evaluate synthesized attributes from each terminating production upward. 1. D consumes the two Ms: D→M D1→M M D2→M M ε. The bottom value is −5, so D1.val=5−5=0 and D.val=5+0=5. 2. H consumes the single L. Its recursive rule contributes 50, then its epsilon rule contributes −10. Hence H.val=50−10=40. 3. There is no C between L and K, so T immediately uses T→ε. This still assigns T.val=−5; generating no terminal symbols does not mean an attribute value of zero. 4. U consumes K and has U.val=5. The start rule sums the values: S.val=5+40−5+5=45. Answer: A. The three distinct epsilon base values are part of the semantics and must be applied even when their terminal run is empty.
A grammar has S→daT | (1), T→aS | bT | (2), R→(3) | ε. FIRST(S)={c,d,f}, FIRST(T)={a,b,ε}, FIRST(R)={c,ε}; FOLLOW(S)=FOLLOW(T)={c,f,$}, FOLLOW(R)={f}. Complete (1),(2),(3). A Rf, ε, cTR; B fR, ε, cTR; C fR, cT, cR; D Rf, cT, cR.
Your answer
Answer & solution
Official answer: A
Approach: Use FIRST to eliminate incompatible productions, then verify the surviving option with FOLLOW rather than stopping after a partial match. 1. T must derive ε, and its FIRST set excludes c. Since aS and bT cannot produce ε, the missing alternative is T→ε, not T→cT. This eliminates C and D. 2. FIRST(S) contains c. The existing production daT starts with d. An alternative fR would start only with f, whereas Rf starts with c when R→cTR and with f when R→ε. Thus only A has the required FIRST(S). 3. In A, S→Rf places f immediately after R, giving FOLLOW(R)={f}. R→cTR places a nullable R after T, contributing c and FOLLOW(R)'s f to FOLLOW(T). 4. The trailing T in S→daT inherits FOLLOW(S), while the trailing S in T→aS inherits FOLLOW(T). Because S is the start symbol, $ propagates to both sets. The result is exactly {c,f,$} for each. Answer: A. FIRST describes how derived strings begin; FOLLOW describes terminals that can occur immediately after a nonterminal in a sentential form.
The code is L1 t1=−1; L2 t2=0; L3 t3=0; L4 t4=4*t3; L5 t5=4*t2; L6 t6=t5*M; L7 t7=t4+t6; L8 t8=a[t7]; L9 if t8<=max goto L11; L10 t1=t8; L11 t3=t3+1; L12 if t3<M goto L4; L13 t2=t2+1; L14 if t2<N goto L3; L15 max=t1. Find (number of basic blocks, instructions in largest block). A (6,6); B (6,7); C (7,7); D (7,6).
Your answer
Answer & solution
Official answer: D
Approach: A basic block is a maximal straight-line instruction sequence with entry only at its first instruction and transfer out only at its last. Identify every leader before counting. 1. The first instruction L1 is a leader. Branch targets L11, L4 and L3 are leaders because execution can enter directly at them. 2. Instructions immediately after conditional branches are also leaders: L10 follows L9, L13 follows L12, and L15 follows L14. These are the fall-through paths. 3. Sort the distinct leaders: L1, L3, L4, L10, L11, L13, L15. Each block runs from one leader through the instruction just before the next leader. 4. The blocks are [L1–L2], [L3], [L4–L9], [L10], [L11–L12], [L13–L14], [L15]. Their lengths are 2,1,6,1,2,2,1, totaling all 15 instructions. Answer: D, seven blocks with largest size six. The terminating branch L9 belongs to its block; a branch target such as L3 begins a new block even when the preceding instruction falls through to it.
Initially a=b=1. Thread T1 performs a=a+1 followed by b=b+1. Thread T2 performs b=2*b followed by a=2*a. Each assignment is atomic, but threads may interleave. Which set lists every possible final (a,b)? A {(4,4),(3,3),(4,3)}; B {(3,4),(4,3),(3,3)}; C {(4,4),(4,3),(3,4)}; D {(2,2),(2,3),(3,4)}.
Your answer
Answer & solution
Official answer: A
Approach: Preserve each thread's internal order while allowing every merge of the two two-statement sequences. 1. Label T1's statements A: increment a, B: increment b; label T2's statements C: double b, D: double a. Legal interleavings satisfy A before B and C before D. 2. There are six such orders: ABCD gives (4,4); ACBD gives (4,3); ACDB gives (4,3); CABD gives (4,3); CADB gives (4,3); CDAB gives (3,3). For example, ABCD increments each initial 1 to 2 before doubling it to 4. 3. Removing duplicates leaves {(4,4),(4,3),(3,3)}. 4. To see why (3,4) is impossible, a=3 would require D before A, while b=4 would require B before C. Together with the thread orders this demands C<D<A<B<C, an impossible cycle. Answer: A. Atomic assignments prevent lost updates inside an assignment, but do not force a whole thread to run as one unit.
The array [82,101,90,11,111,75,33,131,44,93] is “heapified”. Which first three entries result? A 82,90,101; B 82,11,93; C 131,11,93; D 131,111,90. The original does not specify min-heap versus max-heap; the official answer uses the usual bottom-up max-heap interpretation.
Your answer
Answer & solution
Official answer: D
Step through it (13 steps)
Approach: Under the intended max-heap convention, every parent must be at least as large as its children. Build the heap bottom-up by sifting down internal nodes, using zero-based indices. 1. Start at index 4 (value 111), whose child is 93, so no change. At index 3, swap 11 with its larger child 131. Index 2 contains 90 above children 75 and 33 and needs no change. 2. At index 1, 101 has children 131 and 111. Swap with 131; 101 then sits at index 3 above 11 and 44. 3. At index 0, 82 must move below 131. At its new index 1, move it below 111; then at index 4 move it below 93. 4. The resulting array is [131,111,90,101,93,75,33,11,44,82]. Its first three entries are 131,111,90, matching D. “Heap” alone also allows a min-heap, whose root would be 11, absent from all options. The question also does not name a particular construction algorithm. D is retained as the official intended answer, not as a uniquely forced result of the literal wording. Existing discrepancy CS-2024-S1-Q41-HEAP-TYPE remains open.
Normalize a square-root recurrence and flag its base case
Asymptotic Analysis & Recurrences
Tap to enlarge
The printed recurrence gives T(n)=√n·T(√n)+n for n≥1 and T(1)=1. Which asymptotic answer is intended? A Θ(n log log n); B Θ(n log n); C Θ(n² log n); D Θ(n² log log n). The recursive branch overlaps the base case, so the literal definition needs qualification.
Your answer
Answer & solution
Official answer: A
Approach: First disclose the definition's defect, then solve the intended version with a constant-size stopping threshold. 1. Literally, the n≥1 branch applies at n=1 and says T(1)=T(1)+1, contradicting T(1)=1. Merely changing ≥ to > is still insufficient over exact real arguments: repeated square roots of n>1 approach 1 but never reach it in finitely many steps. A constant threshold greater than 1, or a specified integer-rounding convention with a valid base, is needed. 2. For the intended recurrence, divide by n and set F(n)=T(n)/n. Then √n·T(√n)/n=T(√n)/√n=F(√n), so F(n)=F(√n)+1. 3. After k expansions, F(n)=F(n1/2^k)+k. Reaching a fixed threshold c>1 requires log n/2k≤log c, so k=Θ(log log n). 4. A bounded base value gives F(n)=Θ(log log n), hence T(n)=Θ(n log log n). Official intended answer: A. This derivation is conditional on the corrected stopping model; it does not solve the inconsistent recurrence exactly as printed. Existing discrepancy CS-2024-S1-Q42-BASE-CASE is preserved.
A binary min-heap contains 105 distinct elements. If k is the array index holding the maximum element, how many values can k take over valid heaps? A 53; B 52; C 27; D 1.
Your answer
Answer & solution
Official answer: A
Approach: Use the heap-order property to restrict the maximum to leaves, then count leaves in the complete binary-tree shape. 1. In a min-heap every parent is smaller than its children because all keys are distinct. If the maximum were an internal node, its child would need to be still larger, a contradiction. Thus the maximum must be a leaf. 2. With one-based indexing, internal nodes are indices 1 through floor(105/2)=52. Leaves occupy indices 53 through 105, giving 105−52=53 leaves. 3. Every leaf is a feasible maximum location: place the largest key at the chosen leaf and assign the remaining keys in increasing order along a parent-before-child ordering of the remaining nodes. All parent-child inequalities can be satisfied. Answer: A, 53. Zero-based indexing changes the leaf indices to 52 through 104 but not their number. The maximum is not fixed at the last array position; any leaf can hold it.
Prove functional dependencies and refute a converse
Functional Dependencies & Keys
Tap to enlarge
Which functional-dependency implications are valid? A XY→ZW implies X→ZW. B XY→ZW implies XY→Z. C XY→Z and W→Y imply XW→Z. D X→Y and Y→Z imply X→Z. Concatenated letters denote attribute sets.
Select all that apply
Answer & solution
Official answer: B, C, D
Step through it (4 parts)
Approach: Treat a functional dependency as a guarantee that equality on its left side forces equality on its right side. Use Armstrong-style inference or a concrete counterexample. 1. A is false: dropping a determinant attribute can lose information. Consider rows (X,Y,Z,W)=(0,0,0,0) and (0,1,1,1). Their XY values differ, so XY→ZW holds, but equal X values have different ZW values, violating X→ZW. 2. B is true by decomposition. If equal XY forces both Z and W to agree, it certainly forces Z alone to agree. 3. C is true. From equal XW, we have equal W, hence equal Y by W→Y. We now have equal XY, which forces equal Z by XY→Z. Equivalently, the closure of XW contains Y and then Z. 4. D is the transitivity rule: agreement on X gives agreement on Y, then on Z. Answer: B, C and D. Decomposing the right-hand side is valid; arbitrarily decomposing the left-hand side is not.
T is a DFS spanning tree of a directed graph G, rooted at v, and is also a BFS tree of G rooted at v. Which claims must hold? A G has no back edges relative to T. B G has no cross edges. C G has no forward edges. D Every edge of G belongs to T.
Select all that apply
Answer & solution
Official answer: C
Approach: A BFS tree preserves shortest-path distances from its root. Compare this constraint with the endpoint depths of each DFS edge type, using the usual simple directed-graph classification. 1. A non-tree forward edge u→w goes from a vertex to a proper descendant that is not its child. Thus depth_T(w)≥depth_T(u)+2. 2. But the edge supplies a root-to-w path of length depth_T(u)+1, shorter than its tree depth. This contradicts T being a BFS tree, so forward edges cannot exist. C is true. 3. Back edges are possible. In the directed cycle v→a→b→v, both DFS and BFS from v have the path v→a→b as their tree, and b→v is a back edge. Thus A and D are false. 4. Cross edges are also possible. Use edges v→a, v→b, b→a, with a explored before b in DFS. Both trees have a and b as root children, while b→a is a cross edge to the already completed branch. Answer: C only.
The schedule is r1(z); w1(z); r2(x); r3(y); w3(y); r2(y); w2(x); w2(y), where subscripts name transactions. Which serial schedules are conflict equivalent? A T1 T2 T3; B T1 T3 T2; C T3 T2 T1; D T3 T1 T2.
Select all that apply
Answer & solution
Official answer: B, C, D
Step through it (10 steps)
Approach: Only operations from different transactions on the same data item, with at least one write, impose conflict-order constraints. 1. Transaction T1 touches only z. Neither T2 nor T3 uses z, so T1 has no conflicts with the others and may appear anywhere in a serial order. 2. Only T2 accesses x, so x creates no intertransaction constraint. 3. On y, T3's read and write precede T2's read and write. Conflicting pairs include w3(y) before r2(y), w3(y) before w2(y), and r3(y) before w2(y). Each demands the same precedence edge T3→T2. 4. A conflict-equivalent serial order must therefore put T3 before T2, with T1 free. The valid orders are T1 T3 T2, T3 T2 T1, and T3 T1 T2. Answer: B, C and D. Option A reverses the y-conflict order. Merely knowing that the precedence graph is acyclic establishes serializability; enumerating its topological orders identifies the actual choices.
F(X,Y,Z)=Σ(3,5,6,7), with minterm indices in XYZ binary order. Which claims are correct? A F=Π(0,1,2,4). B F=XY+YZ+XZ. C F is independent of Y. D F is independent of X.
Select all that apply
Answer & solution
Official answer: A, B
Step through it (13 steps)
Approach: Translate the minterm indices to input assignments, then compare equivalent representations and test claimed independence. 1. The one-output assignments are 3=011, 5=101, 6=110 and 7=111. They are exactly the assignments with at least two inputs equal to 1. 2. The remaining indices 0,1,2,4 give output zero. A product of maxterms lists the zero-output indices, so F=Π(0,1,2,4). A is true. 3. XY is 1 when X and Y are both 1; YZ and XZ cover the other pairs. Their OR, XY+YZ+XZ, is therefore 1 exactly when at least two inputs are 1. B is true. 4. To disprove independence from Y, fix X=1,Z=0: then F=Y, so changing Y changes the output. Likewise with Y=1,Z=0, F=X. Thus C and D are false. Answer: A and B. Independence requires that changing an input never changes the output, so one counterexample assignment is enough to refute it.
The C function f(int x,int y) runs for(int i=0;i<y;i++){x=x+x+y;} and returns x. Which statements hold in the intended integer model? A f(20,10)>2²⁰; B f(20,20)>2²⁰; C f(20,10)<2¹⁰; D f(10,20)>2²⁰. The exponents are 20 and 10, not the decimal numbers 220 and 210.
Select all that apply
Answer & solution
Official answer: B, D
Approach: Derive a closed form for the loop instead of expanding twenty iterations individually. 1. Let x_k be the value after k iterations, with initial value x_0. Since y is unchanged, x_(k+1)=2x_k+y. Adding y gives x_(k+1)+y=2(x_k+y). 2. Therefore x_k+y=2^k(x_0+y), or x_k=2^k(x_0+y)−y. For the positive inputs listed, the loop performs exactly y iterations. 3. f(20,10)=30×2¹⁰−10=30,710. This exceeds 2¹⁰=1,024 but is below 2²⁰=1,048,576, so both A and C are false. 4. f(20,20)=40×2²⁰−20=41,943,020, and f(10,20)=30×2²⁰−20=31,457,260. Both exceed 2²⁰, making B and D true. Answer: B and D. This trace assumes an int wide enough for these values, such as a 32-bit signed int. On a narrow implementation signed overflow would invalidate the mathematical trace; the original does not specify int width.
Nullity bounds and counterexamples to stronger claims
Linear Algebra
Tap to enlarge
For every n×m matrix A with m>n, which statements about Ax=0 are true? A There are at least m−n linearly independent solutions. B Exactly m−n independent vectors can span every solution. C Some nonzero solution has at least m−n zero coordinates. D Some solution has at least n nonzero coordinates.
Select all that apply
Answer & solution
Official answer: A
Approach: Rank-nullity gives the universal dimension guarantee, but it does not directly guarantee particular zero/nonzero coordinate patterns. 1. Let r=rank(A). Then r≤n, and dim ker(A)=m−r≥m−n. A nullspace basis therefore contains at least m−n independent solution vectors. A is true. 2. B demands a spanning set of only m−n independent vectors. If A is the zero matrix, its nullspace has dimension m, which is larger than m−n for n>0. Thus B is not universal. 3. For C, take n=2,m=3 and rows (1,0,1),(0,1,1). Solutions are x=(−t,−t,t). Every nonzero solution has all three coordinates nonzero, whereas m−n=1 zero coordinate is required. C is false. 4. For D, instead take rows (1,0,0),(0,1,0). Solutions are (0,0,t), with at most one nonzero coordinate, less than n=2. D is false. Answer: A only. The counterexamples use different matrices because each universal statement may be refuted independently.
A DFA has start state 1 and only accepting state 1. For inputs (0,1), its transitions are: state 1→(2,4); state 2→(3,1); state 3→(1,2); state 4→(1,5); state 5→(4,1). Let n0(w),n1(w) count symbols. Which statements are false? A States 2 and 4 are distinguishable. B States 3 and 4 are distinguishable. C States 2 and 5 are distinguishable. D Every w with n0(w)=n1(w) is accepted.
Select all that apply
Answer & solution
Official answer: B, C
Approach: Group states with the same future acceptance behavior, then interpret the resulting quotient machine. 1. Consider classes C0={1}, C1={2,5}, C2={3,4}. Only C0 accepts. From either member of C1, input 0 leads to C2 and input 1 to C0. From either member of C2, 0 leads to C0 and 1 to C1. From C0, 0 leads to C1 and 1 to C2. 2. This is a stable partition: members of each class have the same accepting status and transition to the same classes for each symbol. Induction on suffix length therefore proves that states 2 and 5 are equivalent, as are states 3 and 4. Claims B and C are false. 3. States 2 and 4 are distinguishable: suffix 1 sends 2 to accepting state 1 but sends 4 to nonaccepting state 5. Thus A is true. 4. Label C0,C1,C2 by residues 0,1,2. A 0 adds 1 modulo 3 and a 1 subtracts 1. Starting at residue 0, the machine accepts exactly when n0−n1 is divisible by 3. Equal counts satisfy this condition, so D is true. Answer: B and C, because the question asks for false statements.
A graph G has n vertices and chromatic number k, the minimum number of colors in a proper coloring. Which always hold? A G contains K_k as a subgraph. B G has an independent set of size at least n/k. C G has at least k(k−1)/2 edges. D G has a vertex of degree at least k.
Select all that apply
Answer & solution
Official answer: B, C
Approach: A proper coloring partitions vertices into independent color classes. Use a coloring with exactly k colors to prove B and C, and small graphs to test A and D. 1. The k color classes together contain n vertices. By the pigeonhole principle, some class has at least n/k vertices (in fact at least ceil(n/k)). No two in that class are adjacent, proving B. 2. Every pair of color classes must have at least one edge between them. Otherwise those two classes could use the same color, producing a (k−1)-coloring and contradicting minimality. 3. There are choose(k,2)=k(k−1)/2 pairs of classes. An edge belongs to only one such pair, so at least that many edges are necessary. C is true. 4. A fails for the five-cycle: its chromatic number is 3, but it contains no triangle K3. D fails for Kk itself, where every vertex has degree k−1 rather than at least k. Answer: B and C. A clique of size k forces at least k colors, but needing k colors does not force a k-clique.
For positive integers, define a◇b=a+2b and a□b=ab. Which claims are true? A ◇ is associative. B □ is associative. C ◇ distributes over □. D □ distributes over ◇.
Select all that apply
Answer & solution
Official answer: B, D
Approach: Write both sides of each proposed identity using the definitions. An operation's symbol does not give it familiar arithmetic properties automatically. 1. For associativity of ◇, (a◇b)◇c=a+2b+2c, whereas a◇(b◇c)=a+2b+4c. Because c>0, they differ, so A is false. 2. □ is ordinary multiplication: (a□b)□c=(ab)c=a(bc)=a□(b□c). B is true. 3. For ◇ distributing over □, a◇(b□c)=a+2bc, but (a◇b)□(a◇c)=(a+2b)(a+2c). Taking a=b=c=1 yields 3 versus 9, disproving C. 4. Multiplication distributes over ◇ on both sides: a□(b◇c)=a(b+2c)=ab+2ac=(a□b)◇(a□c), and (a◇b)□c=(a+2b)c=ac+2bc=(a□c)◇(b□c). Answer: B and D. Checking both sides is useful because ◇ is not commutative, so left and right distributive identities should not be silently identified.
Two set-associative caches use LRU replacement. WBC is write-back; WTC is write-through. Which are true? A A WBC read miss never evicts a dirty block. B A WTC read miss never writes a victim block back to memory. C A WBC write hit can change a dirty bit. D A WTC write miss always writes its victim back before loading a block.
Select all that apply
Answer & solution
Official answer: B, C
Approach: Replacement policy selects the victim, whereas write policy determines whether the victim may contain newer data than main memory. 1. In a write-back cache, a write can modify the cached block without immediately updating memory. The dirty bit records this mismatch. On a write hit to a clean block, the bit can change from 0 to 1, proving C. 2. LRU selection does not guarantee a clean victim. A read miss can evict a dirty write-back block, which must then be written to memory. A's “never” is false. 3. Write-through propagates each write to memory, so a replaced cache block does not need an eviction-time dirty-block write-back in the standard completed-write model. Hence B is true. 4. D is false for the same reason. Moreover, a write-through cache may use no-write-allocate, in which case a write miss need not load a new block or select a cache victim at all. Answer: B and C. Write-through memory traffic caused by the current write is not the same thing as writing back an evicted dirty block.
A hard disk has capacity 512 GB, 32 storage surfaces, 4,096 sectors per track and 1,024 bytes per sector. How many cylinders does it contain? Use the binary capacity convention underlying the official answer.
Answer & solution
Official answer: 4096
Approach: A cylinder is the collection of tracks at one radial position across all storage surfaces. Compute bytes per cylinder before dividing total capacity. 1. One track contains 4,096×1,024=2¹²×2¹⁰=2²² bytes. 2. A cylinder contains one track on each of 32=2⁵ surfaces, so its capacity is 2⁵×2²²=2²⁷ bytes. The stated surface count is already the number of recording surfaces; it must not be doubled again. 3. Under the question's intended binary convention, 512 GB=512×2³⁰=2³⁹ bytes. 4. Number of cylinders = total bytes / bytes per cylinder = 2³⁹/2²⁷=2¹²=4,096. Answer: 4096. Strict decimal GB would mean 512×10⁹ bytes and would produce approximately 3814.697 cylinders, not the key's integer. The binary convention is therefore made explicit rather than silently treating the two unit definitions as identical.
Balance parallel speedup against per-core overhead
Processor Performance
Tap to enlarge
A program takes 100 ns on one 2 GHz core. Work accounting for 90% of that time parallelizes fully and is shared equally among cores. Every additional core adds 10 ns overhead. How many cores minimize total execution time?
Answer & solution
Official answer: 3
Approach: Write a total-time function containing serial work, divided parallel work, and overhead for cores beyond the first. 1. The serial part takes 10 ns regardless of core count. With k≥1 cores, the parallel part takes 90/k ns. 2. There are k−1 additional cores, so overhead is 10(k−1) ns. Thus T(k)=10+90/k+10(k−1)=90/k+10k ns. 3. Treating k temporarily as continuous, T'(k)=−90/k²+10. The stationary point is k²=9, so k=3. Since T''(k)=180/k³>0, this is the unique continuous minimum. 4. It is also a valid integer choice. Check its neighbors: T(2)=65 ns, T(3)=60 ns, T(4)=62.5 ns. The derivative is negative before 3 and positive afterward, excluding more distant improvements. Answer: 3 cores. The 2 GHz rate is not needed because the baseline and overhead are already specified in time units. Ignoring overhead would incorrectly suggest that more cores always help.
A program has 25% load/store instructions. Ideal CPI is 2; instruction-cache miss rate is 2%; data-cache miss rate is 8%; every miss costs 100 cycles. Find the speedup with perfect instruction and data caches, rounded to two decimals.
Answer & solution
Official answer: 3.00
Approach: Express every stall contribution per executed instruction so they can be added to the base CPI. 1. Every instruction requires an instruction fetch. Instruction-cache stalls therefore contribute 0.02 misses/instruction ×100 cycles/miss=2 cycles/instruction. 2. Only 25% of instructions access data memory. Data-cache stalls contribute 0.25 accesses/instruction ×0.08 misses/access ×100 cycles/miss=2 cycles/instruction. 3. With the stated additive, nonoverlapped miss-penalty model, actual CPI=ideal CPI+instruction stalls+data stalls=2+2+2=6. 4. Perfect caches remove both stall terms and restore CPI=2. With the same instruction count and clock rate, execution time is proportional to CPI, so speedup=old time/new time=6/2=3. Answer: 3.00. Using 8% for every instruction would overcount data misses. The reciprocal 2/6 is the new-to-old time ratio, not the speedup factor.
The code is int x=3; while(x>0){fork(); printf("hello"); wait(NULL); x--;}. The printed question assumes successful system calls and asks how many times printf executes. The ordinary POSIX behavior of wait creates a qualification to that premise.
Answer & solution
Official answer: 14
Step through it (24 steps)
Approach: Count statement executions in the process tree, not the number of visible copies of buffered output or the number of processes at one instant. 1. At x=3, the original process forks into a parent and child. Both continue after fork and execute printf, giving 2 executions associated with that loop value. 2. Each process has its own copied x. Both eventually reach x=2, and each forks again, giving 4 printf executions at that level. At x=1, the four process lineages each fork, giving 8 more executions. 3. Total executions are 2+4+8=14. wait may delay a parent while descendants finish, so these levels need not occur simultaneously, but waiting does not erase the later iterations of the parent's loop. A newly created child initially has no child of its own. Its first wait(NULL) therefore returns −1 with ECHILD on POSIX, contradicting the blanket premise that all calls succeed. The code ignores the return value, so the intended count is still 14 when normal no-child wait failures are allowed. Buffered “hello” text can also be copied by fork; that concerns output rendering, not the number of printf executions asked here. Answer: 14 under the intended counting model. Existing discrepancy CS-2024-S1-Q57-WAIT-PREMISE remains preserved.
A router has routes 10.1.1.0/24→R1, 10.1.1.128/25→R2, 10.1.1.64/26→R3 and 10.1.1.192/26→R4. It sends 20 packets to each of 10.1.1.16, .72, .132, .191 and .205. How many packets use R2? The abbreviated destinations share prefix 10.1.1.
Answer & solution
Official answer: 40
Step through it (7 steps)
Approach: A router uses the matching route with the greatest prefix length, not the first matching row or every matching route. 1. The /24 covers last-octet values 0–255. The /25 beginning at 128 covers 128–255. The /26 beginning at 64 covers 64–127, and the /26 beginning at 192 covers 192–255. 2. Destination .16 matches only the /24 and uses R1. Destination .72 matches the /24 and the 64/26; the longer /26 wins, so it uses R3. 3. Destinations .132 and .191 match the /24 and the 128/25, with no matching /26. Both therefore use R2. 4. Destination .205 also matches R2's /25, but it matches the more specific 192/26, so it uses R4 instead. Exactly two hosts use R2, each with 20 packets: 2×20=40. Answer: 40. Counting .205 for R2 would ignore longest-prefix selection.
A context-free grammar in Chomsky Normal Form has terminals {a,b,c} and 10 variables including start symbol S. It derives w=a³⁰b³⁰c³⁰. How many rule applications occur in a derivation S⇒*w?
Answer & solution
Official answer: 179
Approach: In Chomsky Normal Form, a nonempty derivation uses binary-variable rules A→BC and terminal rules A→a. Count each kind using the final word length. 1. The word contains 30+30+30=90 terminal symbols. Each requires exactly one terminal-producing rule application, so there are 90 such applications. 2. Initially there is one variable occurrence. Each binary rule replaces one variable with two and therefore increases the total number of current symbol occurrences by one. Terminal rules replace one symbol with one and do not change that total. 3. To grow from one symbol to a final string of 90 symbols requires exactly 89 binary-rule applications. Equivalently, the variable branching tree is full binary with 90 leaves and 89 internal branching nodes. 4. Total rule applications =90+89=179. Answer: 179. The ten available variable names can be reused and do not bound the number of variable occurrences. Derivation order does not change these counts; the CNF epsilon exception is irrelevant to this nonempty word.
An undirected graph has 100 vertices. A complete DFS traversal produces a spanning forest containing 40 edges. How many connected components does the graph have?
Answer & solution
Official answer: 60
Approach: DFS starts a new tree exactly when it moves to a previously unvisited connected component. Each resulting tree spans that component. 1. Suppose there are c components and their vertex counts are v1,…,vc. The counts sum to 100. 2. A tree with vi vertices has exactly vi−1 edges. This includes an isolated vertex: vi=1 gives zero edges. 3. Summing over the DFS forest gives 40=Σ(vi−1)=Σvi−c=100−c. 4. Solving yields c=100−40=60. Answer: 60 connected components. The original graph may have additional nontree edges and cycles; the given 40 counts only forest edges. One can also view each of those 40 tree edges as discovering one nonroot vertex, leaving 60 roots, one for each component.
Over {0,1}, r=0*+1* and s=01*+10*, where + means union and * means Kleene star. Count strings of length at most 5 that belong to neither language, including the empty string in the universe.
Answer & solution
Official answer: 44
Approach: Count all short binary strings, subtract the union of the two languages, and account for their overlap. 1. There are Σ from length 0 to 5 of 2^length =1+2+4+8+16+32=63 strings. The empty string is the single length-zero string. 2. Language r contains ε and, at each positive length 1–5, the all-zero and all-one strings. Thus |r within the limit|=1+2×5=11. Count ε only once even though both starred expressions generate it. 3. Language s contains a leading 0 followed by only 1s, or a leading 1 followed by only 0s. It has two strings at each length 1–5 and none at length zero, so its count is 10. 4. The overlap is exactly {0,1}. Longer strings in s contain both symbols, so cannot be in r. Inclusion-exclusion gives union size 11+10−2=19. 5. The complement count is 63−19=44. Answer: 44. A lengthwise check gives 0,0,0,4,12,28 excluded strings at lengths 0 through 5, again totaling 44.
Translate a page number while preserving the offset
Virtual Memory & Paging
Tap to enlarge
Pages are 2 KB, with addresses starting at zero. Virtual pages 0,1,2,3 occupy physical frames 1,3,2,0 respectively. What decimal physical address corresponds to decimal virtual address 2500? Use 1 KB=1024 bytes.
Answer & solution
Official answer: 6596
Step through it (5 steps)
Approach: Split the virtual address into a page number and page offset. The page table replaces only the page number; the offset stays unchanged. 1. Page size is 2×1024=2048 bytes. Compute 2500=1×2048+452, so the virtual page is 1 and the offset within it is 452 bytes. 2. The mapping for virtual page 1 is physical frame 3. It is the second listed mapping because page numbering starts at 0. 3. Physical frame 3 begins at address 3×2048=6144. Add the same offset: 6144+452=6596. Answer: 6596. The result lies within frame 3's address range [6144,8191], and subtracting its start recovers offset 452. Using page 2 or frame 1 would confuse zero-based numbering with the order in which the mappings are listed.
A bag contains 10 red and 15 blue balls. Two are drawn uniformly without replacement. Given that the first draw is red, find the probability that both draws are red, rounded to three decimals.
Answer & solution
Official answer: 0.370 to 0.380
Our answer: 0.375
Approach: The first red draw is already known. Update the bag after that draw and compute only the remaining uncertainty. 1. Initially there are 25 balls. After the given red draw, one red ball has been removed, leaving 9 red and 15 blue balls, 24 in total. 2. Under this condition, “both balls are red” is equivalent to “the second ball is red”. Its probability is therefore 9/24=3/8=0.375. 3. A conditional-probability check gives P(first red and second red)/P(first red)=[(10/25)(9/24)]/(10/25)=9/24, confirming that the first-draw factor cancels. Answer: 0.375, already expressed to three decimal places and within the official accepted interval 0.370–0.380. Multiplying by 10/25 without dividing by the conditioning probability would instead calculate the unconditional probability of two red draws.
M1 selects X1 for A=0 and X2 for A=1, giving Q1. M2 selects X3 for B=0 and X4 for B=1, giving Q2. M3 selects Q1 for C=0 and Q2 for C=1, giving Y. With X1=X2=1 and X3=X4=0, how many assignments to (A,B,C) give Y=1?
Answer & solution
Official answer: 4
Approach: Evaluate the first-stage multiplexers before enumerating the three select bits. 1. A 2-to-1 multiplexer outputs one of its two data inputs according to its select bit. Since both M1 inputs are 1, Q1=1 whether A is 0 or 1. 2. Both M2 inputs are 0, so Q2=0 whether B is 0 or 1. 3. The final multiplexer has data inputs Q1=1 on its 0 port and Q2=0 on its 1 port. Thus Y=(NOT C)·1+C·0=NOT C. 4. Therefore Y=1 exactly when C=0. A and B remain arbitrary, giving 2×2×1=4 assignments: (0,0,0), (0,1,0), (1,0,0), (1,1,0). Answer: 4. Although there are three select bits, only C affects the output for these fixed data inputs. The port labels in the source determine which value of C produces 1.
An IPv4 datagram totals 1420 bytes including a 20-byte header. It traverses a sender-to-router link with MTU 542, then a router-to-receiver link with MTU 360. Assuming ordinary permitted fragmentation and 20-byte fragment headers, how many fragments reach the receiver?
Answer & solution
Official answer: 6
Step through it (8 steps)
Approach: MTU includes each fragment's header. Nonfinal payload boundaries must align to eight-byte units, and the intermediate router fragments existing fragments rather than reassembling the original datagram. 1. Original payload is 1420−20=1400 bytes. On the first link, raw payload capacity is 542−20=522 bytes. Round down to a multiple of 8: floor(522/8)×8=520 bytes. 2. The sender creates payloads 520,520,360, each with a 20-byte header. Their original-data starting offsets are 0,520,1040 bytes. 3. On the second link, raw capacity is 360−20=340 bytes, with aligned nonfinal capacity floor(340/8)×8=336 bytes. Each 520-byte payload splits into 336+184; the 360-byte payload splits into 336+24. 4. Six payload fragments arrive: 336,184,336,184,336,24. Their starting offsets, in eight-byte units, are 0,42,65,107,130,172. Only the last has no more-fragments flag; total payload still sums to 1400. Answer: 6. Applying ceil(1400/336)=5 directly at the second link incorrectly assumes that the router reassembles and repacks the first-link fragments. Normal IPv4 forwarding leaves reassembly to the final destination, and fragmentation presumes DF is unset.