ops: A.
Capgemini technical mcq question, verified with a worked answer. Free to practise - no sign-up.
ops: A. 2,1,8 B. 4,1,8 Ans: 2,1,8 Suppose f(A,B)=A'+B. Simplified expression for function f(f(x+y,y),z) is : ops : A. x'+z B. xyz C. xy'+z D. None of the mention options Answer: xy'+z The number of control lines for a 8-to-1 multiplexer is: ops : A. 3 B. 4 C. 2 D. 5 Ans: 3 4. Stack is useful for implementing: Ans: Both(A) & (B) 5. HUB is a _______ device and switch is a ________ de - A) 4,4,8 D. 2,4,8 - B) recursion B. depth first search C. both (A) & (B) - C) breadth first search
Show answer & explanation
The question asks what a Stack is useful for implementing. Stacks are the fundamental data structure used to manage function calls in recursion and are the primary mechanism for tracking visited nodes in a Depth First Search (DFS) algorithm.
Step-by-step Derivation:
Step 1: Analyze the data structure 'Stack'. A stack follows the Last-In-First-Out (LIFO) principle.
Step 2: Evaluate 'Recursion'. When a function calls itself, the system pushes the current state (return address, local variables) onto the call stack. Therefore, recursion is implemented using a stack.
Step 3: Evaluate 'Depth First Search (DFS)'. DFS explores as far as possible along each branch before backtracking. This backtracking mechanism is implemented using either an explicit stack or the implicit call stack of recursion.
Step 4: Since both recursion and DFS rely on stack behavior, the correct answer is 'Both (A) & (B)'.
Step 5: Match this conclusion to the provided options. Option B contains the text 'recursion', 'depth first search', and 'both (A) & (B)'.