Placement Prep

10 Technical Aptitude Questions: Set 3 (Solved)

Set 3 of solved technical aptitude questions covering data structures, DBMS, OS, networking, and OOP: the mix campus drives test most often.

By FACE Prep Team 7 min read
technical-interview aptitude data-structures dbms operating-systems campus-placement placement-prep

Campus placement technical rounds test a predictable spread: data structures, algorithms, DBMS, OS, networking, and OOP. This set covers all six with step-by-step derivations.

Each question below follows the format seen in TCS NQT, Infosys, Wipro, and Capgemini technical aptitude sections. Work through the solution before reading the explanation.

Data Structures (Questions 1–2)

Q1: Stack Operation Trace

  • Problem: Given the following sequence on an initially empty stack, what are the contents from bottom to top after all operations complete?
push(5), push(8), push(3), pop(), push(2), pop(), push(7)
  • Options:

    • A. 5, 8, 7
    • B. 5, 7
    • C. 5, 8, 2, 7
    • D. 5, 3, 7
  • Answer: A

  • Trace:

    • push(5) → [5]
    • push(8) → [5, 8]
    • push(3) → [5, 8, 3]
    • pop() → removes 3 → [5, 8]
    • push(2) → [5, 8, 2]
    • pop() → removes 2 → [5, 8]
    • push(7) → [5, 8, 7]
  • Key concept: A stack is LIFO. Each pop() removes only the most recently pushed element. Drawing the trace takes 15 seconds and eliminates guessing.

Q2: Reconstruct Binary Tree Traversal

  • Problem: Given inorder and preorder traversals, determine the postorder traversal.

    • Inorder: D, B, E, A, F, C
    • Preorder: A, B, D, E, C, F
  • Options:

    • A. D, E, B, F, C, A
    • B. D, B, E, F, C, A
    • C. D, E, F, B, C, A
    • D. E, D, B, F, C, A
  • Answer: A

  • Derivation:

    • Preorder first element = root = A
    • In inorder, A splits: left subtree = [D, B, E], right subtree = [F, C]
    • Left subtree preorder = [B, D, E]. Root of left = B. Splits left-inorder: left-left = [D], left-right = [E]
    • Right subtree preorder = [C, F]. Root of right = C. Splits right-inorder: right-left = [F], right-right = empty
    • Postorder (left, right, root): D, E, B, F, C, A
  • Complexity: O(n) with a hash map for inorder index lookups; O(n squared) with linear search.

Algorithms (Questions 3–4)

Q3: Time Complexity of Nested Loop

  • Problem: What is the time complexity of the following code?
for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
        printf("%d %d\n", i, j);
    }
}
  • Options:

    • A. O(n)
    • B. O(n log n)
    • C. O(n squared)
    • D. O(2 to the power n)
  • Answer: C

  • Derivation:

    • When i=1, inner loop runs 1 time
    • When i=2, inner loop runs 2 times
    • When i=n, inner loop runs n times
    • Total iterations = 1 + 2 + … + n = n(n+1)/2 = O(n squared)
  • Pattern: Any nested loop where the inner bound depends linearly on the outer variable produces the arithmetic series sum. This pattern drives selection sort, bubble sort, and insertion sort.

Q4: Binary Search Comparison Count

  • Problem: In a sorted array [2, 5, 8, 12, 16, 23, 38, 56, 72, 91], how many comparisons does binary search need to find 23?

  • Options:

    • A. 2
    • B. 3
    • C. 4
    • D. 5
  • Answer: B

  • Trace (0-indexed):

    • Iteration 1: low=0, high=9, mid=4. Array[4]=16. Since 23 > 16, set low=5.
    • Iteration 2: low=5, high=9, mid=7. Array[7]=56. Since 23 < 56, set high=6.
    • Iteration 3: low=5, high=6, mid=5. Array[5]=23. Found.
    • Total comparisons: 3
  • Bound: Binary search on 10 elements needs at most ceil(log2(10)) = 4 comparisons. For related pattern-based problems, see Pascal’s triangle printing which also uses index arithmetic.

DBMS (Questions 5–6)

Q5: SQL INNER JOIN Output

  • Problem: Given two tables:
Students
idnamedept_id
1Ravi101
2Priya102
3Karthik105
Departments
dept_iddept_name
101CSE
102ECE
103EEE

What does this query return?

SELECT name, dept_name
FROM Students INNER JOIN Departments
ON Students.dept_id = Departments.dept_id;
  • Options:

    • A. Ravi-CSE, Priya-ECE, Karthik-NULL
    • B. Ravi-CSE, Priya-ECE
    • C. Ravi-CSE, Priya-ECE, NULL-EEE
    • D. All 3 students with all 3 departments (9 rows)
  • Answer: B

  • Explanation: INNER JOIN returns only rows where the join condition matches in both tables. Karthik’s dept_id (105) has no match in Departments, so he is excluded. EEE (103) has no matching student, so it is also excluded. LEFT JOIN would include Karthik with NULL; CROSS JOIN without a condition would produce 9 rows.

Q6: Identify the Normal Form

  • Problem: Relation R(A, B, C, D) has functional dependencies: A to B, A to C, C to D. Candidate key: A. What is the highest normal form R satisfies?

  • Options:

    • A. 1NF
    • B. 2NF
    • C. 3NF
    • D. BCNF
  • Answer: B

  • Derivation:

    • 2NF: The candidate key is a single attribute (A), so partial dependency is impossible. Satisfied.
    • 3NF: A to C and C to D means A to D is transitive through C. Since C is not a superkey and D is not part of any candidate key, the FD C to D violates 3NF.
    • R is in 2NF but not 3NF.
  • The 3NF rule (Bill Kent’s phrasing): every non-key attribute must depend on the key, the whole key, and nothing but the key.

Operating Systems (Questions 7–8)

Q7: FIFO Page Replacement Fault Count

  • Problem: 3 page frames (initially empty). Reference string: 7, 0, 1, 2, 0, 3, 0, 4. How many page faults occur using FIFO?

  • Options:

    • A. 5
    • B. 6
    • C. 7
    • D. 8
  • Answer: C

  • Trace table:

    • Page 7: frames = [7, -, -], fault (total: 1)
    • Page 0: frames = [7, 0, -], fault (total: 2)
    • Page 1: frames = [7, 0, 1], fault (total: 3)
    • Page 2: oldest=7, replace. frames = [2, 0, 1], fault (total: 4)
    • Page 0: present, hit (total: 4)
    • Page 3: oldest=0, replace. frames = [2, 3, 1], fault (total: 5)
    • Page 0: absent, oldest=1, replace. frames = [2, 3, 0], fault (total: 6)
    • Page 4: oldest=2, replace. frames = [4, 3, 0], fault (total: 7)
  • Method: Maintain a queue for insertion order. On a miss, evict the front. On a hit, do nothing (FIFO does not reorder on access). For a deeper treatment of page replacement algorithms, LRU and Optimal are the next study targets.

Q8: SJF Non-Preemptive Scheduling

  • Problem: Calculate the average waiting time under non-preemptive SJF.
ProcessArrival TimeBurst Time
P106
P214
P322
P433
  • Options:

    • A. 3.50
    • B. 4.75
    • C. 5.25
    • D. 6.00
  • Answer: B

  • Derivation:

    • t=0: Only P1 available. Run P1 (burst=6). Completes at t=6.
    • t=6: P2(4), P3(2), P4(3) waiting. Shortest=P3. Completes at t=8.
    • t=8: P2(4), P4(3) waiting. Shortest=P4. Completes at t=11.
    • t=11: Run P2. Completes at t=15.
    • Waiting time = completion - arrival - burst
    • P1: 6 - 0 - 6 = 0
    • P2: 15 - 1 - 4 = 10
    • P3: 8 - 2 - 2 = 4
    • P4: 11 - 3 - 3 = 5
    • Average = (0 + 10 + 4 + 5) / 4 = 19/4 = 4.75
  • Note: Non-preemptive SJF cannot interrupt a running process. P1 runs to completion despite shorter jobs arriving at t=1, t=2, t=3.

Networking and OOP (Questions 9–10)

Q9: OSI Model Layer Identification

  • Problem: Which OSI layer handles end-to-end error recovery, flow control, and segmentation?

  • Options:

    • A. Network Layer (Layer 3)
    • B. Transport Layer (Layer 4)
    • C. Session Layer (Layer 5)
    • D. Data Link Layer (Layer 2)
  • Answer: B

  • Explanation: The Transport Layer (Layer 4) provides end-to-end services: segmentation, flow control, error recovery, and connection management. TCP operates here. Data Link (Layer 2) handles hop-to-hop error detection, not end-to-end. Network (Layer 3) handles routing and logical addressing.

Q10: Java Runtime Polymorphism

  • Problem: What is the output?
class Animal {
    void sound() {
        System.out.println("Generic sound");
    }
}

class Dog extends Animal {
    void sound() {
        System.out.println("Bark");
    }
}

public class Main {
    public static void main(String[] args) {
        Animal a = new Dog();
        a.sound();
    }
}
  • Options:

    • A. Generic sound
    • B. Bark
    • C. Compilation error
    • D. Runtime exception
  • Answer: B

  • Explanation: The reference type is Animal, but the object is Dog. In Java, method overriding resolves at runtime based on actual object type (dynamic method dispatch). Since Dog overrides sound(), the Dog version executes. If sound() were static, static binding would apply and “Generic sound” would print.

Practice Strategy

The derivation method used above matters more than memorising answer keys. When numbers change (different reference string, different arrival times), only re-derivation produces the correct answer.

For C-language fundamentals tested in these rounds, work through C coding questions set 1. For aptitude pattern types beyond the technical domain, see coding and decoding question types.

The verify-by-derivation habit these ten questions build is the same skill needed when working with AI-generated code: prompt, read the output, trace it step-by-step, confirm or reject. TinkerLLM (₹299) gives you a sandbox to do exactly that with real LLM outputs, building the same trace-table muscle on algorithm problems that go beyond multiple-choice.

Primary sources

Frequently asked questions

Are these exact questions asked in TCS NQT or Infosys drives?

The exact wording varies, but the underlying concepts (page faults, normalization, time complexity, polymorphism) appear consistently across TCS NQT, Infosys InfyTQ, Wipro NLTH, and Capgemini technical rounds. Practising the derivation method matters more than memorising specific questions.

How much OS and networking should I cover for placement prep?

Page replacement (FIFO, LRU, Optimal), CPU scheduling (SJF, FCFS, Round Robin), the OSI model layers, and TCP vs UDP cover roughly 80 percent of the OS and networking questions seen in mass-recruiter technical rounds.

What is the difference between a technical aptitude round and a coding round?

Technical aptitude rounds are MCQ-based and test conceptual understanding across CS subjects. Coding rounds require writing compilable solutions to algorithmic problems. Both can appear in the same drive, usually technical aptitude first as a screening filter.

Should I memorise SQL syntax for placement aptitude tests?

Basic SELECT, JOIN, GROUP BY, and WHERE syntax is worth memorising since DBMS MCQs appear in most mass-recruiter papers. Complex subqueries and window functions are rare in MCQ format but can appear in coding rounds at product companies.

Is OOP tested even for roles that do not use Java?

Yes. Inheritance, polymorphism, and encapsulation concepts appear in technical rounds regardless of the role's primary language. The questions test understanding of object-oriented principles, not Java-specific syntax.

Build AI projects

A self-paced playground for building with LLMs.

TinkerLLM is FACE Prep's sister property. A guided environment for shipping real LLM applications, the kind of project that earns a paragraph on your resume, not a line.

Try TinkerLLM (₹299 launch)
Free AI Roadmap PDF