The ratio of boys to girls in a class is 7:3. Which total number of students is possible? Options: A 21; B 37; C 50; D 73.
Your answer
Answer & solution
Official answer: C
The coprime ratio 7: 3 requires integer counts 7k and 3k, so the total must be a multiple of 10. Only 50 qualifies among the choices; it gives 35 boys and 15 girls. Thus C.
The integer restriction matters: writing boys=0.7N alone is not enough unless 0.7N and 0.3N are integers. Because gcd(7,3)=1, the multiplier k must be integral. Testing the alternatives modulo 10 immediately rejects 21,37,73; 50 supplies a concrete feasible class.
A polygon is convex when the segment between every pair of its points remains inside or on it. Which depicted polygon is NOT convex? Diagram descriptions: A a right-pointing chevron-shaped hexagon with an inward notch at the middle of its left boundary; B a triangle; C a square; D a trapezoid with a shorter parallel top side and a longer bottom side.
Your answer
Answer & solution
Official answer: A
The left-side indentation in A creates a reflex interior angle. A segment joining points above and below that indentation can leave the shaded polygon, violating convexity. The triangle, square, and trapezoid have no such indentation and are convex. Thus A.
Convexity is about every joining segment, not whether most angles look ordinary. In A, choose two points just to the right of the upper-left and lower-left corners: their vertical joining segment passes through the notch outside the polygon. A single such pair disproves convexity. For B–D every interior angle is at most 180°, and each simple polygon is convex.
Consider (i) Everybody in the class is prepared for the exam. (ii) Babu invited Danish to his home because he enjoys playing chess. Which observation is correct? A (i) grammatical, (ii) unambiguous; B (i) ungrammatical, (ii) unambiguous; C (i) grammatical, (ii) ambiguous; D (i) ungrammatical, (ii) ambiguous.
Your answer
Answer & solution
Official answer: C
Everybody is grammatically singular and correctly takes is. In the second sentence, he could refer to either Babu or Danish, so the referent of the person enjoying chess is ambiguous. Thus sentence(i) is grammatical and(ii) is ambiguous, C.
The subject of sentence (i) is the singular indefinite pronoun everybody, not the plural noun class members that one might mentally substitute. To remove (ii)'s ambiguity one must name the chess enthusiast: 'because Babu enjoys playing chess' and 'because Danish enjoys playing chess' express different readings. Both can fit the original sentence, so ambiguity is semantic reference, not a verb-agreement error.
A circular paper sheet is folded with its right half onto its left half, then with its lower half upward, leaving the upper-left quarter. The final folded quarter is punched: a quarter-circle at the original center, a horizontal rectangular notch into the vertical fold above the center, and a small vertical rectangular notch into the horizontal fold left of the center. Which pattern appears after unfolding? All choices show a central round hole and four rectangular holes. A long horizontal rectangles above/below and short vertical rectangles left/right; B long horizontal rectangles above/below and short horizontal rectangles left/right; C short horizontal rectangles above/below and long vertical rectangles left/right; D short vertical rectangles above/below and long vertical rectangles left/right.
Your answer
Answer & solution
Official answer: A
The first fold moves the right half onto the left; the second moves the lower half upward. Unfolding reflects the quarter-circle center cut into a complete central circular hole. The rectangular cut reaching the vertical fold becomes a long horizontal slot, mirrored above and below the center. The cut reaching the horizontal fold becomes a vertical slot, mirrored to the left and right. These orientations match A.
Track each cut independently rather than rotating the whole pattern mentally. Reflection across a fold duplicates a notch and joins its two copies at the fold; it never rotates the notch by 90°. The horizontal notch touches the vertical fold, so that reflection doubles its horizontal length. The other fold makes its above/below pair. The small vertical notch similarly becomes the left/right pair. The central quarter-circle is reflected four times into one circle, not four separated holes.
Complete the analogy: ___ is to surgery as writer is to ___. Options (first blank, second blank): A plan, outline; B hospital, library; C doctor, book; D medicine, grammar.
Your answer
Answer & solution
Official answer: C
A doctor performs surgery, while a writer produces a book. This preserves the practitioner-to-work relationship, unlike the place, planning, or enabling-material alternatives. Thus C.
Read the relation in the same direction on both sides: person→work associated with that person. Hospital/library is a place pair, and medicine/grammar gives tools or knowledge rather than the person who does the work. Plan/outline does not place a practitioner in the first blank. The analogy is approximate, since surgery is an activity and a book is an output, but doctor/book is the only choice preserving the intended occupational relation.
Two sheets M and N each measure 6 cm by 1 cm. M is rolled into a cylinder by joining its short edges, and its ends are assumed closed. N is cut into equal square patches and assembled into the largest possible closed cube. What is volume(cylinder)/volume(cube)? A π/2; B 3/π; C 9/π; D 3π.
Your answer
Answer & solution
Official answer: C
Joining the short edges makes the cylinder circumference 6 cm and height 1 cm. Its radius is 3/π, so its volume is 9/π cubic centimeters. The 6×1 sheet supplies six 1×1 squares for a closed cube of side 1 and volume 1. A larger square face cannot fit within width 1. Thus the volume ratio is 9/π, option C.
The circumference is the long side because the short edges are identified. Thus 2πr=6, not 1; h=1. The cube requires six congruent faces. Six unit squares exactly exhaust the sheet's area, so the volume calculation uses all six faces, not an open box with five faces. Closing the cylinder ends is assumed rather than charged against sheet M's material, as the question explicitly states.
Item P has cost ₹5400 and marked price ₹5860. Item Q has profit 25% and marked price ₹10000. The cost ratio P:Q is 3:4. Profit percentage is 100(selling price−cost)/cost; discount is marked price−selling price. What is Q's discount as a percentage of marked price? A 25; B 12.5; C 10; D 5.
Your answer
Answer & solution
Official answer: C
The cost ratio gives cost(Q)=5400×4/3=7200. A 25% profit gives selling price 9000. Against marked price 10000, the discount is 1000, or 10%. Thus C; P’s marked price is not needed.
The calculation has two different percentage bases. Profit 25% is on cost, giving 7200×1.25=9000, whereas discount is on marked price, giving (10000−9000)/10000×100=10%. Dividing by cost at the final step would produce the wrong percentage. The unused P marked price is a distractor and does not impose a separate profit constraint.
Five bags each contain the same set of ten distinct chocolate types. Independently pick one chocolate uniformly from each bag. What is the probability that at least two selected chocolates have the same type? A 0.3024; B 0.4235; C 0.6976; D 0.8125.
Your answer
Answer & solution
Official answer: C
Use the complement event that all five selected chocolates have distinct types. Under independent uniform selections its probability is (10·9·8·7·6)/10⁵=0.3024. Therefore the probability of at least one repeated type is 1−0.3024=0.6976, C.
There are 105 equally likely ordered selections, one coordinate per bag. Distinct-type selections have successively 10,9,8,7,6 choices. Counting the complement avoids double-counting outcomes containing two pairs or a triple, which would complicate direct counting of 'at least two'. It is not a without-replacement draw from one bag: the bags make equal types across draws possible.
Statements: All bacteria are microorganisms. All pathogens are microorganisms. Conclusions: I Some pathogens are bacteria. II All pathogens are not bacteria. Which option is logically correct? A only I; B only II; C either I or II; D neither I nor II. Preserve the wording of II because its scope is ambiguous.
Your answer
Answer & solution
Official answer: C OR D
Our answer: C as an exhaustive alternative; D as individual entailment
Both premises only place bacteria and pathogens inside the microorganism set. They do not force their overlap or disjointness. If conclusion II means no pathogen is a bacterium, it is the logical negation of conclusion I, so exactly one must hold in any interpretation, supporting C’s either-or reading. Neither conclusion individually follows from the premises, supporting D if the question asks which conclusions are entailed individually. The phrase all pathogens are not bacteria also permits a not-all scope reading, adding ambiguity. The official key explicitly accepts C OR D; preserve both rather than selecting one without qualification.
Two models show the lack of entailment: take microorganisms {a,b}, bacteria {a}, pathogens {a} for overlap, and take bacteria {a}, pathogens {b} for disjointness. Both satisfy the premises. Under the 'no pathogens are bacteria' reading, I and II are complementary propositions, so their disjunction is always true although neither individual proposition is forced. This distinction between truth of an either-or and individual entailment is why collapsing the accepted pair to one letter would lose information.
A passage says that anti-obesity measures (AOM), such as calorie information on restaurant menus, sidestep the core causes of obesity: poverty and income inequality. Which statement summarizes it? A proposed AOM addresses the core causes; B reducing obesity will naturally reduce poverty because obesity causes poverty; C AOM address the core causes and are likely to succeed; D AOM address the problem superficially.
Your answer
Answer & solution
Official answer: D
The passage says the proposed calorie-display measures bypass the underlying poverty and income-inequality causes. It therefore characterizes those measures as superficial, D. It does not reverse causation or say that they already address the core causes.
A faithful summary preserves the author's direction of criticism. The passage proposes poverty/inequality as causes and calls menu labels an inadequate response to those causes. It does not establish that obesity causes poverty, so B reverses the causal claim. A and C contradict the word 'sidestep'; D captures its sense without adding an unsupported prediction.
L1 is regular and L2 is context-free. Which language need NOT be context-free? A L1∩L2; B L1·L2 (concatenation); C L1−L2; D L1∪L2.
Your answer
Answer & solution
Official answer: C
CFLs are closed under intersection with regular languages, concatenation with regular languages, and union with regular languages. They are not closed under complement, so choosing regular L1=Σ* makes L1−L2 the complement of a CFL, which need not be context-free. For a concrete witness, the complement of the non-context-free copy language {ww} is context-free; using that complement as L2 yields the non-CFL {ww}. Thus C.
A simpler explicit counterexample to closure under difference uses Σ={a,b,c}. Define L2=Σ*\{an bn cn:n≥0}. This is context-free: strings outside a*b*c* form a regular language; inside that regular pattern, unequal a/b counts or unequal b/c counts form a union of CFLs, each checkable by a PDA. With regular L1=Σ*, L1−L2 is the standard non-CFL {an bn cn}. For A, run the DFA alongside the PDA; for B,D, use standard CFL concatenation/union constructions because regular languages are also CFLs.
An array contains n integers. Let t be the optimal worst-case number of element comparisons needed to find both its minimum and maximum. Which printed bound is intended? A t>2n−2; B t>3⌈n/2⌉ and t≤2n−2; C t>n and t≤3⌈n/2⌉; D t>⌈log2 n⌉ and t≤n. The source gives no small-n restriction.
Your answer
Answer & solution
Official answer: C
Our answer: C for n≥5; small-n premise omitted
The optimal worst-case comparison count for simultaneous minimum and maximum is ceil(3n/2)−2. Compare elements in pairs, then compare each pair’s smaller element only against the running minimum and its larger element only against the running maximum; for even n this costs 3n/2−2, and for odd n it costs 3(n−1)/2. The standard adversary lower bound matches these counts. Consequently n<t≤3ceil(n/2) for n≥5, giving intended C. Literal qualification: for n=3 or 4, t=n, and for n=1 or 2 it is smaller, so the strict inequality in C is not valid for every unspecified n.
For even n, first compare one pair to initialize min/max (1 comparison); each of the remaining (n−2)/2 pairs needs one internal comparison and two comparisons with min/max. Total 1+3(n−2)/2=3n/2−2. For odd n, initialize both extrema to the first value for free, then spend three comparisons for each of (n−1)/2 pairs. Pseudocode for each pair (a,b): compare a,b; let lo=min(a,b), hi=max(a,b); compare lo with running_min and hi with running_max. For the matching lower bound, each nonmaximum needs a loss certificate and each nonminimum a win certificate, totaling 2n−2 certificates. An adversary classifies elements as untouched, winner-only, loser-only or both, and consistently places winner-only elements above loser-only elements. Comparing two untouched elements can create two certificates, but such comparisons are disjoint and number at most floor(n/2). Other comparisons can be answered to create at most one new certificate. Therefore at least 2n−2−floor(n/2)=ceil(3n/2)−2 comparisons are needed. This proof concerns worst-case comparisons, not a particular presorted input.
Let f1=10^n, f2=n^(log n), and f3=n^(√n). Arrange by increasing asymptotic growth. A f3,f2,f1; B f2,f1,f3; C f1,f2,f3; D f2,f3,f1.
Your answer
Answer & solution
Official answer: D
Taking logarithms gives log f2=Θ((log n)²), log f3=√n log n, and log f1=n log10. Since (log n)²=o(√n log n) and √n log n=o(n), the increasing order is f2, f3, f1, D.
Logarithms are strictly increasing on positive values, so their comparison preserves the order. Ratios of logarithms settle both gaps: (log n)²/(√n log n)=(log n)/√n→0 and (√n log n)/n=(log n)/√n→0. Consequently f2/f3 and f3/f1 tend to zero. The phrase 'n raised to log n' is not n log n; misreading the exponent would change the classification.
S1: The sequence of procedure calls is a preorder traversal of the activation tree. S2: The sequence of procedure returns is a postorder traversal. Which is correct? A S1 true/S2 false; B S1 false/S2 true; C both true; D both false.
Your answer
Answer & solution
Official answer: C
A procedure activation is entered before its child calls, producing preorder. It returns only after its nested calls finish, producing postorder. Thus both statements are true, C, in the ordinary sequential, properly nested call-return model.
For example, if main calls A, A calls B and C in order, and main then calls D, the entry order is main,A,B,C,D. The completion order is B,C,A,D,main. These are exactly preorder and postorder on the ordered activation tree. Recursive calls create distinct activation nodes even when the procedure name repeats; one must not merge all calls of the same procedure into a single node.
S1: Every SLR(1) grammar is unambiguous, but some unambiguous grammars are not SLR(1). S2: For every context-free grammar there is a parser taking at most O(n³) time for an input of length n. Which is correct? A S1 true/S2 false; B S1 false/S2 true; C both true; D both false.
Your answer
Answer & solution
Official answer: C
A conflict-free SLR(1) table yields a unique parse, so every SLR(1) grammar is unambiguous. The converse fails: the standard grammar S→L=R|R, L→*R|id, R→L is unambiguous but has an SLR shift-reduce conflict. General CFG recognition and construction of a parse can be done in O(n³) for a fixed grammar, for example by Earley parsing or CYK after normalization. Thus both statements hold, C; this does not claim that exponentially many parse trees can all be listed in cubic time.
In the counterexample grammar, the LR(0) state after recognizing L contains S→L·=R and R→L·. Since '=' belongs to FOLLOW(R), SLR would both shift '=' and reduce R→L there. Thus unambiguity alone does not remove SLR conflicts. For cubic parsing, CYK stores whether each nonterminal derives each substring and considers O(n) split points for O(n²) substrings; the fixed grammar contributes only a constant factor. A parse witness can be recovered by stored backpointers.
A number is 210 in base 3. What is its hexadecimal representation? A 15; B 21; C D2; D 528.
Your answer
Answer & solution
Official answer: A
Step through it (8 steps)
The ternary numeral 210 represents 2·3²+1·3=21 decimal. Since21=1·16+5, its hexadecimal representation is 15, A.
The positional expansion is 2×9+1×3+0×1=21. Converting that decimal result to base 16 gives quotient 1 and remainder 5. Conversely hexadecimal 15 evaluates to 16+5=21, providing a reverse check. The visible digits 210 are not a decimal number to be converted directly.
For propositions p,q, let S1=(¬p∧(p∨q))→q and S2=q→(¬p∧(p∨q)). Which are tautologies? A both; B S1 only; C S2 only; D neither.
Your answer
Answer & solution
Official answer: B
The antecedent ¬p∧(p∨q) simplifies to ¬p∧q. Therefore S1 is (¬p∧q)→q, a tautology. S2 is q→(¬p∧q), which is false when p=q=true. Hence only S1 is a tautology, B.
Distributivity gives ¬p∧(p∨q)=(¬p∧p)∨(¬p∧q)=¬p∧q. Any valuation making S1's antecedent true already makes q true, so it cannot be a false implication. To refute S2 it suffices to exhibit one valuation: p=true,q=true makes antecedent true but consequent false. Tautology requires all valuations, not just some.
S1: The destination MAC address of an ARP reply is a broadcast address. S2: The destination MAC address of an ARP request is a broadcast address. Which is correct? A both true; B S1 true/S2 false; C S1 false/S2 true; D both false.
Your answer
Answer & solution
Official answer: C
In ordinary Ethernet ARP address resolution, a requester broadcasts because it does not yet know the target MAC address. The target learns the requester’s MAC from that request and unicasts the reply to it. Thus S1 is false and S2 true, C. This describes the normal request/reply exchange, not gratuitous ARP or implementation-specific unicast refresh traffic.
The requester already knows the destination IP but lacks its link-layer address. It therefore sends an Ethernet broadcast asking which host owns that IP. The request includes the requester's own sender MAC/IP, so the responding target has the information needed for a unicast reply. Do not confuse the IP address being resolved with the Ethernet destination field the statements ask about.
For [23,32,45,69,72,73,89,97], which standard sorting algorithm uses the fewest comparisons between array elements to sort in increasing order? A selection sort; B mergesort; C insertion sort; D quicksort with last-element pivot.
Your answer
Answer & solution
Official answer: C
Step through it (4 runs)
The displayed eight elements are already sorted. Standard insertion sort makes one failed element comparison for each of the seven later elements, totaling 7. Selection sort makes 28; ordinary mergesort makes more than 7; last-element-pivot quicksort repeatedly chooses the largest element and makes 28. Therefore insertion sort uses the least, C, for the standard versions of the named algorithms.
For selection sort the unsorted suffixes have lengths 8,7,...,2, producing 7+6+...+1=28 comparisons. Balanced top-down mergesort uses 4 comparisons merging singletons, 4 merging the sorted pairs, then 4 merging the two sorted halves, totaling 12 on this input. Insertion sort compares each new key with its immediate predecessor and stops, totaling 7. Quicksort's last pivot is always the maximum, so its partition costs sum to 28 in the standard implementation.
A binary search tree T has n distinct elements. What is the time complexity of picking an element smaller than its maximum? A Θ(n log n); B Θ(n); C Θ(log n); D Θ(1). The task implicitly requires n≥2.
Your answer
Answer & solution
Official answer: D
If the root has a right child, the root itself is smaller than the maximum. If it has no right child, it is the maximum, so return its left child. For n≥2 that child exists in the latter case. Only a constant number of pointer tests is needed, Θ(1), D. The task implicitly needs at least two nodes; no such element exists for n=1.
An O(1) algorithm is: if root.right is non-null, return root.key; otherwise return root.left.key. In the first branch some right-subtree key is greater than the root, proving the root is not maximum. In the second branch the root is maximum; distinctness ensures its left child is strictly smaller. Searching for the second-largest element would be a different, potentially height-dependent task; the question asks for any smaller element.
Select all correct paging statements. A paging addresses external fragmentation; B page size has no impact on internal fragmentation; C paging incurs memory overhead; D multilevel paging is necessary to support different page sizes.
Select all that apply
Answer & solution
Official answer: A; C
Fixed-size page frames avoid external fragmentation, while partially filled pages still incur internal fragmentation whose amount depends on page size. Page tables and related translation metadata require memory overhead. Multiple page sizes can be supported without requiring multilevel page tables, so that mechanism is not logically necessary. Thus A, C.
External fragmentation means sufficient free space exists but is scattered into unusable variable-size gaps. Equal-sized frames avoid that requirement for contiguous allocation. Internal fragmentation occurs inside the final allocated page, potentially wasting almost one page per allocation. Translation requires page-table entries and sometimes additional levels or supporting structures. The number of page-table levels and the set of supported page sizes are separate design choices.
For Σ={0,1} and automaton encoding ⟨M⟩, select the languages that are NOT recursive. A {⟨M⟩: M is a DFA and L(M)=∅}; B {⟨M⟩: M is a DFA and L(M)=Σ*}; C {⟨M⟩: M is a PDA and L(M)=∅}; D {⟨M⟩: M is a PDA and L(M)=Σ*}.
Select all that apply
Answer & solution
Official answer: D
DFA emptiness is decidable by reachability of an accepting state. DFA universality is decidable by complementing the complete DFA and checking emptiness. PDA emptiness is decidable, for example by converting to a CFG and marking productive nonterminals. Universality of a general nondeterministic PDA/CFG is undecidable, so only D is not recursive.
A recursive language has an algorithm that halts on both yes and no instances. For DFA universality, first ensure the transition function is total by adding a sink if necessary, then invert final/nonfinal states and run a finite reachability test. PDA emptiness asks whether some derivation produces a terminal string, which productive-variable marking decides. PDA universality is a known undecidable CFG universality problem; enumerating accepted strings cannot certify that no unaccepted string exists.
A database crashes again while recovering from a previous crash. No checkpoints are taken during transactions or recovery. Select correct statements in the intended basic recovery model. A the same undo and redo lists are used on restarting recovery; B further recovery is impossible; C transactions already undone/redone will not be recovered again; D the database becomes inconsistent.
Select all that apply
Answer & solution
Official answer: A
Our answer: A in the basic repeated undo/redo model
Without a new checkpoint or changed transaction-completion history, restarting recovery analyzes the same log to identify the same committed and uncommitted transactions. Undo/redo actions are designed to be idempotent, so a second crash does not make recovery impossible or inherently inconsistent. Thus A in the intended basic log-recovery model. An implementation with compensation log records may track already completed recovery work more precisely; the answer is not a universal claim that every recovery algorithm literally repeats an unchanged physical work list.
Redo reapplies logged updates for transactions whose effects must survive; undo removes effects of incomplete transactions. Idempotence means redo(redo(state))=redo(state), with corresponding safe repeated undo semantics. A crash can leave only a prefix of recovery finished, so a correct recovery design cannot assume that restarting itself destroys consistency. No new checkpoint is available to certify that the earlier log prefix can be ignored. More elaborate logging of recovery work is precisely the qualification already retained above.
Which standard C library functions always invoke a system call when executed by a single-threaded UNIX/Linux process? Select all: A exit; B malloc; C sleep; D strlen.
Select all that apply
Answer & solution
Official answer: A; C
Normal process termination through exit eventually asks the kernel to terminate the process. A blocking sleep asks the kernel to suspend execution and arrange resumption. malloc can satisfy a request from existing user-space heap storage, and strlen scans user-space memory, so neither always needs a system call. Thus A, C in the ordinary UNIX/Linux library execution model. This is a systems-interface question, not a claim about abnormal nonreturning exit handlers or arbitrary replacement libraries.
Library routines are not synonymous with system calls. strlen needs only reads of its argument up to the terminating zero byte. malloc commonly obtains a larger region once, then fulfills many allocations from its own free lists without entering the kernel. In contrast, normal process exit changes kernel process state, and a blocking sleep requires kernel scheduling/timer support. The exam's 'always' language is interpreted under these normal library semantics.
A directory foo is implemented as an unsorted linear list of nodes containing file names and metadata including data-block pointers. Which successful operations necessarily require a full scan? A create a new file; B delete an existing file; C rename an existing file; D open an existing file.
Select all that apply
Answer & solution
Official answer: A; C
Our answer: A; C under fresh-name uniqueness checking
Creating a new file requires checking that its proposed name is absent from the entire unsorted directory list. Renaming to a new unused name similarly needs an absence check. Deletion or opening can stop when the existing entry is found, so they do not necessarily scan the entire list. Thus A, C under the intended simple-directory model. A real rename operation that is permitted to replace an existing target, or an indexed name cache, changes the necessity claim; those are outside this linear-list/fresh-name interpretation.
A successful lookup can stop at the matched name, perhaps the first node, so opening/deleting do not necessarily scan all nodes. To establish that a proposed new name is absent, finding no match in only a prefix is insufficient: it could occur in the unvisited suffix. Creation and a rename to a fresh name must therefore inspect the whole directory. The distinction is existential lookup versus proof of absence, not simply whether the operation changes disk contents.
A connected undirected planar graph has eight vertices and five faces. How many edges does it have? Count the unbounded face among the five.
Answer & solution
Official answer: 11
For a connected planar embedding, Euler’s formula is V−E+F=2, including the unbounded face. Hence E=8+5−2=11.
Rearrange Euler's formula as E=V+F−2 and substitute the given values. A tree would have E=V−1 and F=1, illustrating that the exterior region is a face. Here five faces imply four independent cycles, also checked by E−V+1=11−8+1=4. Omitting the exterior face would shift the answer by one.
Find the number of minimum-weight spanning trees in this undirected graph. Essential diagram: nine vertices in a 3×3 grid, named a,b,c (top row), d,e,f (middle), g,h,i (bottom). Edges and weights: ab=.1, bc=.1, de=.1, ef=.9, gh=.9, hi=.1, ad=.9, be=.9, cf=.9, dg=.1, eh=.1, fi=.1. There are no other edges.
Answer & solution
Official answer: 3
Step through it (13 steps)
The seven weight 0.1 edges form a forest with two components: the top row of three vertices and the remaining six vertices. All seven cheap edges can be included without a cycle. Connecting these components requires one weight 0.9 edge; exactly the three vertical links between the top and middle rows do so. Each choice gives total weight 1.6, and any tree using fewer cheap edges is more expensive. Therefore exactly 3 MSTs.
A spanning tree on nine vertices needs eight edges. The seven cheap edges are acyclic and leave precisely two components, so Kruskal's algorithm accepts all seven before considering weight .9. Among the expensive edges only ad,be,cf cross that component cut; ef and gh stay within the lower component and create cycles. Thus each MST contains seven cheap edges and one of those three cross edges. This proves both attainability and exhaustiveness rather than merely counting three plausible trees.
A component lifetime X is exponentially distributed with parameter 2. Find P(X>E[X]), rounded to two decimal places.
Answer & solution
Official answer: 0.35 to 0.39
Our answer: 0.37
For an exponential lifetime with rateλ, E[X]=1/λ and P(X>t)=e−λt. Therefore P(X>E[X])=e−1≈0.367879, rounding to 0.37, within the official 0.35–0.39 range. The result is the same if parameter2 is expressed as a scale rather than rate.
With rate λ=2 the mean is 1/2, so integrate the density: ∫_(1/2)^∞ 2e−2xdx=e−1. Equivalently use the survival function. If the printed 'parameter 2' were interpreted as scale θ=2, the mean would be 2 and survival at that mean would still be e−2/2=e−1. This invariant removes the rate-versus-scale convention issue for this particular question.
Assign six distinct jobs of distinct difficulty to three distinct computers of distinct speeds. The fastest must get the toughest job, the slowest the easiest, and each computer must receive at least one job. How many assignments are possible?
Answer & solution
Official answer: 65
Fix the toughest job on the fastest computer and the easiest on the slowest. Each of the four remaining distinct jobs has 3 destination choices, giving 3⁴. Subtract assignments that leave the middle-speed computer empty: all four then go to the other two computers, giving 2⁴. Thus3⁴−2⁴=81−16=65.
The extreme jobs are fixed, leaving four labeled jobs, not four indistinguishable units. The fastest and slowest computers are already nonempty, so only the middle computer requires an inclusion-exclusion correction. For a second count, assign exactly k of the four remaining jobs to the middle computer: Σ_(k=1)4 binom(4,k)24−k=32+24+8+1=65.
Evaluate lim(x→−3) (√(2x+22)−4)/(x+3), rounded to two decimal places.
Answer & solution
Official answer: 0.25
Rationalize the numerator: (√(2x+22)−4)/(x+3)=2/(√(2x+22)+4) for x≠−3. Taking x→−3 gives 2/(4+4)=1/4=0.25.
Direct substitution yields 0/0, an indeterminate form rather than an answer. Multiply numerator and denominator by √(2x+22)+4. The numerator becomes 2x+22−16=2(x+3), which cancels for x≠−3 in a punctured neighborhood. The remaining expression is continuous at −3. The derivative interpretation also works: the numerator is f(x)−f(−3) for f(x)=√(2x+22), so the limit is f'(−3)=1/4.
The first pop removes 52. After pushing 55 and 62, the next pop gives s=62. In the queue the first dequeue removes 21, leaving 24 at the front even after 28 and 32 are enqueued. Thus q=24 and s+q=86.
Write stack contents bottom-to-top: [54], [54,52], [54], [54,55], [54,55,62], then pop returns 62. Write queue contents front-to-back: [21], [21,24], [24], [24,28], [24,28,32], then dequeue returns 24. The stack is last-in-first-out and the queue first-in-first-out. Recording contents after every operation prevents confusing the earlier discarded pop/dequeue results with s and q.
A system has 2^32 bytes of byte-addressable main memory and a 32 KB direct-mapped cache, with 1 KB=2^10 bytes and 64-byte cache blocks. How many bits are in the address tag?
Answer & solution
Official answer: 17
Step through it (6 steps)
A byte address has 32 bits. The64-byte block uses 6 offset bits; 32KB/64=512 cache lines use 9 index bits. The remaining tag has 32−6−9=17 bits.
A direct-mapped address is partitioned into tag | line index | block offset. The offset selects one of 64 bytes, so it takes log2 64=6 bits. The data capacity contains 32768/64=512 lines, so index needs log2 512=9 bits. Address width is log2(232)=32 bits, leaving 17. Cache size is assumed to mean data capacity, as usual in this exercise, not data plus tag-store overhead.
A database relation r(A,B) is stated to contain 1200 tuples. A takes integer values 6 through 20 and B values 1 through 20; A and B are independently distributed. Estimate the output count of σ[(A>10) OR (B=18)](r). The source does not explicitly assume uniform distributions and its tuple count exceeds the distinct-pair domain size.
Answer & solution
Official answer: 819 to 820 OR 205
Our answer: 820 under uniform bag estimation; official also accepts 205
Under uniform independent attribute estimates, P(A>10)=10/15 and P(B=18)=1/20. Inclusion-exclusion gives selection fraction 10/15+1/20−(10/15)(1/20)=41/60. Multiplying by 1200 gives 820. The official key also accepts 205, which is the number of distinct qualifying pairs in the full 15×20 value grid: 200 pairs with A>10 plus 5 additional pairs with B=18. Both official alternatives are preserved exactly. Premise issues: independence alone does not imply uniform marginals, and a mathematical set relation with only these two finite-domain attributes can have at most 300 distinct tuples, not 1200. The820 estimate therefore uses bag/count statistics and uniformity assumptions; 205 corresponds to the distinct-pair grid, not 1200 distinct source tuples.
There are 15 A-values and 20 B-values. Ten A-values (11 through 20) pass A>10, while one B-value passes B=18. The overlap must be subtracted because OR counts a tuple satisfying both only once. Under the full-grid model there are 10×20+15×1−10×1=205 qualifying pairs out of 300, so the selectivity is 205/300=41/60. Applying that fraction to the stated 1200 rows yields 820. These are distinct interpretations, not two different arithmetic roundings of one count.
In IEEE 754 single precision (bias 127), S=1, E=10000001, F=11110000000000000000000. Find the represented decimal value, rounded to two decimal places.
Answer & solution
Official answer: -7.75 to -7.75
Our answer: -7.75
Step through it (5 steps)
The sign is negative. The exponent field 10000001₂=129 gives exponent 2 after subtracting bias 127. The significand is 1.1111₂=31/16. Hence value=−(31/16)·2²=−31/4=−7.75.
For a normalized single-precision number the formula is (−1)S(1.F)_2×2E−127. The stored fraction is .1111₂=1/2+1/4+1/8+1/16=15/16; the hidden leading 1 gives 31/16. E=129 is neither zero nor all ones, so neither subnormal nor infinity/NaN rules apply. Multiplication by 4 yields 7.75, and the sign bit makes it negative.
Three processes arrive at time zero with CPU bursts 16,20,10 milliseconds. With prior burst knowledge and non-preemptive scheduling, what is the minimum average waiting time, rounded to the nearest integer in milliseconds?
Answer & solution
Official answer: 12
Shortest-job-first minimizes total waiting time when all jobs arrive together and burst lengths are known. Execute bursts 10, 16, 20. Their waiting times are 0, 10, 26, whose average is 36/3=12 milliseconds.
For three jobs of lengths a,b,c in that order, total waiting is 0+a+(a+b)=2a+b. Placing shorter jobs earlier minimizes this weighted sum. More generally, swapping adjacent lengths x>y reduces the waiting total by x−y while leaving later completion times unchanged. This exchange argument proves shortest-job-first is optimal here. Completion/turnaround times would be 10,26,46 and are not the requested waiting times.
A grammar and SDT are: P→D* E*; D→int ID records the identifier as int; D→bool ID records it as bool; E→E1+E2 checks E1.type=E2.type=int and sets E.type=int; E→!E1 checks E1.type=bool and sets E.type=bool; E→ID unconditionally sets E.type=int. Which claim holds? A correctly type-checks every syntactically correct program; B type-checks syntactically correct integer declarations and integer expressions; C type-checks syntactically correct boolean declarations and boolean expressions; D leads to an infinite loop.
Your answer
Answer & solution
Official answer: B
The ID expression action unconditionally sets its type to int instead of consulting the declarations. Consequently integer-only, properly declared expressions using + receive the intended types, but a declared boolean is still labeled int and a valid negation can be rejected. The finite semantic actions do not themselves loop. Thus B. As usual, the limited claim assumes the mentioned integer identifiers have valid declarations; the displayed action does not implement undeclared-variable checking.
Trace a valid boolean declaration/expression: bool flag; !flag. The declaration records bool, but E→ID labels flag as int; the negation action then demands bool and rejects a valid expression. Conversely int a; int b; a+b labels both operands int and passes. A corrected ID action would look up ID.lexeme in the symbol table, reject undeclared identifiers, and copy the declared type. Thus the exact defect is the unconditional int assignment, not the grammar's use of repetition.
empAge(empNo,age) stores ages of 500 employees, with empNo a key. Evaluate π_empNo(empAge ⋈_[age>age1] ρ_[empNo1,age1](empAge)). A employee numbers with maximum age only; B those older than exactly one other employee; C all those whose age is not minimum; D all those with minimum age.
Your answer
Answer & solution
Official answer: C
The renamed second copy supplies another employee’s age. The theta join retains a first-copy employee whenever some other row has a strictly smaller age. Projecting empNo therefore returns exactly employees whose age is not the minimum. Minimum-age ties are all excluded. Thus C.
The join is existential after projection: an employee appears if there exists any employee of smaller age. An employee of minimum age has no such witness and is excluded, even if multiple employees tie for minimum. For ages 20,20,30,40 the output contains the 30- and 40-year-old employee numbers. The 40-year-old has several witnesses, but set projection removes duplicates; it is not restricted to 'exactly one' younger employee.
A synchronous three-bit T-flip-flop counter has outputs P,Q,R and common clock. The circuit connects R to T_P, complemented P to T_Q, and complemented Q to T_R. Starting at PQR=000, what are its next three states? A 011,101,000; B 001,010,111; C 011,101,111; D 001,010,000.
Your answer
Answer & solution
Official answer: A
The inspected wiring gives T_P=R, T_Q=¬P, T_R=¬Q, with a shared clock. Since a T flip-flop updates by Q_next=Q XOR T, the simultaneous transition equations are P_next=P XOR R, Q_next=Q XOR ¬P, R_next=R XOR ¬Q. From000 they give 011, then 101, then 000. Thus A. Every right-hand side uses the old state.
The transition trace is: old 000 gives T=(0,1,1), new 011; old 011 gives T=(1,1,0), new 101; old 101 gives T=(1,0,1), new 000. A T input of 0 holds its flip-flop and 1 toggles it. Since all receive the same clock, updating P first and then using the new P to compute Q would incorrectly simulate a sequential program instead of a synchronous circuit.
A 12-bit Hamming codeword is d8 d7 d6 d5 c8 d4 d3 d2 c4 d1 c2 c1, listed from left to right. Data d8...d1 are 1,1,0,x,0,1,0,1; check bits c8,c4,c2,c1 are y,0,1,0. Find x,y. A 0,0; B 0,1; C 1,0; D 1,1.
Your answer
Answer & solution
Official answer: A
Step through it (5 steps)
Number codeword positions from the right. The c2 parity group at positions 2, 3, 6, 7, 10, 11 already has four ones, establishing even parity. The c1 group at 1, 3, 5, 7, 9, 11 has 2+x ones, so x=0. The c8 group at 8, 9, 10, 11, 12 then has y+2 ones, so y=0. Thus A. This uses the parity convention inferred from the supplied known check group, not an unprovided arbitrary choice.
The positions from right to left are 1:c1=0,2:c2=1,3:d1=1,4:c4=0,5:d2=0,6:d3=1,7:d4=0,8:c8=y,9:d5=x,10:d6=0,11:d7=1,12:d8=1. Each parity check includes positions whose binary index has its corresponding bit set. After x=y=0, c4's group {4,5,6,7,12} also has two ones, verifying consistency with the parity convention inferred from c2.
The printed recurrence is T(n)=T(n/2)+T(2n/5)+7n for n>0, and T(0)=1. Under the intended integer-rounded or terminating-cutoff interpretation, select its tight order. A Θ(n^(5/2)); B Θ(n log n); C Θ(n); D Θ((log n)^(5/2)). The printed recurrence itself omits a rounding/cutoff convention.
Your answer
Answer & solution
Official answer: C
Our answer: C under terminating integer-size recurrence convention
The two recursive subproblem sizes sum to 0.9n. Thus the nonrecursive work over successive levels is bounded by 7n[1+0.9+0.9²+…]=70n. A terminating rounded-size recursion tree has O(n) leaves, so constant leaf costs do not alter the upper bound. The root alone costs 7n, giving Ω(n), hence Θ(n), C. Literal qualification: exact real-valued subproblem sizes never reach 0 from positive n, and the only printed base case is n=0. Integer rounding or a positive-size cutoff is therefore implicit; without such a convention the displayed recursion is not a terminating algorithm.
An induction makes the linear upper bound concrete: for floor-rounded subproblems and n≥1, assume T(k)≤Ck+D for smaller k. Then T(n)≤.9Cn+2D+7n, so any C sufficiently above 70 absorbs the constant excess for large n; enlarge constants for finitely many small cases. Alternatively a positive cutoff and geometric level sum yield the same result. Applying the equal-subproblem Master theorem directly would be invalid because the two recursive sizes differ.
For terminals {a,b,c,d,f}, grammar S→daT|Rf, T→aS|baT|ε, R→caTR|ε has a partially filled LL(1) table. Numbered cells are 1=(S,c), 2=(S,f), 3=(T,c), 4=(T,$). Known cells are (S,d)=S→daT; (T,a)=T→aS; (T,b)=T→baT; (T,f)=T→ε; (R,c)=R→caTR; (R,f)=R→ε; other unnumbered cells blank. Choose entries (1,2,3,4): A (S→Rf,S→Rf,T→ε,T→ε); B (blank,S→Rf,T→ε,T→ε); C (S→Rf,blank,blank,T→ε); D (blank,S→Rf,blank,blank).
Your answer
Answer & solution
Official answer: A
Step through it (2 parts)
FIRST(R)={c,ε}, so FIRST(Rf)={c, f}; both numbered S-row cells contain S→Rf. From R→caTR, c belongs to FOLLOW(T), and nullable R carries FOLLOW(R)={f} into FOLLOW(T). From S→daT and T→aS, the start marker $ also reaches FOLLOW(T). Thus FOLLOW(T)={c, f,$}, and the numbered T-row cells at c and $ contain T→ε. Therefore A.
The FIRST rule puts A→α in every terminal column of FIRST(α) except ε. When α is nullable, put it in all FOLLOW(A) columns. For S→Rf, R can start with c or disappear, exposing f. For T→ε, the c column comes from T followed by R in R→caTR; the f column comes from the following nullable R and S→Rf; the end marker flows from start S through S→daT. No guessed table entry is needed once these sets are computed.
Similar questions10 more → · asked again: GATE 2007, Q64
Transactions & Concurrency Control
Tap to enlarge
Let ri(z),wi(z) denote reads/writes by transaction Ti. S1=r1(x),r1(y),r2(x),r2(y),w2(y),w1(x). S2=r1(x),r2(x),r2(y),w2(y),r1(y),w1(x). Which schedules are conflict-serializable? A S1 only; B S2 only; C both; D neither.
Your answer
Answer & solution
Official answer: B
Step through it (2 schedules)
In S1, r1(y) before w2(y) gives T1→T2, while r2(x) before w1(x) gives T2→T1, creating a cycle. In S2, w2(y) before r1(y) and r2(x) before w1(x) both give only T2→T1. Therefore S1 is not conflict-serializable while S2 is, equivalent to T2 thenT1. Answer B.
Only different transactions accessing the same item, with at least one write, create precedence edges. Reads of x by both transactions do not conflict. In S1, y imposes T1 before T2 whereas x imposes T2 before T1, making a directed cycle. Moving r1(y) after w2(y) in S2 reverses the y constraint; all constraints now agree. An acyclic precedence graph is the necessary and sufficient test for conflict serializability.
R(P,Q,S,T,X,Y,Z,W) has FDs PQ→X, P→YX, Q→Y, Y→ZW. D1 decomposes it into (P,Q,S,T),(P,T,X),(Q,Y),(Y,Z,W). D2 decomposes it into (P,Q,S),(T,X),(Q,Y),(Y,Z,W). Which is correct? A D1 lossless/D2 lossy; B D1 lossy/D2 lossless; C both lossless; D both lossy.
Your answer
Answer & solution
Official answer: A
Step through it (2 parts)
For D1, join PQST with PTX on PT: P→X makes PT a key of PTX, so this step is lossless. Join QY using Q→Y, then YZW using Y→ZW; both steps are lossless. D2 separates TX from every other component, leaving no common attribute to reconnect it. A concrete legal relation can contain two rows with distinct P, Q, S, T, X, Y, Z, W values; all listed FDs hold, but joining its D2 projections pairs each TX row with either other-part row, creating spurious tuples. Thus D1 is lossless and D2 lossy, A.
For D1, add projections in the order PQST,PTX,QY,YZW. Their intersections with the accumulated schema are PT,Q,Y respectively, each determining all attributes of the new projection via P→X,Q→Y,Y→ZW. The binary lossless-join criterion applies at each step. For D2 use two original tuples (p1,q1,s1,t1,x1,y1,z1,w1) and (p2,q2,s2,t2,x2,y2,z2,w2) with every subscripted value distinct. All FDs hold, yet the join contains (p1,q1,s1,t2,x2,y1,z1,w1), which was not an original tuple.
G is a group of order 6 and H is a subgroup with 1<|H|<6. Which is correct? A both always cyclic; B G may not be cyclic but H always is; C G always cyclic but H may not be; D neither need be cyclic.
Your answer
Answer & solution
Official answer: B
Lagrange’s theorem makes the nontrivial proper subgroup order either 2 or 3. A group of prime order is cyclic, so H is always cyclic. G need not be cyclic: the permutation group S3 has order 6 and is nonabelian. Thus B.
Lagrange's theorem says |H| divides |G|=6, so the proper nontrivial choices are exactly 2 and 3. In a group of prime order p, any nonidentity element has order dividing p and greater than 1, hence order p; its powers generate the whole group. To disprove cyclicity of G it is enough to give one counterexample, S3. A cyclic group of order 6 also exists, so 'may not' is the appropriate wording rather than 'never'.
S1: There exist random variables X,Y for which (E[(X−E[X])(Y−E[Y])])²>Var[X]Var[Y]. S2: For all X,Y, Cov[X,Y]=E[|X−E[X]| |Y−E[Y]|]. Which is correct? A both true; B S1 true/S2 false; C S1 false/S2 true; D both false. Variances/covariances are understood to exist.
Your answer
Answer & solution
Official answer: D
For finite second moments, Cauchy–Schwarz gives Cov(X, Y)²≤Var(X)Var(Y), contradicting S1’s strict greater-than claim. S2 incorrectly inserts absolute values. For a nonconstant mean-zero random variable X and Y=−X, covariance is−Var(X), while the proposed expectation of absolute deviations is+Var(X). Both statements are false, D.
Let U=X−E[X], V=Y−E[Y]. Cauchy–Schwarz says |E[UV]|≤√(E[U²]E[V²]); squaring establishes the opposite of S1's strict inequality. For S2 take X equally likely ±1 and Y=−X. Means are zero, Cov(X,Y)=E[−X²]=−1, while E[|X||Y|]=1. The sign information removed by absolute values is essential to covariance.
G is an undirected unweighted connected graph with adjacency matrix M and diameter equal to its largest shortest-path distance. Let P=M² and define G2 on the same vertices by N_ij=1 if M_ij>0 or P_ij>0, otherwise 0. Which holds universally? A diam(G2)≤⌈diam(G)/2⌉; B ⌈diam(G)/2⌉<diam(G2)<diam(G); C diam(G2)=diam(G); D diam(G)<diam(G2)≤2 diam(G).
Your answer
Answer & solution
Official answer: A
G2 connects vertices whose original distance is at most 2. A shortest G path of lengthd can be compressed into ceil(d/2) G2 edges. Conversely each G2 edge expands into at most 2 G edges, so no shorter G2 path than ceil(d/2) is possible. Thus d_G2(u, v)=ceil(d_G(u, v)/2), and diam(G2)=ceil(diam(G)/2), which in particular satisfies A’s ≤ bound. Self-loops from M² do not shorten distances.
Each positive entry of M² represents a two-edge walk, so a G2 edge can cover at most two original edges. A d-edge shortest path can be grouped into pairs, with one singleton if d is odd, giving an upper bound ⌈d/2⌉. Expanding any k-edge G2 path yields a G walk of at most 2k edges, proving k≥⌈d/2⌉. Taking the maximum over all vertex pairs establishes equality, which is stronger than the selected non-strict bound.
What happens in this ANSI C program? #include <stdio.h> int main(void){ 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; } A fails compilation; B compiles and prints 10; C compiles and prints 8; D compiles and prints 13.
Your answer
Answer & solution
Official answer: B
Step through it (35 steps)
For j=−3,−2,−1 the left operand of && is false, so i++ is not evaluated. At j=0 the old i=0 makes the condition false, but increments i to 1. At j=1, 2, 3 the old i is nonzero, adding 1+2+3=6 while i reaches 4. The final addition gives count=6+4=10. Thus B. Short-circuiting and postincrement order are defined by C.
A compact trace (j, i after condition, count after body) is (−3,0,0),(−2,0,0),(−1,0,0),(0,1,0),(1,2,1),(2,3,3),(3,4,6). Postincrement yields the old value as the expression result, then changes i. The logical AND operator sequences and short-circuits its operands, so the first three iterations do not increment i at all. The final statement adds the final i=4 once, obtaining 10 without undefined unsequenced modifications.
Which DFA recognizes exactly binary strings ending in 011? Essential transition-table descriptions of the four diagrams: all have states q0,q1,q2,q3, start q0, only q3 accepting. Common transitions: q0 on 0→q1 and on 1→q0; q1 on 0→q1 and on 1→q2; q2 on 0→q1 and on 1→q3. The differing q3 transitions (on 0,on 1) are A (q1,q3); B (q3,q3); C (q1,q2); D (q1,q0).
Your answer
Answer & solution
Official answer: D
Label the four states by the longest suffix matching a prefix of 011: ε, 0, 01, 011. Their transitions on(0, 1) are respectively(0,ε),(0, 01),(0, 011),(0,ε). Only the 011 state accepts. These transitions are exactly D. A wrongly accepts 0111, B keeps accepting after arbitrary suffixes, and C accepts 01111 despite its final three symbols being 111.
The invariant is that the state remembers the longest suffix of the input that is also a prefix of the target 011. After reading 0111 there is no nonempty suffix that is such a prefix, so the accepting state's 1-transition must return to q0. After reading 0110, the suffix 0 remains useful, so its 0-transition must go to q1. These two checks distinguish D from the three other diagrams while the invariant proves correctness for arbitrary input lengths.
For Turing-machine encodings ⟨M⟩, L1={⟨M⟩: M takes more than 2021 steps on all inputs}, L2={⟨M⟩: M takes more than 2021 steps on some input}. Which is correct? A both decidable; B L1 decidable/L2 undecidable; C L1 undecidable/L2 decidable; D both undecidable.
Your answer
Answer & solution
Official answer: A
A computation limited to 2021 steps can inspect only finitely many input positions. Enumerate all finite relevant prefixes, including end-of-input cases, and simulate M for that fixed bound on each representative. Check whether all representatives run longer than 2021 for L1, or at least one does for L2. Both procedures terminate, despite a very large finite enumeration. Therefore both languages are decidable, A.
This is bounded-time behavior, unlike the unbounded halting problem. In 2021 steps a standard single-tape input head can visit only a bounded initial portion of the input; choose a conservative prefix bound 2022 and include all shorter words and all words of that prefix length as representatives for longer inputs. Simulate each for exactly the fixed bound, detecting whether it halts within it. The enumeration is enormous but finite, which is sufficient for decidability; no practical polynomial-time claim is made.
Let R_n be the maximum revenue from cutting a rod of integer length n into one or more integer-length pieces. Prices for lengths 1,...,7 are 1,5,8,9,10,17,18. Select all true statements: A R7=18; B R7=19; C R7 is achieved by three different solutions; D no three-piece solution achieves R7. Different piece orders are not different cutting solutions.
Select all that apply
Answer & solution
Official answer: A; C
With R0=0 and Rn=max1≤i≤n(p[i]+Rn−i), the values R1,…, R7 are 1, 5, 8, 10, 13, 17, 18. Revenue18 is achieved by exactly the three unordered partitions 7; 6+1; 3+2+2. The last uses three pieces, so D is false, and 19 is not attainable. Hence A, C. Different orders of the same piece lengths are not counted as distinct cutting solutions.
Dynamic-programming pseudocode: R[0]=0; for length=1..7: R[length]=max(price[i]+R[length−i] for i=1..length). At length 7 the candidates for first piece sizes 1..7 are 18,18,18,17,15,18,18. Backtracking optimal candidates and sorting piece lengths gives {7},{1,6},{2,2,3}; different first-piece choices can lead to the same sorted partition, so count each only once. The recurrence is exhaustive because every nonempty cutting solution has some first piece and an optimally solved remainder.
For a DFS tree T of a connected undirected graph G, select all true statements. A its root can never be an articulation point; B its root is an articulation point iff it has at least two DFS children; C a DFS leaf can be an articulation point; D if u is an articulation point, x is its ancestor and y its descendant in T, every graph path x→y must pass through u.
Select all that apply
Answer & solution
Official answer: B
The DFS root is an articulation point exactly when it has at least two DFS children. Distinct child subtrees have no connecting edge in an undirected DFS, whereas one child subtree remains connected after deleting the root. This proves B and disproves A. A DFS leaf cannot disconnect the remaining DFS tree when removed, so C is false. D is too strong: use edges x-u, u-y, y-x, u-z and DFS order x, u, y, z. Vertex u is an articulation point because its removal isolates z, but the edge x-y avoids u even though x is its ancestor and y its descendant.
For a nonroot vertex u, the actual test is whether some DFS child v has low[v]≥discovery[u], meaning that child's subtree lacks a back-edge to a strict ancestor of u. It does not assert that every descendant is trapped. The counterexample in the main derivation separates a trapped branch z from a branch y that can reach ancestor x by a back-edge. For the root, two distinct child subtrees cannot connect except through the root, or DFS would have explored them as one subtree.
Let F=(X+Y+Z)(¬X+Y)(¬Y+Z), where + is OR and adjacency AND. Select expressions equal to ¬F: A (¬X+¬Y+¬Z)(X+¬Y)(Y+¬Z); B X¬Y+¬Z; C (X+¬Z)(¬Y+¬Z); D X¬Y+Y¬Z+¬X¬Y¬Z.
Select all that apply
Answer & solution
Official answer: B; C; D
Step through it (14 steps)
If Z=0, the product is (X+Y)(NOT X+Y)(NOT Y)=Y(NOT Y)=0. If Z=1, it is NOT X+Y. Thus F=Z(NOT X+Y) and its complement is NOT Z+X(NOT Y), option B. By (a+b)(c+b)=ac+b, C is the same expression. Direct De Morgan expansion gives X(NOT Y)+Y(NOT Z)+(NOT X)(NOT Y)(NOT Z), exactly D. Option A is false, for example at X=0, Y=1, Z=0: it evaluates to 0 while the complement of F is 1.
Algebraically, (X+Y)(¬X+Y)=Y, so setting Z=0 makes F=Y¬Y=0. Setting Z=1 leaves only ¬X+Y. Hence ¬F=¬Z+X¬Y. Expanding C gives X¬Y+X¬Z+¬Y¬Z+¬Z, which absorbs to B. De Morgan on the original three factors gives D directly. Checking A at (X,Y,Z)=(0,1,0) yields a zero second factor (X+¬Y), whereas F=0 and its complement must be 1; this single assignment rules A out.
A relation R is circular when aRb and bRc imply cRa. Select the sufficient conditions for a relation S to be an equivalence relation: A reflexive and symmetric; B circular and symmetric; C reflexive and circular; D transitive and circular.
Select all that apply
Answer & solution
Official answer: C
If S is reflexive and circular, aSb together with bSb implies bSa, establishing symmetry. If aSb and bSc, circularity gives cSa, and symmetry then gives aSc; hence S is transitive as well, proving C. Reflexive and symmetric need not imply transitive: take all loops on {1, 2, 3}, pairs (1, 2),(2, 1),(2, 3),(3, 2), but omit (1, 3). This refutes A. The empty relation on a nonempty set is circular, symmetric and transitive but not reflexive, refuting B and D.
An equivalence relation must satisfy three independent obligations: reflexivity, symmetry, transitivity. Under C, reflexivity supplies bSb to combine with aSb and derive bSa by circularity. Once symmetry is established, aSb and bSc give cSa by circularity and then aSc by symmetry. The empty relation on any nonempty set satisfies every implication whose premise requires an existing pair, so it is circular, symmetric and transitive vacuously, yet it fails all reflexive loops. This explains both B and D counterexamples.
A TCP server listens on port P of host S and has an active client connection. S crashes and reboots. The client uses no TCP keepalive timer. Select possible behaviors: A a client waiting for a packet may wait indefinitely; B the restarted server can listen again on P; C a client packet after reboot receives RST; D a client packet after reboot receives FIN.
Select all that apply
Answer & solution
Official answer: A; B; C
A passive client with no keepalive, no pending retransmission and no application timeout can wait indefinitely after a silent server crash, so A is possible. After reboot the server can bind and listen on the same port again, so B is possible. The old established connection state is gone; a segment from that old connection can elicit a reset, not an orderly FIN, giving C rather than D. This is the standard reachable-server TCP response model; actual delivery can still be affected by packet loss or filtering, and a listening socket does not restore the lost connection.
A crash does not perform an orderly TCP close, so no reliable FIN is sent merely because the old connection disappeared. After reboot the endpoint has no matching established-connection state. A valid arriving old-connection segment is therefore rejected/reset in the standard reachable-host model rather than resuming that connection. Waiting indefinitely is a possibility, not a promise: an application timeout, retransmission timeout, keepalive, or network error could instead terminate a particular client's wait.
P sends a 1400-byte TCP segment to Q through router R. MTUs are 1500 bytes on P–R and 820 bytes on R–Q; IP headers are 20 bytes, identification 0x1234, and DF=0. Select true statements: A R creates two fragments and the second IP datagram is 620 bytes; B if the second fragment is lost, R retransmits it with ID 0x1234; C if it is lost, P must resend the whole TCP segment; D the TCP destination port can be obtained from the second fragment alone.
Select all that apply
Answer & solution
Official answer: A; C
The TCP segment is the 1400-byte IP payload. The original IP datagram is 1420 bytes and fits the first MTU. The second link allows 820-20=800 payload bytes per fragment, a multiple of eight. Fragment payloads are therefore 800 and 600 bytes, giving datagram sizes 820 and 620, so A holds. IP routers do not retransmit lost fragments, so B is false. Loss prevents reassembly of the original segment and TCP at P retransmits the unacknowledged data, corresponding to C in the ordinary unchanged-segmentation model. TCP may resegment retransmitted bytes in a more general implementation; it does not repair just the missing IP fragment. The TCP header is only in the first fragment, so the second alone does not reveal the destination port and D is false.
IPv4 fragment offsets count eight-byte units. The first fragment has offset 0, payload 800, total 820 and MF=1; the second has offset 100, payload 600, total 620 and MF=0. Both retain the original identification for reassembly. The receiver needs both to reconstruct the TCP segment. Reliable delivery belongs to TCP endpoints, not an IP router's fragment-repair service. A later TCP retransmission may choose new segmentation or a new IP identification; retaining the exam answer does not justify claiming otherwise.
Shared counter=0 and counting semaphore S=5. Five threads concurrently execute parop(){wait(S); wait(S); counter++; signal(S); signal(S);} The increment is explicitly non-atomic. Select possible outcomes: A counter=5 after all complete; B counter=1 after all complete; C counter=0 after all complete; D all five threads deadlock.
Select all that apply
Answer & solution
Official answer: A; B; D
Serially completing all five operations gives counter=5, proving A. For B, let one thread acquire two permits and read counter=0, then pause before writing. The other four can each acquire two of the remaining three permits, increment and finish sequentially. Finally the paused thread writes its stale result 1 and finishes. C cannot occur after successful completion: every write is a nonnegative value read plus one, so the final write is at least 1. For D, let each of the five threads acquire its first permit before any acquires a second. All then block on the second wait with no permit left and none able to signal. These are pseudocode read-modify-write interleavings, as explicitly assumed.
The semaphore limits simultaneous holders of permits but does not provide mutual exclusion for counter++: two threads can each hold two permits out of five. For final value 1, the crucial schedule is a delayed stale write from the first thread after the other four have successively completed. For deadlock, no thread reaches its first signal because every thread is stuck on its second wait. Replacing the two waits by one atomic acquisition of two permits would remove that particular hold-and-wait pattern, but that is not the given code.
Dynamic hashing uses a four-entry table indexed by the lowest two bits of four-bit integer keys. Collisions split into a binary tree by the third-lowest bit (0 left,1 right), then the fourth-lowest bit; split only when required. Target diagram: bucket 00 empty; bucket 01 splits at bit 3, with a leaf on branch 0 and a bit-4 split with two leaves on branch 1; bucket 10 splits at bit 3 into two leaves; bucket 11 has one leaf. Which insertion sequence yields it? A 5,9,4,13,10,7; B 9,5,10,6,7,1; C 10,9,6,7,5,13; D 9,5,13,6,10,14.
Select all that apply
Answer & solution
Official answer: C
The displayed shape requires bucket 00 empty; bucket 01 with one key having third-lowest bit 0 and two keys having third-lowest bit 1, separated by the fourth bit; bucket 10 with one key on each third-bit branch; and bucket 11 with one key. C supplies bucket01={9(1001), 5(0101), 13(1101)}, bucket10={10(1010), 6(0110)}, and bucket11={7(0111)}, exactly that structure. A puts 4 in bucket00, B splits the zero third-bit branch of bucket01 because it contains 1 and 9, and D leaves bucket11 empty while putting three keys in bucket10. Only C matches.
Process C explicitly: 10=1010 enters bucket10; 9=1001 enters bucket01; 6=0110 collides in bucket10 but differs from 10 in bit3, making its two leaves. Key 7=0111 occupies bucket11. Key 5=0101 collides with 9 in bucket01 and goes to its bit3=1 branch, whereas 9 has bit3=0. Finally 13=1101 joins 5 on bit3=1 and differs in bit4, producing exactly the extra split. A premature split without collision would violate the stated rule.
ANSI C function: 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;} Array Z has ten elements, all equal to 1. Find SimpleFunction(Z,10,2).
Answer & solution
Official answer: 1023
The loop performs Horner evaluation. Starting at total=1, each of the nine iterations replaces total by 2*total+1. After k iterations total=2^(k+1)-1, so after nine iterations the result is 2^10-1=1023. All intermediate results are within even the minimum standard signed-int range.
The values after initialization and each iteration are 1,3,7,15,31,63,127,255,511,1023. An induction proves total after k loop iterations is 2k+1−1: base k=0 is 1, and 2(2k+1−1)+1=2k+2−1. More generally the function evaluates Y[0]xn−1+Y[1]xn−2+...+Y[n−1] in n−1 multiplications, which is Horner's method.
A sliding-window protocol uses a full-duplex error-free link with negligible frame/ACK processing, unlimited queued frames, 2000-bit data frames, 10-bit ACK frames, 1 Mbps in each direction, and 100 ms one-way propagation. What is the minimum sender window in frames needed for 50% utilization (source asks nearest-integer rounding)?
Answer & solution
Official answer: 50 to 52
Our answer: 51
Step through it (6 steps)
A data frame takes 2000/106=2 ms to serialize; an ACK takes 10/106=0.01 ms. The earliest ACK for the first frame returns after 2+100+0.01+100=202.01 ms. For an unsaturated sliding window of W frames, utilization is W*2/202.01. Requiring at least 0.5 gives W>=50.5025, so the smallest integer window is 51. The official accepted interval is 50 to 52 and is retained, but the explicit ACK serialization and minimum-integer calculation give 51.
A cycle for the first frame includes its serialization, forward propagation, ACK serialization, and reverse propagation: 202.01 ms. In that interval W frames occupy the forward link for 2W ms, unless the link is already saturated. Hence utilization is min(1,2W/202.01). W=50 gives about 49.5025%, below the target, whereas W=51 gives about 50.4925%. This directly checks the minimum-integer result and explains why the wider official interval is preserved separately from the derivation.
A compiler represents this basic block by a common-subexpression DAG: a=b+c; e=a+1; d=b+c; f=d+1; g=e+f;. How many DAG nodes are needed? The symbol in the additions to a and d is the constant digit 1.
Answer & solution
Official answer: 6
The code uses the constant 1, not a variable i. A common-subexpression DAG has three leaves b, c, 1. One addition node b+c is labeled by both a and d. A second addition node (b+c)+1 is labeled by both e and f. The final addition node adds that second node to itself and is labeled g. Hence there are 3 leaves plus 3 operation nodes, totaling 6. Variable labels are not separate DAG nodes in this representation.
Name the six nodes: n1=b, n2=c, n3=constant 1, n4=+(n1,n2) labeled a,d, n5=+(n4,n3) labeled e,f, n6=+(n5,n5) labeled g. The code does not change b or c, so the two b+c expressions really share one node. Repeated variable names attached as labels are not new values/nodes. This is common-subexpression DAG construction, not a syntax tree that duplicates every appearance or algebraic strength reduction to multiplication.
A PDA has states q0,q1,q2,q3, start q0 and only final state q3, input {a,b} and stack alphabet {#,A}. Transition label input,pop→push is used, with ε meaning no input/pop/push. Transitions: q0→q1: ε,ε→#; q1 loop: a,ε→A; q1→q2: ε,ε→ε; q2 loop: b,A→ε; q2→q3: ε,A→A. There are no other transitions. How many length-100 strings are accepted by final state?
Answer & solution
Official answer: 50
The PDA first pushes its bottom marker, then pushes one A for each initial a. In the second phase it pops one A for each b. Reaching the final state requires an A still on top, so the language is am bn with m>n>=0. For total length 100, n can be any integer from 0 through 49, with m=100-n. Each choice determines one string, giving 50. The accepting-state transition preserves that remaining A; acceptance is by final state rather than empty stack.
While reading a's, the stack contains one A per a above #. After switching to q2, each b removes one A and no a-transition exists, enforcing the order a* b*. The final ε-transition tests and preserves an A, requiring strictly more a's than b's. For length 100, m+n=100 and m>n give 100−n>n, so n<50. Each n=0,...,49 gives one word a100−nbn, including a100; equality at n=50 is not accepted.
Find the largest eigenvalue of the 4×4 matrix whose diagonal entries are 0 and all off-diagonal entries are 1: rows (0,1,1,1),(1,0,1,1),(1,1,0,1),(1,1,1,0).
Answer & solution
Official answer: 3
The matrix is J-I, where J is the 4-by-4 all-ones matrix. The all-ones vector has eigenvalue 4 for J and therefore eigenvalue 3 for J-I. Every vector whose coordinates sum to zero has eigenvalue 0 for J and -1 for J-I; that subspace has dimension three. The full spectrum is 3,-1,-1,-1, so the largest eigenvalue is 3.
For any vector v, Jv is the vector whose four entries are sum(v). Thus v=(1,1,1,1) gives (J−I)v=3v. Every zero-sum vector gives (J−I)v=−v; examples (1,−1,0,0),(0,1,−1,0),(0,0,1,−1) form a basis for that three-dimensional subspace. These four independent eigenvectors account for the whole 4×4 matrix. The trace check 3−1−1−1=0 matches the zero diagonal.
A five-stage pipeline has stage delays 150,120,150,160,140 ns, and its interstage registers each have 5 ns delay. With no stalls, find the total execution time of 100 independent instructions in ns.
Answer & solution
Official answer: 17160
The clock period is the slowest combinational stage delay plus the pipeline-register delay: 160+5=165 ns. Five stages take five clocks for the first instruction and one clock for each of the remaining 99. Total cycles=5+99=104, so execution time is 104*165=17160 ns under the standard synchronous-pipeline timing convention.
The clock cannot use the average stage delay: every stage must finish before the next common edge, so the 160 ns stage controls. Add 5 ns register overhead once per clock interval to obtain 165 ns, rather than summing all register delays into one stage. The first instruction completes after five clocks and the hundredth after 99 additional clocks. This separates pipeline latency from steady-state throughput and avoids the error 100×5×165.
A sender transmits H with probability .1 and L with probability .9. Channel edge probabilities are P(received H|sent H)=.3, P(received L|sent H)=.7, P(received H|sent L)=.8, P(received L|sent L)=.2. Given that H was received, find the probability H was sent, rounded to two decimals.
Answer & solution
Official answer: 0.04
Bayes rule gives P(sent H given received H)=P(received H given sent H)P(sent H)/P(received H). The diagram gives 0.3 for H-to-H and 0.8 for L-to-H. The numerator is 0.3*0.1=0.03, and the denominator is 0.3*0.1+0.8*0.9=0.75. The conditional probability is 0.03/0.75=0.04.
Among an imagined 1000 transmissions, 100 are H and 900 are L. Expected received-H counts are 30 from sent-H and 720 from sent-L. Conditioning on received H therefore selects a population of 750, of which only 30 originated as H: 30/750=.04. The reversed conditional P(received H|sent H)=.3 is not the requested P(sent H|received H), because the prior probabilities differ greatly.
A byte-addressable machine starts this sequence at address 1000. Instruction, semantics, size in 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 to absolute address 1004 if not zero,2; HALT: stop,1. Initially MEMORY[5000]=10, R3=3000, and MEMORY[3000] through MEMORY[3010] are all 50. All numbers are decimal. Find MEMORY[3010] after execution.
Answer & solution
Official answer: 50
The four-byte first instruction at address 1000 initializes R1=10, and address 1004 is the next instruction, the loop entry. Each loop iteration updates MEMORY[R3], then increments R3 and decrements R1. BNZ tests the zero condition left by that decrement and returns to 1004 while R1 is nonzero. Exactly ten iterations update locations 3000 through 3009. After the tenth, R3 is 3010 and R1 is zero, so the program halts before writing location 3010. Its original value 50 is unchanged.
Instruction addresses are 1000,1004,1008,1010,1014,1016,1018,1020. Thus branching to 1004 skips the initialization at 1000. At iteration k=1,...,10 the address updated is 2999+k and R1 before decrement is 11−k, so memory values written are 60,59,...,51 at 3000,...,3009. The final increment makes R3=3010, but DEC makes R1=0 and the branch falls through to HALT. Merely pointing at 3010 does not write to it.