140 practice MCQs covering exactly what Sasken's assessment tests — C, C++, Data Structures & Algorithms, and Operating Systems, at medium-to-hard difficulty. Each question is collapsed by default with the answer and explanation hidden underneath — try answering first, then tap to reveal.

Section 1: C Programming

30 questions — medium to hard

1. What does the following print? int x = 5; printf("%d %d %d", x++, x++, x);

  1. 5 6 7
  2. 7 6 5
  3. Undefined behavior
  4. 5 5 5
Reveal Answer

Answer: c) Undefined behavior. Order of evaluation of function arguments is unspecified in C, and modifying x more than once without a sequence point causes UB.

2. sizeof(char *) on a 64-bit system is typically:

  1. 1 byte
  2. 4 bytes
  3. 8 bytes
  4. Depends on data type pointed to
Reveal Answer

Answer: c) 8 bytes. All pointer types have the same size on a given architecture (8 bytes on 64-bit), regardless of what they point to.

3. Which storage class retains a variable's value between function calls?

  1. auto
  2. register
  3. static
  4. extern
Reveal Answer

Answer: c) static. static local variables are allocated once and persist for the program's lifetime, retaining their value across calls.

4. What is the output? #define SQUARE(x) x*x int a = 25 / SQUARE(5); printf("%d", a);

  1. 1
  2. 25
  3. 5
  4. 0
Reveal Answer

Answer: b) 25. Macro expands to 25 / 5*5 = (25/5)*5 = 5*5 = 25, due to lack of parentheses — classic macro pitfall.

5. Which function correctly resizes previously allocated memory?

  1. malloc()
  2. calloc()
  3. realloc()
  4. alloc()
Reveal Answer

Answer: c) realloc(). realloc() resizes a previously allocated block, preserving existing content up to the smaller of old/new size.

6. What does int *p = (int*)0; represent?

  1. Compile error
  2. Null pointer
  3. Pointer to 0th array index
  4. Garbage pointer
Reveal Answer

Answer: b) Null pointer. Assigning the integer constant 0 to a pointer creates a null pointer, valid in C for representing "points to nothing."

7. Output of the following? int arr[5] = {1,2,3,4,5}; printf("%d", *(arr+2));

  1. Address of arr[2]
  2. 3
  3. 2
  4. Error
Reveal Answer

Answer: b) 3. arr+2 points to arr[2]; dereferencing gives its value, 3. Array name decays to pointer to first element.

8. Which is true about const int *p?

  1. p cannot change
  2. *p cannot change via p
  3. Both p and *p are constant
  4. Neither is constant
Reveal Answer

Answer: b) *p cannot change via p. const int *p means p points to a constant int — the pointed-to value can't be modified through p, but p itself can be reassigned.

9. What's the size of struct A { char c; int i; }; on a typical 32-bit-aligned system?

  1. 5 bytes
  2. 8 bytes
  3. 6 bytes
  4. 4 bytes
Reveal Answer

Answer: b) 8 bytes. Padding is added after char (3 bytes) so int starts at a 4-byte aligned address — structure alignment/padding rule.

10. What does the volatile keyword indicate to the compiler?

  1. Variable is read-only
  2. Variable's value may change unexpectedly (e.g. hardware/interrupt)
  3. Variable is thread-local
  4. Variable is a constant
Reveal Answer

Answer: b) Variable's value may change unexpectedly. volatile prevents compiler optimizations that assume the value doesn't change outside program flow, common in embedded/hardware register access.

11. What happens if you free() a pointer twice?

  1. No effect
  2. Undefined behavior
  3. Compile error
  4. Memory is doubly freed safely
Reveal Answer

Answer: b) Undefined behavior. Double free corrupts the heap's memory management structures and can cause crashes or security vulnerabilities.

12. Which of these correctly declares a function pointer to a function taking an int and returning int?

  1. int fp(int);
  2. int *fp(int);
  3. int (*fp)(int);
  4. (int*)fp(int);
Reveal Answer

Answer: c) int (*fp)(int); Parentheses around *fp are required; without them (int *fp(int)) it's a function returning int*, not a pointer to function.

13. Output? int i = 0; for(; i<3; i++) { static int count = 0; count++; printf("%d ", count); }

  1. 1 1 1
  2. 0 1 2
  3. 1 2 3
  4. 3 3 3
Reveal Answer

Answer: c) 1 2 3. static initializes count only once; it retains its incremented value across loop iterations.

14. What is a dangling pointer?

  1. A pointer that is NULL
  2. A pointer pointing to freed/deallocated memory
  3. An uninitialized pointer
  4. A pointer to a pointer
Reveal Answer

Answer: b) A pointer pointing to freed/deallocated memory. After free() or when a local variable goes out of scope, any pointer still referencing that memory becomes dangling.

15. Which loop is guaranteed to execute at least once?

  1. for
  2. while
  3. do-while
  4. None
Reveal Answer

Answer: c) do-while. do-while checks the condition after executing the loop body, so the body always runs at least one time.

16. What does a ^= b; b ^= a; a ^= b; achieve (a, b integers)?

  1. Sets both to 0
  2. Swaps a and b
  3. Doubles both values
  4. Undefined behavior
Reveal Answer

Answer: b) Swaps a and b. Classic XOR swap trick — swaps values without a temporary variable, using properties of the XOR bitwise operator.

17. In union U { int i; float f; char c[4]; };, what is sizeof(U)?

  1. Sum of all members
  2. Size of the largest member (with padding if needed)
  3. Size of int only
  4. 0
Reveal Answer

Answer: b) Size of the largest member. A union allocates memory shared by all members; its size equals the largest member's size, aligned as needed.

18. What is the output? char *s = "Hello"; s[0] = 'M'; printf("%s", s);

  1. Mello
  2. Hello
  3. Undefined behavior/crash
  4. Compile error
Reveal Answer

Answer: c) Undefined behavior/crash. String literals are stored in read-only memory; attempting to modify them causes undefined behavior (often a segfault).

19. Which best describes register storage class?

  1. Guarantees CPU register storage
  2. Hints to the compiler to store variable in a register for fast access
  3. Makes variable global
  4. Same as static
Reveal Answer

Answer: b) Hints to the compiler. register is only a suggestion; the compiler may ignore it, especially with modern optimizers. & cannot be used on register variables.

20. What is the output? printf("%d", printf("%d", printf("%d", 100)));

  1. 1003321
  2. 100331
  3. Error
  4. 100321
Reveal Answer

Answer: b) 100331. Innermost printf(100) prints "100" (3 chars) and returns 3; next prints "3" and returns 1; outer prints "1" — total output "100" + "3" + "1" = "100331".

21. Which correctly allocates and zero-initializes memory for 10 integers?

  1. malloc(10*sizeof(int))
  2. calloc(10, sizeof(int))
  3. realloc(NULL, 10)
  4. new int[10]
Reveal Answer

Answer: b) calloc(10, sizeof(int)). Unlike malloc, calloc initializes all allocated bytes to zero, which malloc does not guarantee.

22. What is the scope of a variable declared in a for loop's initialization in C99+?

  1. Global
  2. Entire function
  3. Limited to the loop block
  4. File scope
Reveal Answer

Answer: c) Limited to the loop block. C99 allows declaration inside for(int i=0;...); the variable's scope is restricted to the loop.

23. What does int (*arr)[5]; declare?

  1. Array of 5 pointers
  2. Pointer to an array of 5 ints
  3. 5 arrays of pointers
  4. Invalid syntax
Reveal Answer

Answer: b) Pointer to an array of 5 ints. Parentheses bind * to arr first, meaning arr is a pointer, and it points to an array of 5 integers.

24. Which is true regarding recursion in C?

  1. Uses heap memory for call stack
  2. Each call uses stack memory for local variables/return address
  3. Cannot be used with arrays
  4. Always faster than iteration
Reveal Answer

Answer: b) Each call uses stack memory. Every recursive call pushes a new stack frame; deep recursion can cause stack overflow.

25. What is output? int a[] = {10,20,30}; int *p = a; printf("%d", *p++); printf("%d", *p);

  1. 10 10
  2. 10 20
  3. 20 20
  4. 20 30
Reveal Answer

Answer: b) 10 20. *p++ dereferences first (10), then increments pointer (postfix). Next *p accesses the now-incremented pointer → 20.

26. Which header is required for dynamic memory functions?

  1. stdio.h
  2. stdlib.h
  3. string.h
  4. memory.h
Reveal Answer

Answer: b) stdlib.h. malloc, calloc, realloc, and free are declared in stdlib.h.

27. What is a memory leak?

  1. Accessing freed memory
  2. Allocated memory that is never freed and becomes unreachable
  3. Writing beyond array bounds
  4. Using an uninitialized pointer
Reveal Answer

Answer: b) Allocated memory that is never freed and becomes unreachable. If the last reference to allocated memory is lost without calling free(), that memory is leaked for the program's lifetime.

28. In struct Emp { unsigned int age:4; };, what does :4 signify?

  1. Array size 4
  2. Bit-field of 4 bits
  3. Pointer offset
  4. Default value
Reveal Answer

Answer: b) Bit-field of 4 bits. Bit-fields restrict a member to a specific number of bits, used to pack data tightly (age can hold 0-15 in 4 bits).

29. What does the comma operator do in x = (a++, b++, a+b);?

  1. Syntax error
  2. Evaluates all expressions left to right; result is the last expression's value
  3. Only evaluates the first
  4. Undefined behavior
Reveal Answer

Answer: b) Evaluates all expressions left to right; result is last value. The comma operator evaluates each operand in sequence and yields the value of the rightmost operand.

30. Which is true about passing arrays to functions in C?

  1. Entire array is copied
  2. Array decays to a pointer to its first element
  3. Compile error
  4. Only works for 1D arrays
Reveal Answer

Answer: b) Array decays to a pointer. In C, arrays cannot be passed by value; the function receives a pointer to the first element, so sizeof inside the function gives pointer size, not array size.

Section 2: C++

30 questions — medium to hard

1. What is the primary purpose of a virtual function?

  1. Faster execution
  2. Runtime (dynamic) polymorphism
  3. Compile-time polymorphism
  4. Memory optimization
Reveal Answer

Answer: b) Runtime polymorphism. Virtual functions enable a base class pointer/reference to call the derived class's overridden method, resolved at runtime via the vtable.

2. What happens if a base class destructor is not virtual and you delete a derived object through a base pointer?

  1. Compile error
  2. Only base destructor runs — derived destructor is skipped (resource leak risk)
  3. Both destructors always run
  4. Undefined at compile time
Reveal Answer

Answer: b) Only base destructor runs. Without a virtual destructor, deleting via a base pointer causes undefined behavior/resource leaks since the derived part isn't cleaned up.

3. Which best describes a pure virtual function?

  1. virtual void f();
  2. virtual void f() = 0;
  3. void f() override;
  4. static void f();
Reveal Answer

Answer: b) virtual void f() = 0; The = 0 syntax makes it pure virtual, forcing derived classes to implement it and making the base class abstract (non-instantiable).

4. What is object slicing?

  1. Splitting an object into parts
  2. Losing derived-class data when a derived object is assigned to a base object (by value)
  3. A memory optimization technique
  4. A type of casting
Reveal Answer

Answer: b) Losing derived-class data when assigned by value. Assigning Derived d; Base b = d; copies only the Base portion, "slicing off" derived members — a common polymorphism pitfall.

5. What does the diamond problem refer to?

  1. A sorting algorithm issue
  2. Ambiguity from multiple inheritance where a class inherits the same base twice
  3. A template error
  4. A memory alignment issue
Reveal Answer

Answer: b) Ambiguity from multiple inheritance. If classes B and C both inherit from A, and D inherits from both B and C, D gets two copies of A's members unless virtual inheritance is used.

6. Which correctly overloads the + operator as a member function for class Complex?

  1. void operator+(Complex);
  2. Complex operator+(Complex);
  3. Complex +operator(Complex);
  4. friend Complex +(Complex);
Reveal Answer

Answer: b) Complex operator+(Complex); Standard syntax for a member operator overload returns the appropriate type and uses the operator+ keyword form.

7. What is the key difference between unique_ptr and shared_ptr?

  1. No difference
  2. unique_ptr allows only one owner; shared_ptr allows multiple owners with reference counting
  3. shared_ptr is faster
  4. unique_ptr can be copied freely
Reveal Answer

Answer: b) unique_ptr = single ownership, shared_ptr = reference-counted shared ownership. unique_ptr cannot be copied (only moved); shared_ptr maintains a reference count and deletes the object when the count reaches zero.

8. What is the output? class A { public: A(){cout<<"A ";} ~A(){cout<<"~A ";} }; class B : public A { public: B(){cout<<"B ";} ~B(){cout<<"~B ";} }; int main(){ B b; }

  1. A B ~B ~A
  2. B A ~A ~B
  3. A B ~A ~B
  4. B ~B
Reveal Answer

Answer: a) A B ~B ~A. Construction order goes base-to-derived (A then B); destruction is reverse — derived-to-base (~B then ~A).

9. What does the friend keyword do?

  1. Makes a class inherit another
  2. Grants a non-member function/class access to private/protected members
  3. Overloads an operator
  4. Declares a static member
Reveal Answer

Answer: b) Grants access to private/protected members. A friend function/class isn't a member but can access the class's private and protected data — breaks strict encapsulation for specific cases.

10. Which STL container provides O(1) average time complexity for insertion/lookup by key?

  1. vector
  2. map
  3. unordered_map
  4. list
Reveal Answer

Answer: c) unordered_map. unordered_map uses a hash table (O(1) average); map uses a red-black tree (O(log n)) — a common point of confusion.

11. What is function overriding vs overloading?

  1. Same thing
  2. Overriding = same signature in base/derived (runtime); Overloading = same name, different parameters (compile-time)
  3. Overloading is runtime, overriding is compile-time
  4. Both are compile-time
Reveal Answer

Answer: b) Overriding = runtime, same signature; Overloading = compile-time, different params. Overriding requires an identical signature in derived class with virtual in base; overloading involves different parameter lists in the same scope.

12. What does "this" pointer refer to in a member function?

  1. The class itself
  2. A pointer to the object invoking the member function
  3. The parent class object
  4. A static reference
Reveal Answer

Answer: b) A pointer to the object invoking the member function. this is implicitly passed to non-static member functions and points to the calling object's memory address.

13. What is the output? class Base { public: virtual void show(){cout<<"Base";} }; class Derived : public Base { public: void show() override {cout<<"Derived";} }; int main(){ Base *b = new Derived(); b->show(); }

  1. Base
  2. Derived
  3. Compile error
  4. BaseDerived
Reveal Answer

Answer: b) Derived. Since show() is virtual, the call is resolved at runtime based on the actual object type (Derived), not the pointer type — dynamic dispatch.

14. What is a constructor initialization list used for?

  1. Only for default values
  2. Initializing member variables (especially const/reference members) before the constructor body executes
  3. Declaring friend functions
  4. Overloading constructors
Reveal Answer

Answer: b) Initializing members before constructor body executes. const and reference members MUST be initialized in the init list since they can't be assigned in the constructor body.

15. Which of these is true about templates?

  1. Resolved at runtime
  2. Enable compile-time generic programming for functions/classes
  3. Only work with built-in types
  4. Same as macros
Reveal Answer

Answer: b) Enable compile-time generic programming. Templates let you write type-independent code; the compiler generates specific versions for each type used (unlike macros, they're type-safe).

16. What happens when an exception is thrown but not caught?

  1. Program continues normally
  2. std::terminate() is called, aborting the program
  3. Compiler error
  4. Returns to main() automatically
Reveal Answer

Answer: b) std::terminate() is called. An uncaught exception propagates up the call stack; if it reaches the top uncaught, std::terminate() aborts the program.

17. What is the difference between new/delete and malloc/free?

  1. No difference
  2. new/delete call constructors/destructors; malloc/free only allocate raw memory
  3. malloc is C++ only
  4. new is slower always
Reveal Answer

Answer: b) new/delete call constructors/destructors. new allocates memory AND invokes the constructor; malloc only allocates raw memory with no object initialization.

18. What is method resolution order when a derived class doesn't override a base virtual function?

  1. Compile error
  2. Base class version is used (inherited)
  3. Undefined behavior
  4. Must be redeclared
Reveal Answer

Answer: b) Base class version is used. If not overridden, calling through a base pointer/reference invokes the inherited base implementation.

19. What does static mean for a class member variable?

  1. Same as const
  2. Shared across all objects of the class (single copy)
  3. Cannot be modified
  4. Local to each object
Reveal Answer

Answer: b) Shared across all objects (single copy). A static member belongs to the class, not any instance — all objects share the same copy, and it must be defined outside the class too.

20. What is a copy constructor invoked for?

  1. Only explicit calls
  2. Creating a new object as a copy of an existing object (pass-by-value, return-by-value, explicit copy)
  3. Destroying objects
  4. Static initialization
Reveal Answer

Answer: b) Creating a new object as a copy of an existing object. Triggered when an object is passed/returned by value, or explicitly copy-initialized — e.g. A a2 = a1;.

21. What is the output? int x = 10; int &ref = x; ref = 20; cout << x;

  1. 10
  2. 20
  3. Compile error
  4. Garbage
Reveal Answer

Answer: b) 20. A reference is an alias for the same memory location; modifying ref directly modifies x.

22. Which STL container maintains elements in sorted order automatically?

  1. vector
  2. unordered_set
  3. set
  4. deque
Reveal Answer

Answer: c) set. std::set is implemented as a self-balancing BST (red-black tree), keeping elements sorted by key automatically.

23. What is virtual inheritance used to solve?

  1. Function overloading conflicts
  2. The diamond problem in multiple inheritance
  3. Template instantiation errors
  4. Memory leaks
Reveal Answer

Answer: b) The diamond problem. Declaring inheritance as virtual ensures only one shared instance of the common base class exists in the derived object.

24. What does const after a member function signature (void show() const) mean?

  1. Function cannot be called
  2. Function cannot modify any member variables (except mutable ones)
  3. Function is static
  4. Function is virtual
Reveal Answer

Answer: b) Function cannot modify member variables. A const member function promises not to alter the object's state, and can be called on const object instances.

25. What is the output? class A { public: void print(){cout<<"A::print ";} }; class B : public A { public: void print(){cout<<"B::print ";} }; int main(){ A *a = new B(); a->print(); }

  1. A::print
  2. B::print
  3. Compile error
  4. Both printed
Reveal Answer

Answer: a) A::print. Since print() is NOT virtual, the call is resolved at compile time based on pointer type (A), not object type — static binding.

26. What is a namespace used for?

  1. Memory management
  2. Avoiding naming conflicts by grouping related identifiers
  3. Creating templates
  4. Exception handling
Reveal Answer

Answer: b) Avoiding naming conflicts. Namespaces logically group code and prevent identifier clashes, especially when combining multiple libraries.

27. What is move semantics primarily used for?

  1. Deep copying objects
  2. Transferring resources from a temporary/rvalue object efficiently, avoiding unnecessary copies
  3. Multithreading
  4. Exception safety only
Reveal Answer

Answer: b) Transferring resources from temporary objects efficiently. std::move and move constructors "steal" resources (like heap pointers) from rvalues instead of deep-copying, improving performance.

28. Which access specifier allows access only within the class and its derived classes, not outside?

  1. public
  2. private
  3. protected
  4. static
Reveal Answer

Answer: c) protected. protected members are accessible within the class itself and any derived class, but not from outside the class hierarchy.

29. What is the output size relationship for an empty class in C++? class Empty {}; cout << sizeof(Empty);

  1. 0
  2. 1
  3. Compile error
  4. 4
Reveal Answer

Answer: b) 1. C++ mandates that every object have a unique address, so even an empty class occupies a minimum of 1 byte.

30. What is the purpose of the explicit keyword on a constructor?

  1. Makes constructor public
  2. Prevents implicit type conversions via the constructor
  3. Makes constructor virtual
  4. Deletes the constructor
Reveal Answer

Answer: b) Prevents implicit type conversions. Without explicit, a single-argument constructor can be used for implicit conversions (e.g. passing an int where the class type is expected), which explicit blocks.

Section 3: Data Structures & Algorithms

40 questions — medium to hard

1. What is the time complexity of binary search on a sorted array of n elements?

  1. O(n)
  2. O(log n)
  3. O(n log n)
  4. O(1)
Reveal Answer

Answer: b) O(log n). Each comparison halves the search space, giving logarithmic time complexity.

2. What is the worst-case time complexity of Quick Sort?

  1. O(n log n)
  2. O(n)
  3. O(n²)
  4. O(log n)
Reveal Answer

Answer: c) O(n²). Worst case occurs with poor pivot selection (e.g. already sorted array with first/last element as pivot), causing unbalanced partitions.

3. Which algorithm is used to detect a cycle in a linked list?

  1. Binary search
  2. Floyd's cycle detection (slow/fast pointer)
  3. Merge sort
  4. Dijkstra's algorithm
Reveal Answer

Answer: b) Floyd's cycle detection. Two pointers move at different speeds (1x and 2x); if they meet, a cycle exists — also called the "tortoise and hare" algorithm.

4. What is the space complexity of Merge Sort?

  1. O(1)
  2. O(log n)
  3. O(n)
  4. O(n²)
Reveal Answer

Answer: c) O(n). Merge sort requires additional array space proportional to n for the merging process, unlike in-place sorts like quicksort/heapsort.

5. In a Min-Heap, where is the minimum element always located?

  1. Last leaf
  2. Root
  3. Middle
  4. Any leaf node
Reveal Answer

Answer: b) Root. A min-heap maintains the heap property where every parent is ≤ its children, so the smallest element is always at the root.

6. What is the time complexity to insert an element into a hash table (average case)?

  1. O(n)
  2. O(log n)
  3. O(1)
  4. O(n²)
Reveal Answer

Answer: c) O(1). With a good hash function and low load factor, insertion/lookup in a hash table is O(1) on average, though O(n) worst case with many collisions.

7. Which traversal of a BST gives elements in sorted order?

  1. Preorder
  2. Inorder
  3. Postorder
  4. Level order
Reveal Answer

Answer: b) Inorder. Inorder traversal (left-root-right) visits nodes of a BST in ascending sorted order, due to BST ordering property.

8. What data structure is best for implementing an "undo" feature?

  1. Queue
  2. Stack
  3. Array
  4. Hash table
Reveal Answer

Answer: b) Stack. Undo requires reversing the most recent action first — LIFO (Last In First Out) behavior, exactly what a stack provides.

9. What is the time complexity of Dijkstra's algorithm using a min-heap/priority queue?

  1. O(V²)
  2. O(E log V)
  3. O(V log E)
  4. O(VE)
Reveal Answer

Answer: b) O(E log V). With a min-heap, each edge relaxation takes O(log V), giving O(E log V) for E edges — more efficient than the O(V²) naive implementation.

10. Which sorting algorithm is stable AND has O(n log n) worst-case time complexity?

  1. Quick Sort
  2. Heap Sort
  3. Merge Sort
  4. Selection Sort
Reveal Answer

Answer: c) Merge Sort. Merge Sort guarantees O(n log n) in all cases and preserves the relative order of equal elements (stability); Quick/Heap sort aren't stable by default.

11. What is the purpose of a sliding window technique?

  1. Sorting arrays
  2. Efficiently processing contiguous subarrays/substrings without recomputation
  3. Graph traversal
  4. Memory allocation
Reveal Answer

Answer: b) Efficiently processing contiguous subarrays/substrings. Instead of recomputing from scratch, the window "slides" by adjusting boundaries, reducing time complexity from O(n²) or O(n·k) to O(n) for many problems.

12. What is Kadane's Algorithm used for?

  1. Shortest path
  2. Maximum subarray sum
  3. Sorting
  4. Cycle detection
Reveal Answer

Answer: b) Maximum subarray sum. Kadane's algorithm finds the maximum sum contiguous subarray in O(n) time using dynamic programming principles.

13. What is the height of a balanced binary search tree with n nodes?

  1. O(n)
  2. O(log n)
  3. O(n²)
  4. O(1)
Reveal Answer

Answer: b) O(log n). A balanced BST (like AVL) maintains height proportional to log n, ensuring O(log n) search/insert/delete operations.

14. Which data structure is used to implement recursion internally?

  1. Queue
  2. Stack (call stack)
  3. Heap
  4. Linked list
Reveal Answer

Answer: b) Stack (call stack). Each function call pushes a stack frame (local vars, return address); returning pops it — recursion depth is limited by stack size.

15. What does the Master Theorem help solve?

  1. Sorting stability
  2. Time complexity of divide-and-conquer recurrence relations
  3. Graph coloring
  4. Hashing collisions
Reveal Answer

Answer: b) Time complexity of divide-and-conquer recurrences. Master theorem provides a direct formula to solve recurrences of the form T(n) = aT(n/b) + f(n), common in algorithms like merge sort.

16. What is the time complexity of building a heap from an unsorted array?

  1. O(n log n)
  2. O(n)
  3. O(log n)
  4. O(n²)
Reveal Answer

Answer: b) O(n). Though a single heapify is O(log n), building the entire heap bottom-up is O(n) total due to amortized analysis of heapify calls at different heights.

17. What is the primary advantage of a doubly linked list over a singly linked list?

  1. Uses less memory
  2. Allows traversal in both directions
  3. Faster insertion at head only
  4. No advantage
Reveal Answer

Answer: b) Allows traversal in both directions. Each node has both next and prev pointers, enabling backward traversal — at the cost of extra memory per node.

18. Which technique is used in the "Two Sum" problem for an O(n) solution?

  1. Sorting
  2. Hash map to store complements
  3. Nested loops
  4. Binary search
Reveal Answer

Answer: b) Hash map to store complements. Storing seen values in a hash map allows O(1) lookup for the complement (target - current), achieving O(n) overall instead of O(n²).

19. What is topological sorting applicable to?

  1. Any graph
  2. Directed Acyclic Graphs (DAG) only
  3. Undirected graphs only
  4. Binary trees only
Reveal Answer

Answer: b) Directed Acyclic Graphs (DAG) only. Topological sort orders vertices such that for every directed edge u→v, u comes before v — only meaningful/possible for DAGs (no cycles).

20. What is the time complexity of the Union-Find (Disjoint Set) operations with path compression and union by rank?

  1. O(n)
  2. O(log n)
  3. Nearly O(1) (amortized, α(n))
  4. O(n²)
Reveal Answer

Answer: c) Nearly O(1) amortized. With both optimizations, operations run in inverse Ackermann time α(n), which is effectively constant for all practical input sizes.

21. In a max-heap represented as an array, what is the index of the left child of node at index i (0-indexed)?

  1. i+1
  2. 2i+1
  3. 2i
  4. i/2
Reveal Answer

Answer: b) 2i+1. For 0-indexed array-based heaps, left child = 2i+1, right child = 2i+2, parent = (i-1)/2.

22. What is the worst-case time complexity of searching in a Trie for a word of length m?

  1. O(n)
  2. O(m)
  3. O(log n)
  4. O(m²)
Reveal Answer

Answer: b) O(m). Trie search follows the path character by character, independent of the number of stored words — depends only on word length m.

23. What is the LCA (Lowest Common Ancestor) of two nodes in a BST used for?

  1. Sorting nodes
  2. Finding the deepest node that is an ancestor of both given nodes
  3. Balancing the tree
  4. Deleting nodes
Reveal Answer

Answer: b) Finding the deepest common ancestor node. In a BST, LCA can be found in O(h) by comparing node values against the root and moving left/right accordingly, using BST ordering.

24. What causes Belady's Anomaly?

  1. A sorting error
  2. Page faults increasing with more page frames in FIFO replacement
  3. Stack overflow
  4. Hash collisions
Reveal Answer

Answer: b) Page faults increasing with more frames (FIFO). Counter-intuitively, in FIFO page replacement, adding more frames can sometimes increase page faults — this doesn't happen with LRU/Optimal.

25. What is the amortized time complexity of a dynamic array's push_back (like std::vector)?

  1. O(n)
  2. O(1) amortized
  3. O(log n)
  4. O(n²)
Reveal Answer

Answer: b) O(1) amortized. Though occasional resizing takes O(n), doubling strategy means the average cost per insertion over many operations is O(1).

26. Which technique does the N-Queens problem primarily use?

  1. Dynamic programming
  2. Backtracking
  3. Greedy
  4. Divide and conquer
Reveal Answer

Answer: b) Backtracking. N-Queens explores placements recursively, "backing off" (undoing choices) whenever a placement leads to a conflict — classic backtracking.

27. What is the recurrence relation's time complexity for T(n) = 2T(n/2) + O(n) (like Merge Sort)?

  1. O(n)
  2. O(n log n)
  3. O(n²)
  4. O(log n)
Reveal Answer

Answer: b) O(n log n). By the Master Theorem (case 2), a=2, b=2, f(n)=O(n) matches n^(log_b a) = n, giving T(n) = O(n log n).

28. What is the primary difference between BFS and DFS traversal?

  1. No difference
  2. BFS uses a queue (level-by-level); DFS uses a stack/recursion (depth-first)
  3. BFS is always faster
  4. DFS can't be used on graphs
Reveal Answer

Answer: b) BFS = queue, level-by-level; DFS = stack/recursion, depth-first. BFS explores all neighbors before going deeper (good for shortest path in unweighted graphs); DFS explores as deep as possible before backtracking.

29. In dynamic programming, what does "overlapping subproblems" mean?

  1. Problems that never repeat
  2. The same subproblems are solved multiple times in a naive recursive solution
  3. Subproblems must be independent
  4. Only applies to graphs
Reveal Answer

Answer: b) Same subproblems solved multiple times. DP exploits this by caching (memoizing) results of subproblems so they're computed once, drastically reducing time complexity (e.g. Fibonacci).

30. What is the time complexity of deleting the minimum element from a min-heap?

  1. O(1)
  2. O(log n)
  3. O(n)
  4. O(n log n)
Reveal Answer

Answer: b) O(log n). Removing the root requires replacing it with the last element and "sifting down" to restore heap property — takes O(log n) for a heap of height log n.

31. What is a circular queue's main advantage over a simple linear queue?

  1. Faster sorting
  2. Efficient reuse of freed space, avoiding wasted memory
  3. Allows duplicate elements only
  4. No advantage
Reveal Answer

Answer: b) Efficient reuse of freed space. In a linear queue, dequeued space at the front can't be reused; a circular queue wraps around, utilizing all allocated slots.

32. What is the space complexity of an iterative (non-recursive) implementation of a DFS using an explicit stack?

  1. O(1)
  2. O(V) in the worst case
  3. O(E)
  4. O(V²)
Reveal Answer

Answer: b) O(V) in the worst case. The explicit stack can hold up to all vertices in the worst case (e.g. a skewed graph structure), giving O(V) space.

33. Which of these best describes greedy algorithms?

  1. Always find the global optimum
  2. Make the locally optimal choice at each step, hoping it leads to a global optimum
  3. Same as dynamic programming
  4. Only work on sorted data
Reveal Answer

Answer: b) Make locally optimal choice at each step. Greedy algorithms don't reconsider previous choices; they work correctly only for problems exhibiting the "greedy choice property" (e.g. activity selection, Huffman coding).

34. What is the time complexity of Bubble Sort in the best case (already sorted array, with optimization)?

  1. O(n²)
  2. O(n)
  3. O(log n)
  4. O(n log n)
Reveal Answer

Answer: b) O(n). With an early-exit flag checking if any swaps occurred, an already-sorted array requires just one pass, giving O(n) best case.

35. What does "in-place" mean for a sorting algorithm?

  1. Uses no comparisons
  2. Sorts using only O(1) extra space (doesn't need a separate copy of the array)
  3. Always O(n log n)
  4. Cannot be recursive
Reveal Answer

Answer: b) Sorts using O(1) extra space. In-place algorithms (e.g. quicksort, heapsort) rearrange elements within the original array without significant additional memory (unlike merge sort).

36. What is the primary use of a segment tree?

  1. Sorting arrays
  2. Efficient range queries (sum/min/max) and updates on an array
  3. Graph traversal
  4. Hashing
Reveal Answer

Answer: b) Efficient range queries and updates. Segment trees allow both range queries and point/range updates in O(log n), much faster than O(n) naive approaches for repeated queries.

37. What is the worst-case time complexity of inserting into a hash table with many collisions (all elements hash to the same bucket)?

  1. O(1)
  2. O(log n)
  3. O(n)
  4. O(n²)
Reveal Answer

Answer: c) O(n). If all elements collide into one bucket (implemented as a list), insertion/search degrades to O(n) linear time in the worst case.

38. What is the primary difference between a stack-based and queue-based approach to level-order traversal of a tree?

  1. No difference
  2. Level order traversal specifically requires a queue, not a stack, to process nodes level by level
  3. Both work equally well
  4. Stack is faster
Reveal Answer

Answer: b) Level order specifically requires a queue. A queue's FIFO nature ensures nodes are processed in the order they were discovered (level by level); a stack (LIFO) would give a different (DFS-like) order.

39. In the 0/1 Knapsack problem using DP, what does the state dp[i][w] typically represent?

  1. Number of items
  2. Maximum value achievable using first i items with weight capacity w
  3. Minimum weight
  4. Total items count
Reveal Answer

Answer: b) Maximum value achievable using first i items with weight capacity w. This is the standard DP table definition; each cell is built from including/excluding the current item, based on prior subproblem results.

40. What is the time complexity of finding an element in a balanced BST vs. a hash table (average case)?

  1. Both O(1)
  2. BST: O(log n), Hash table: O(1) average
  3. Both O(log n)
  4. BST: O(1), Hash table: O(log n)
Reveal Answer

Answer: b) BST: O(log n), Hash table: O(1) average. Hash tables offer faster average lookup but no ordering; BSTs are slightly slower but maintain sorted order, enabling range queries.

Section 4: Operating Systems

40 questions — medium to hard

1. What is the fundamental difference between a process and a thread?

  1. No difference
  2. Threads share the same address space within a process; processes have separate memory spaces
  3. Processes are faster
  4. Threads cannot run concurrently
Reveal Answer

Answer: b) Threads share address space; processes have separate memory. Multiple threads within a process share code, data, and heap segments but have their own stack and registers — enabling lightweight concurrency.

2. Which scheduling algorithm can cause starvation?

  1. Round Robin
  2. FCFS
  3. Priority Scheduling (without aging)
  4. SJF for equal burst times
Reveal Answer

Answer: c) Priority Scheduling (without aging). Low-priority processes may never execute if higher-priority processes keep arriving; "aging" (gradually increasing priority) fixes this.

3. What are the four necessary conditions for deadlock (Coffman conditions)?

  1. Only mutual exclusion
  2. Mutual exclusion, hold and wait, no preemption, circular wait
  3. Only circular wait
  4. Priority inversion and starvation
Reveal Answer

Answer: b) Mutual exclusion, hold and wait, no preemption, circular wait. ALL four conditions must hold simultaneously for deadlock to occur; breaking even one prevents deadlock.

4. What is the primary difference between a mutex and a semaphore?

  1. No difference
  2. Mutex allows only the locking thread to unlock (ownership); semaphore doesn't have this restriction and can allow multiple resources
  3. Semaphore is always binary
  4. Mutex is used across processes only
Reveal Answer

Answer: b) Mutex has ownership restriction; semaphore doesn't (and can count > 1). A mutex is a locking mechanism owned by the locking thread; a counting semaphore can manage multiple resource instances and be signaled by any thread.

5. What is thrashing in an OS?

  1. A CPU scheduling algorithm
  2. Excessive page faults causing the system to spend more time paging than executing
  3. A disk formatting error
  4. A type of deadlock
Reveal Answer

Answer: b) Excessive page faults causing more time paging than executing. Occurs when processes don't have enough frames, leading to constant page swapping and severely degraded performance.

6. Which page replacement algorithm is theoretically optimal but not practically implementable?

  1. FIFO
  2. LRU
  3. Optimal (Belady's algorithm)
  4. Clock algorithm
Reveal Answer

Answer: c) Optimal (Belady's algorithm). It replaces the page that won't be used for the longest time in the future — requires future knowledge, so it's used only as a theoretical benchmark.

7. What is the difference between internal and external fragmentation?

  1. No difference
  2. Internal = wasted space within an allocated block; External = wasted space between allocated blocks (scattered free memory)
  3. Both are the same as thrashing
  4. Internal only happens in paging
Reveal Answer

Answer: b) Internal = wasted space within a block; External = scattered free space between blocks. Internal fragmentation occurs in fixed-size allocation (e.g. paging); external fragmentation occurs in variable-size allocation (e.g. segmentation), needing compaction.

8. What is a race condition?

  1. A CPU scheduling technique
  2. When multiple processes/threads access shared data concurrently and the outcome depends on timing/order of execution
  3. A type of deadlock
  4. A memory leak
Reveal Answer

Answer: b) Outcome depends on timing/order of concurrent access to shared data. Without proper synchronization, concurrent read-modify-write operations on shared data can produce inconsistent/incorrect results.

9. What is the purpose of the Banker's Algorithm?

  1. CPU scheduling
  2. Deadlock avoidance by checking if a resource allocation leaves the system in a safe state
  3. Page replacement
  4. Disk scheduling
Reveal Answer

Answer: b) Deadlock avoidance via safe state checking. Before granting a resource request, it simulates allocation to ensure the system remains in a "safe state" where all processes can still complete.

10. What is the key difference between paging and segmentation?

  1. No difference
  2. Paging divides memory into fixed-size blocks; segmentation divides into variable-size logical units
  3. Segmentation is always faster
  4. Paging causes external fragmentation
Reveal Answer

Answer: b) Paging = fixed-size blocks; Segmentation = variable-size logical units. Paging eliminates external fragmentation but has internal fragmentation; segmentation matches logical program structure but can suffer external fragmentation.

11. In the Producer-Consumer problem, what is primarily used to prevent buffer overflow/underflow?

  1. Only mutex
  2. Semaphores (empty and full counting semaphores) plus a mutex
  3. Priority scheduling
  4. Round robin
Reveal Answer

Answer: b) Semaphores (empty/full) plus a mutex. empty and full semaphores track available slots/items, while a mutex ensures mutual exclusion during buffer access — classic synchronization pattern.

12. What does TLB (Translation Lookaside Buffer) do?

  1. Schedules processes
  2. Caches recent virtual-to-physical address translations to speed up memory access
  3. Manages disk I/O
  4. Handles interrupts
Reveal Answer

Answer: b) Caches virtual-to-physical address translations. Without TLB, every memory access requires a page table lookup (extra memory access); TLB hit avoids this, significantly speeding up address translation.

13. What is a zombie process?

  1. A process that never started
  2. A terminated process whose exit status hasn't been read by its parent (still has a PCB entry)
  3. A process stuck in an infinite loop
  4. A process with no parent
Reveal Answer

Answer: b) Terminated process whose exit status hasn't been read by parent. The process has finished execution but remains in the process table until the parent calls wait() to read its exit status.

14. What is an orphan process?

  1. Same as zombie
  2. A process whose parent has terminated before it, and gets adopted by init/systemd
  3. A process with no children
  4. A process that never terminates
Reveal Answer

Answer: b) A process whose parent terminated first, gets adopted by init. When a parent dies before its child, the orphaned child is re-parented to the init process (PID 1), which reaps it upon completion.

15. Which disk scheduling algorithm minimizes seek time by always choosing the closest request?

  1. FCFS
  2. SSTF (Shortest Seek Time First)
  3. SCAN
  4. C-SCAN
Reveal Answer

Answer: b) SSTF. SSTF selects the request nearest to the current head position, minimizing immediate seek time (but can cause starvation for far requests).

16. What is the SCAN (elevator) disk scheduling algorithm's behavior?

  1. Always goes to the nearest request
  2. Head moves in one direction servicing requests until the end, then reverses direction
  3. Services requests in arrival order
  4. Random order
Reveal Answer

Answer: b) Head moves in one direction until the end, then reverses. Like an elevator, it services all requests in one direction, reaches the end, then reverses — providing more uniform wait times than SSTF.

17. What is context switching overhead primarily caused by?

  1. Disk I/O
  2. Saving/restoring process state (registers, PC, etc.) when switching between processes
  3. Network delays
  4. Compilation time
Reveal Answer

Answer: b) Saving/restoring process state. The CPU must save the current process's context and load the next process's context — this switching itself consumes CPU time without doing useful work.

18. What is the primary difference between preemptive and non-preemptive scheduling?

  1. No difference
  2. Preemptive can interrupt a running process; non-preemptive lets a process run to completion/blocking
  3. Non-preemptive is always faster
  4. Preemptive only works with one process
Reveal Answer

Answer: b) Preemptive can interrupt; non-preemptive runs to completion. Preemptive scheduling (e.g. Round Robin) allows the OS to forcibly switch processes; non-preemptive (e.g. FCFS) waits for the process to yield or finish.

19. What are the Dining Philosophers and Readers-Writers problems examples of?

  1. CPU scheduling algorithms
  2. Classic synchronization problems illustrating deadlock/race condition challenges
  3. Memory management techniques
  4. File systems
Reveal Answer

Answer: b) Classic synchronization problems. Both are canonical problems used to study and demonstrate solutions (semaphores, monitors) for concurrent resource-sharing issues like deadlock and starvation.

20. What is demand paging?

  1. Loading the entire program into memory at start
  2. Loading pages into memory only when they are actually referenced/needed
  3. A CPU scheduling algorithm
  4. A type of disk formatting
Reveal Answer

Answer: b) Loading pages only when referenced. Reduces memory usage and startup time by deferring page loads until a page fault occurs, following the principle of lazy loading.

21. What is the difference between multiprogramming and multitasking?

  1. Same thing
  2. Multiprogramming = multiple programs reside in memory to maximize CPU utilization; Multitasking = rapid switching giving illusion of parallel execution to users
  3. Multitasking requires multiple CPUs
  4. Multiprogramming is user-facing
Reveal Answer

Answer: b) Multiprogramming maximizes CPU use; Multitasking gives illusion of concurrent execution. Multiprogramming focuses on keeping CPU busy by having jobs ready; multitasking emphasizes responsive time-sharing among users/tasks.

22. What is priority inversion?

  1. Reversing scheduling order
  2. A lower-priority process holds a resource needed by a higher-priority process, causing the higher-priority one to wait
  3. A type of deadlock
  4. A page replacement issue
Reveal Answer

Answer: b) Lower-priority process blocks a higher-priority one via a shared resource. Solved using priority inheritance protocols, where the lower-priority process temporarily inherits higher priority to finish quickly and release the resource.

23. What system call is used to create a new process in Unix/Linux?

  1. exec()
  2. fork()
  3. wait()
  4. exit()
Reveal Answer

Answer: b) fork(). fork() creates a near-identical copy (child) of the calling process; it returns 0 in the child and the child's PID in the parent.

24. What does exec() do after a fork()?

  1. Creates another child
  2. Replaces the current process's memory image with a new program
  3. Terminates the process
  4. Suspends the process
Reveal Answer

Answer: b) Replaces the current process's memory image with a new program. Commonly used together — fork() creates a child, then exec() loads a new program into that child's memory space (e.g. shell launching commands).

25. What is the difference between a pipe and a message queue for IPC?

  1. No difference
  2. Pipes are typically unidirectional and unstructured byte streams between related processes; message queues support structured, discrete messages, often between unrelated processes
  3. Pipes work between unrelated processes only
  4. Message queues are always faster
Reveal Answer

Answer: b) Pipes = unstructured byte stream (related processes); message queues = structured discrete messages. Pipes are simpler and typically limited to parent-child/related processes; message queues offer more structure and flexibility for IPC.

26. What is the primary characteristic that distinguishes a Real-Time OS (RTOS) from a general-purpose OS?

  1. Faster clock speed
  2. Deterministic, guaranteed response time within strict deadlines
  3. More memory
  4. Better graphics
Reveal Answer

Answer: b) Deterministic, guaranteed response time within strict deadlines. RTOS prioritizes predictability and meeting hard/soft deadlines over overall throughput, critical for embedded/automotive systems.

27. What happens during a system call?

  1. Nothing special
  2. The CPU switches from user mode to kernel mode to execute privileged OS code
  3. The process terminates
  4. A new process is created
Reveal Answer

Answer: b) CPU switches from user mode to kernel mode. System calls are the interface for user programs to request OS services (file I/O, process control); this requires elevated (kernel) privileges.

28. What is the purpose of spooling?

  1. Speeding up CPU
  2. Buffering I/O (e.g. print jobs) so a fast device (CPU) doesn't wait for a slow device (printer)
  3. Memory compaction
  4. Process scheduling
Reveal Answer

Answer: b) Buffering I/O so fast devices don't wait for slow ones. SPOOL (Simultaneous Peripheral Operations On-Line) queues jobs (like print requests) on disk, letting the CPU continue without waiting for the slow device.

29. What is starvation, and how does it differ from deadlock?

  1. Same thing
  2. Starvation = a process waits indefinitely (but system may still be progressing); Deadlock = processes are stuck, no progress possible at all
  3. Starvation only happens in single-CPU systems
  4. Deadlock is less severe
Reveal Answer

Answer: b) Starvation = indefinite wait (system still progresses); Deadlock = no progress at all. In starvation, other processes continue executing while one is perpetually postponed; in deadlock, ALL involved processes are permanently blocked.

30. What is the role of the "loader" during system boot?

  1. Manages memory paging
  2. Loads the OS kernel into memory and transfers control to it
  3. Handles user login
  4. Schedules processes
Reveal Answer

Answer: b) Loads the OS kernel into memory and transfers control. The bootloader (e.g. GRUB) reads the kernel image from disk into RAM and jumps to its entry point, initiating OS startup.

31. Which memory allocation strategy leaves the smallest leftover free block, minimizing waste per allocation but increasing fragmentation over time?

  1. First Fit
  2. Best Fit
  3. Worst Fit
  4. Next Fit
Reveal Answer

Answer: b) Best Fit. Best Fit picks the smallest block that can satisfy the request, but this often creates many small unusable leftover fragments over time.

32. What is the primary drawback of the Worst Fit memory allocation strategy?

  1. Slowest allocation time
  2. Quickly breaks large blocks into small unusable ones, defeating its own purpose over time
  3. Cannot allocate large requests
  4. Only works with paging
Reveal Answer

Answer: b) Quickly breaks large blocks, causing fragmentation despite its intent. Ironically, by always choosing the largest block, Worst Fit tends to leave usable leftover fragments initially, but performs poorly overall compared to First/Best Fit in practice.

33. What is a critical section in concurrent programming?

  1. The fastest part of code
  2. A code segment where shared resources are accessed, requiring mutual exclusion to prevent race conditions
  3. Kernel-only code
  4. Code that can never be interrupted
Reveal Answer

Answer: b) Code segment accessing shared resources needing mutual exclusion. Only one process/thread should execute in its critical section at a time regarding a specific shared resource, enforced via locks/semaphores/monitors.

34. What is a monitor in the context of synchronization?

  1. A hardware display device
  2. A high-level synchronization construct that encapsulates shared data with mutual exclusion and condition variables
  3. A CPU scheduling algorithm
  4. A type of deadlock detector
Reveal Answer

Answer: b) A high-level synchronization construct with built-in mutual exclusion. Monitors bundle shared data, procedures, and synchronization logic (condition variables for wait/signal) into a single, easier-to-use abstraction than raw semaphores.

35. What is the primary benefit of multithreading within a single process?

  1. Each thread gets its own memory space
  2. Lower overhead for creation/context-switching and easier data sharing compared to multiple processes
  3. Threads are more secure than processes
  4. No synchronization needed
Reveal Answer

Answer: b) Lower overhead and easier data sharing than multiple processes. Threads share the process's address space, so creating/switching threads is cheaper than processes, and communication doesn't need IPC mechanisms.

36. What is swapping in the context of memory management?

  1. Exchanging CPU registers
  2. Moving an entire process between main memory and disk (swap space) to free up RAM
  3. Switching between two threads
  4. A type of cache replacement
Reveal Answer

Answer: b) Moving an entire process between main memory and disk. Used to handle situations where physical memory is insufficient; a process is temporarily moved out to swap space and brought back in later.

37. What is locality of reference, and why does it matter for caching?

  1. Physical location of the CPU
  2. The tendency of programs to access a relatively small set of memory locations repeatedly/nearby over a short time period, which caching exploits
  3. A network protocol
  4. A scheduling technique
Reveal Answer

Answer: b) Tendency to access nearby/repeated memory locations, exploited by caching. Temporal locality (reusing recent data) and spatial locality (nearby addresses) are why caches significantly speed up average memory access time.

38. In Round Robin scheduling, what happens if the time quantum is too small?

  1. No effect
  2. Excessive context-switching overhead, reducing overall efficiency
  3. Processes never get CPU time
  4. It becomes FCFS
Reveal Answer

Answer: b) Excessive context-switching overhead. Too small a quantum causes the OS to spend a disproportionate amount of time switching contexts rather than doing actual process work.

39. What is a key characteristic that differentiates kernel-level threads from user-level threads?

  1. No difference
  2. Kernel-level threads are managed/scheduled directly by the OS; user-level threads are managed by a user-space library, invisible to the kernel
  3. User-level threads are always faster in I/O-bound tasks
  4. Kernel-level threads cannot be preempted
Reveal Answer

Answer: b) Kernel threads are OS-managed; user threads are library-managed. Kernel threads can be scheduled on multiple cores and don't block the whole process on a syscall, but have higher creation/switching overhead than user threads.

40. What is the main purpose of an interrupt in OS design?

  1. To terminate processes
  2. To signal the CPU about an event needing immediate attention (I/O completion, hardware signal, etc.), pausing current execution
  3. To allocate memory
  4. To schedule processes only
Reveal Answer

Answer: b) Signal CPU about an event needing immediate attention. Interrupts allow asynchronous handling of events (like I/O completion) without the CPU having to continuously poll devices — the CPU saves state, handles the interrupt, then resumes.

Quick Revision Tips

  • C: Focus on pointers, memory management, and "predict the output" style questions — these dominate assessments.
  • C++: Master virtual functions, constructors/destructors order, and OOP pillars with code-trace questions.
  • DSA: Know time/space complexity of every common algorithm cold — this is tested more than implementation.
  • OS: Deadlock conditions, scheduling algorithms, and paging/segmentation are the highest-yield topics.