Skip to main content

Nepal Engineering Council · Chapter 7

Data Structures and Algorithm, Database System and Operating System

Pick an answer for each question, then open “Show answer” to check it.

189 questions in 6 syllabus topics · 22 tagged from past exams or NEC model sets.

7.1 Introduction to data structures, lists, linked lists and trees

36 questions · ACtE0701

1. What is the maximum number of nodes in a binary tree with height h?

Aasadh 2081 exam
  1. Option A: 2^h
  2. Option B: 2^h - 1
  3. Option C: 2^(h+1) - 1
  4. Option D: 2^(h-1)
Show hint

A complete binary tree with height h has this many maximum nodes.

Show answer

Answer: C. 2^(h+1) - 1

Maximum nodes in binary tree of height h = 2^(h+1) - 1. This occurs in a complete binary tree.

2. What binary tree nodes with height h?

  1. Option A: 2^h
  2. Option B: 2^h - 1
  3. Option C: 2^(h+1) - 1
  4. Option D: 2^(h-1)
Show hint

Complete tree maximum.

Show answer

Answer: C. 2^(h+1) - 1

Maximum nodes in binary tree height h is 2^(h+1) - 1.

3. Which of the following best distinguishes a data structure from an abstract data type (ADT)?

  1. Option A: A data structure is theoretical; an ADT is implementation-oriented
  2. Option B: A data structure is a concrete implementation; an ADT is a logical model specifying operations and behavior
  3. Option C: Both terms mean exactly the same thing in computer science
  4. Option D: An ADT is always implemented using arrays, never linked lists
Show hint

Think about interface vs implementation: "what" vs "how".

Show answer

Answer: B. A data structure is a concrete implementation; an ADT is a logical model specifying operations and behavior

An abstract data type (ADT) describes *what* operations are available and the logical behavior of a collection of data, without prescribing *how* the operations are implemented. For example, a Stack ADT specifies push, pop, top, isEmpty, and their semantics (LIFO), but it does not say whether the stack is realized with an array or a linked list. A data structure is the concrete representation in memory and the algorithms that implement those operations: for instance, an array-based stack with a top index, or a linked-list-based stack with a head pointer. Separating ADT from data structure gives design flexibility: client code can depend on the ADT interface and later swap implementations for better performance or memory usage without changing that code. This distinction is foundational for algorithm design, API design, and clean software architecture.

4. In asymptotic analysis, what does Big-O notation primarily describe?

  1. Option A: The exact running time of an algorithm for all input sizes
  2. Option B: The upper bound on the growth rate of an algorithm's time or space as input size tends to infinity
  3. Option C: The lower bound on the running time of an algorithm
  4. Option D: The average running time of an algorithm over all inputs
Show hint

Think of it as a worst-case growth rate classification, ignoring constant factors.

Show answer

Answer: B. The upper bound on the growth rate of an algorithm's time or space as input size tends to infinity

Big-O notation, written as O(f(n)), provides an asymptotic upper bound on how an algorithm's resource usage (time or space) grows with input size n. It captures the dominant term of a complexity function and discards constant factors and lower-order terms. For example, if an algorithm takes T(n) = 3n^2 + 5n + 20 steps, we say T(n) = O(n^2) because, for sufficiently large n, n^2 dominates the growth. Big-O is typically used for worst-case analysis: for instance, worst-case time of insertion sort is O(n^2). Complementary notations are Big-Omega Ω(f(n)), which gives an asymptotic lower bound, and Big-Theta Θ(f(n)), which simultaneously gives both an asymptotic upper and lower bound, tightly characterizing growth. Mastering these notations is essential for comparing algorithms independently of specific hardware or implementation details.

5. For an algorithm with time complexity T(n) = 5n log n + 2n + 100, which of the following asymptotic bounds is tight (Big-Theta)?

  1. Option A: Θ(n)
  2. Option B: Θ(n log n)
  3. Option C: Θ(n^2)
  4. Option D: Θ(log n)
Show hint

Identify the dominant term as n grows large and ignore constants.

Show answer

Answer: B. Θ(n log n)

The time complexity T(n) = 5n log n + 2n + 100 consists of three terms. Among these, n log n grows faster than n and any constant as n → ∞. The coefficient 5 does not affect the asymptotic class. Therefore, T(n) is in O(n log n) (upper bound) and Ω(n log n) (lower bound), which together imply T(n) = Θ(n log n). A Θ bound means that n log n both upper-bounds and lower-bounds T(n) up to constant factors. This kind of reasoning is standard when analyzing divide-and-conquer algorithms like mergesort and heapsort, which typically have Θ(n log n) time complexity.

6. Which of the following operations is typically O(1) for an array-based implementation of a stack with a fixed capacity (ignoring overflow/underflow checks)?

  1. Option A: Push
  2. Option B: Searching for an element
  3. Option C: Removing an element from the bottom of the stack
  4. Option D: Merging two stacks
Show hint

Focus on operations that touch only the top and a single index variable.

Show answer

Answer: A. Push

In an array-based stack, the stack is represented by an array and a top index that indicates the position of the current top element. A push operation increments the top index and writes the new value at that position, which is a constant-time operation independent of the number of elements, so its time complexity is O(1). Similarly, pop is also O(1) because it just reads from the top index and decrements it. Operations such as searching or removing from the bottom require traversing multiple elements, giving O(n) in the worst case. This constant-time top access is precisely why stacks are efficient and heavily used in language runtimes (for function calls), expression evaluation, and backtracking algorithms.

7. Which of the following expressions correctly represents a postfix (Reverse Polish) form of the infix expression (A + B) * (C - D)?

  1. Option A: AB+CD-*
  2. Option B: AB+*CD-
  3. Option C: A+B*C-D
  4. Option D: ABCD+-*
Show hint

In postfix, operators appear after their operands; handle inner parentheses first.

Show answer

Answer: A. AB+CD-*

To convert (A + B) * (C - D) to postfix, process the innermost sub-expressions: A + B becomes AB+, and C - D becomes CD-. Then the entire expression is (AB+) * (CD-), so the postfix is AB+CD-*. In general, postfix notation places the operator after its operands and eliminates parentheses, relying on the operator position and stack-based evaluation. This format is ideal for stack evaluation algorithms: scanning from left to right, operands are pushed on a stack and operators pop operands, compute a result, and push it back. Many expression evaluators, compiler back ends, and calculators use postfix or similar internal representations because they make precedence and associativity explicit and unambiguous.

8. During evaluation of a postfix expression using a stack, what is the correct order of operand usage when an operator is encountered?

  1. Option A: Pop first operand as right, second as left
  2. Option B: Pop first operand as left, second as right
  3. Option C: Use any order; it does not matter
  4. Option D: Always treat both popped operands as commutative
Show hint

Think of how "A B -" should be evaluated as A - B, not B - A.

Show answer

Answer: A. Pop first operand as right, second as left

When evaluating a postfix expression, each time an operator is encountered, two operands are popped from the stack. The first popped operand corresponds to the *right* operand, and the second popped operand corresponds to the *left* operand. For example, for the postfix sequence "A B -", after pushing A then B, encountering '-' means: pop B (right operand), pop A (left operand), compute A − B, and push the result. This order is crucial for non-commutative operations such as subtraction and division. If you reversed them, you would compute B − A, which is incorrect. This right-then-left rule ensures postfix representation faithfully captures the original infix semantics.

9. In a singly linked list, what is the time complexity of inserting a new node at the head (front) of the list?

  1. Option A: O(1)
  2. Option B: O(log n)
  3. Option C: O(n)
  4. Option D: O(n log n)
Show hint

You only need to change a constant number of pointers.

Show answer

Answer: A. O(1)

In a singly linked list where you maintain a pointer to the head node, inserting at the front requires only allocating a new node, setting its next pointer to the current head, and then updating the head pointer to the new node. These are all constant-time operations, independent of the list length, so the insertion at the head is O(1). In contrast, inserting at the tail is O(1) only if you also maintain a tail pointer; otherwise, it is O(n) because you must traverse the list to find the last node. Understanding these costs is key when choosing between array-based and linked-list-based representations for lists, stacks, and queues.

10. Which of the following linked list types allows traversal in both forward and backward directions without extra data structures?

  1. Option A: Singly linked list
  2. Option B: Doubly linked list
  3. Option C: Circular singly linked list
  4. Option D: Static array-based list
Show hint

Each node maintains two links.

Show answer

Answer: B. Doubly linked list

In a doubly linked list, each node maintains two pointers: one to the next node and one to the previous node. This structure allows traversal in both forward and backward directions by following next and prev pointers respectively. It also makes certain operations such as deletion of a known node easier, because you can directly access both its predecessor and successor without a separate search. A singly linked list only stores next pointers, so to move backward you would have to start again from the head or maintain auxiliary structures. Circular lists alter the boundary behavior (last node points back to first) but do not inherently add backward traversal unless they are circular doubly linked lists.

11. What is a key advantage of a circular linked list over a simple singly linked list for certain applications?

  1. Option A: It eliminates the need for a head pointer
  2. Option B: It allows easily cycling through all nodes from any starting node without hitting a null pointer
  3. Option C: It reduces memory usage for pointers
  4. Option D: It guarantees faster search operations
Show hint

Think about structures that model rings or round-robin scheduling.

Show answer

Answer: B. It allows easily cycling through all nodes from any starting node without hitting a null pointer

In a circular linked list, the last node points back to the first node instead of storing a null next pointer. This makes the list logically circular. As a result, if you start from any node and keep following next pointers, you will eventually return to the starting node after visiting all others, and you will never hit a null. This property is useful in applications like round-robin scheduling, buffer management, or games where you conceptually move around a ring of elements. However, circular lists do not by themselves improve time complexity for search or insertion; they mostly affect boundary conditions and traversal patterns.

12. In a binary tree, what is the height of a tree with a single node (no children), assuming the convention that height is the number of edges on the longest path from root to a leaf?

  1. Option A: -1
  2. Option B: 0
  3. Option C: 1
  4. Option D: 2
Show hint

Count the number of edges, not nodes, on the longest root-to-leaf path.

Show answer

Answer: B. 0

If height is defined as the number of edges on the longest simple path from the root to any leaf, then a single-node tree (with just the root, which is also a leaf) has height 0, because there are no edges. Some texts instead define height as the number of nodes on that path, in which case the same tree would have height 1. It is important to check the convention being used. For algorithm analysis involving trees (such as AVL trees or heaps), the edge-based definition (height 0 for a single node) is common, because each level adds one edge of distance from the root.

13. Which traversal of a binary search tree (BST) will visit the nodes in sorted (non-decreasing) order of their keys?

  1. Option A: Pre-order traversal
  2. Option B: In-order traversal
  3. Option C: Post-order traversal
  4. Option D: Level-order traversal
Show hint

Visit left subtree, then root, then right subtree.

Show answer

Answer: B. In-order traversal

For a Binary Search Tree, by definition all keys in the left subtree of a node are less than the node’s key and all keys in the right subtree are greater. An in-order traversal (Left, Root, Right) recursively visits all nodes in the left subtree, then the node itself, then all nodes in the right subtree. Because of the BST ordering property, this yields the keys in non-decreasing sorted order. This property is fundamental: many BST-based algorithms rely on in-order traversal to output sorted sequences or to check that a tree maintains the BST invariant.

14. In an AVL tree, what is the balance factor of a node?

  1. Option A: The number of children of the node
  2. Option B: The height of the node's left subtree minus the height of its right subtree
  3. Option C: The number of nodes in its left subtree
  4. Option D: The total height of the tree
Show hint

AVL trees keep this value within -1, 0, or +1 for every node.

Show answer

Answer: B. The height of the node's left subtree minus the height of its right subtree

The balance factor of a node in an AVL tree is defined as BF(node) = height(left subtree) − height(right subtree). For an AVL tree, this balance factor must be −1, 0, or +1 for every node. If insertion or deletion causes the balance factor of some node to go outside this range, the tree is rebalanced by performing one or more rotations (LL, RR, LR, RL) to restore the AVL property. By maintaining strictly bounded imbalance, AVL trees guarantee that the tree height stays in O(log n), providing O(log n) worst-case time for search, insertion, and deletion, unlike plain BSTs which can degenerate to O(n) height in pathological cases.

15. Which search structure can guarantee O(log n) time for search, insertion, and deletion by maintaining a height-balanced binary search tree?

  1. Option A: Unbalanced binary search tree
  2. Option B: AVL tree
  3. Option C: Singly linked list
  4. Option D: Hash table with chaining
Show hint

It uses rotations after insert/delete to keep the tree balanced.

Show answer

Answer: B. AVL tree

An AVL tree is a self-balancing binary search tree in which the height difference (balance factor) between the left and right subtrees of any node is at most 1. After every insertion or deletion, the tree is checked for balance factor violations; if found, local tree rotations (single or double) are performed to restore the AVL property. Because the height of an AVL tree with n nodes remains O(log n), searching, inserting, and deleting all take O(log n) in the worst case. In contrast, an unbalanced BST can degenerate into a chain with O(n) height. Hash tables typically have O(1) expected-time operations but not the strict worst-case logarithmic bound, and they do not maintain a sorted key order.

16. What is maximum nodes in binary tree height h?

  1. Option A: 2^h
  2. Option B: 2^h - 1
  3. Option C: 2^(h+1) - 1
  4. Option D: 2^(h-1)
Show hint

Complete tree maximum.

Show answer

Answer: C. 2^(h+1) - 1

Maximum nodes in binary tree of height h = 2^(h+1) - 1.

17. Binary tree requirement?

  1. Option A: Balanced
  2. Option B: Complete
  3. Option C: Sorted
  4. Option D: One child
Show hint

BST property.

Show answer

Answer: C. Sorted

Binary search tree requires sorted order: left < root < right.

18. Which data structure is linear with pointer?

  1. Option A: Stack
  2. Option B: Queue
  3. Option C: Linked List
  4. Option D: Tree
Show hint

Each element points to next.

Show answer

Answer: C. Linked List

Linked list is linear collection where each element points to next.

19. Which follows FIFO principle?

  1. Option A: Queue
  2. Option B: Stack
  3. Option C: Linked List
  4. Option D: Tree
Show hint

First in, first out.

Show answer

Answer: A. Queue

Queue follows FIFO: first element added is first removed.

20. Common for implementing queue?

  1. Option A: Linked list
  2. Option B: Array
  3. Option C: Stack
  4. Option D: Hash table
Show hint

Dynamic size needed.

Show answer

Answer: A. Linked list

Linked lists commonly implement queues for dynamic size management.

21. Which data structure implements LIFO?

  1. Option A: Queue
  2. Option B: Stack
  3. Option C: Heap
  4. Option D: Tree
Show hint

Last in, first out.

Show answer

Answer: B. Stack

Stack implements LIFO: last element added is first removed.

22. Full binary tree leaves?

  1. Option A: L = 2*I
  2. Option B: L = I + 1
  3. Option C: L = I - 1
  4. Option D: L = 2*I - 1
Show hint

Leaf-node relation.

Show answer

Answer: B. L = I + 1

In full binary tree, leaves = internal nodes + 1.

23. What stack property use?

  1. Option A: FIFO
  2. Option B: LIFO
  3. Option C: Random
  4. Option D: Priority
Show hint

Last in, first out.

Show answer

Answer: B. LIFO

Stack uses LIFO: last pushed element popped first.

24. Deque allows?

  1. Option A: Delete front
  2. Option B: Insert rear
  3. Option C: Both
  4. Option D: Neither
Show hint

Double-ended queue.

Show answer

Answer: C. Both

Deque allows insertion and deletion at both ends.

25. In a circular doubly linked list, the previous pointer of the first node points to:

NEC model set
  1. Option A: a) Null
  2. Option B: b) Last node
  3. Option C: c) Second node
  4. Option D: d) Itself
Show hint

In a circular list, everything points to something (nothing is null). First node's previous?

Show answer

Answer: B. b) Last node

In a circular doubly linked list, the previous pointer of the first node points to the last node. This creates a circle where the last node's next pointer also points back to the first node. This structure allows traversal in both directions without reaching a null pointer. It's useful for round-robin scheduling and playlist applications where you need to loop through elements.

26. What is the postfix notation of the infix expression (A+B)*C?

Recalled from Jan 2026 exam
  1. Option A: AB+C*
  2. Option B: ABC+*
  3. Option C: A+BC*
  4. Option D: CAB+*
Show hint

Convert infix to postfix: operators come after operands. What is it?

Show answer

Answer: A. AB+C*

The postfix notation of the infix expression (A+B)*C is AB+C*. In postfix notation (Reverse Polish Notation), operators appear after their operands. To convert (A+B)*C to postfix: (1) A and B are operands, A B, (2) + operator comes after A and B, so AB+, (3) The result (A+B) is multiplied by C, so AB+ then C and *, giving AB+C*. Postfix notation is useful for expression evaluation using stacks and is used in many calculators and compilers.

27. Which data structure follows the Last-In-First-Out (LIFO) principle?

  1. Option A: Queue
  2. Option B: Stack
  3. Option C: Linked List
  4. Option D: Tree
Show answer

Answer: B. Stack

28. The postfix expression for the infix expression A+B*C is:

  1. Option A: ABC+*
  2. Option B: AB+C*
  3. Option C: ABC*+
  4. Option D: +A*BC
Show answer

Answer: C. ABC*+

29. Which data structure follows the First-In-First-Out (FIFO) principle?

  1. Option A: Queue
  2. Option B: Stack
  3. Option C: Linked List
  4. Option D: Tree
Show answer

Answer: A. Queue

30. An AVL tree is:

  1. Option A: A binary search tree
  2. Option B: A balanced binary search tree
  3. Option C: A complete binary tree
  4. Option D: A full binary tree
Show answer

Answer: B. A balanced binary search tree

31. In a singly linked list, each node contains:

  1. Option A: Data and a pointer to the previous node
  2. Option B: Data and a pointer to the next node
  3. Option C: Data and pointers to both previous and next nodes
  4. Option D: Only data
Show answer

Answer: B. Data and a pointer to the next node

32. Which notation is used to represent the upper bound of an algorithm's time complexity?

  1. Option A: Big Oh (O)
  2. Option B: Omega (Ω)
  3. Option C: Theta (Θ)
  4. Option D: Delta (Δ)
Show answer

Answer: A. Big Oh (O)

33. Which of the following is NOT a type of linked list?

  1. Option A: Singly Linked List
  2. Option B: Doubly Linked List
  3. Option C: Circular Linked List
  4. Option D: Binary Linked List
Show answer

Answer: D. Binary Linked List

34. The height of a complete binary tree with n nodes is:

  1. Option A: log₂n
  2. Option B: n/2
  3. Option C: ⌊log₂n⌋
  4. Option D: n-1
Show answer

Answer: C. ⌊log₂n⌋

35. Which traversal of a binary tree visits the root node first?

  1. Option A: In-order
  2. Option B: Pre-order
  3. Option C: Post-order
  4. Option D: Level-order
Show answer

Answer: B. Pre-order

36. The time complexity of insertion in a singly linked list at the beginning is:

  1. Option A: O(1)
  2. Option B: O(log n)
  3. Option C: O(n)
  4. Option D: O(n²)
Show answer

Answer: A. O(1)

7.2 Sorting, searching and graphs

43 questions · ACtE0702

37. What is the worst-case time complexity of Shell sort?

Aasadh 2081 exam
  1. Option A: O(n)
  2. Option B: O(n log n)
  3. Option C: O(n²)
  4. Option D: O(n³)
Show hint

Depends on gap sequence used.

Show answer

Answer: C. O(n²)

Shell sort worst-case is O(n²) when using poor gap sequences.

38. What does Warshall algorithm give?

Aasadh 2081 exam
  1. Option A: Transitive closure
  2. Option B: Shortest distance
  3. Option C: Minimum spanning tree
  4. Option D: Topological sorting
Show hint

Determines reachability between all pairs of vertices.

Show answer

Answer: A. Transitive closure

Warshall's algorithm computes the transitive closure of a directed graph, determining path existence between all vertex pairs.

39. What is Dijkstra paradigm?

  1. Option A: Greedy
  2. Option B: Backtracking
  3. Option C: Dynamic Programming
  4. Option D: Divide Conquer
Show hint

Greedy choice at each step.

Show answer

Answer: A. Greedy

Dijkstra's shortest path uses greedy paradigm.

40. What does Warshall algorithm compute?

  1. Option A: Transitive closure
  2. Option B: Shortest distance
  3. Option C: MST
  4. Option D: Topological sort
Show hint

Path existence.

Show answer

Answer: A. Transitive closure

Warshall's algorithm computes transitive closure of directed graph.

41. Complexity binary search?

  1. Option A: O(n)
  2. Option B: O(log n)
  3. Option C: O(n²)
  4. Option D: O(n log n)
Show hint

Divide and conquer.

Show answer

Answer: B. O(log n)

Binary search has O(log n) complexity.

42. Shell sort worst-case?

  1. Option A: O(n)
  2. Option B: O(n log n)
  3. Option C: O(n²)
  4. Option D: O(n³)
Show hint

Gap sequence dependent.

Show answer

Answer: C. O(n²)

Shell sort worst-case is O(n²) with poor gap sequences.

43. Quicksort average case?

  1. Option A: O(n)
  2. Option B: O(n²)
  3. Option C: O(n log n)
  4. Option D: O(log n)
Show hint

Divide and conquer.

Show answer

Answer: C. O(n log n)

Quicksort average case is O(n log n).

44. Which of the following correctly describes an internal (in-place) sorting algorithm?

  1. Option A: It requires additional memory proportional to the input size (O(n))
  2. Option B: It performs sorting by using only a constant amount of extra memory, aside from the input array
  3. Option C: It can only sort small datasets that fit in main memory
  4. Option D: It always uses recursion
Show hint

Focus on extra space overhead, not whether the data fits into RAM.

Show answer

Answer: B. It performs sorting by using only a constant amount of extra memory, aside from the input array

An internal or in-place sorting algorithm rearranges elements within the original array or list using only a constant amount of additional memory, typically O(1) extra space. Classic examples include insertion sort, selection sort, bubble sort, heapsort, and in-place variants of quicksort. External sorting deals with data sets that are too large to fit in main memory and therefore require disk or external storage; such algorithms (like external mergesort) are not in-place, since they rely on additional temporary files or buffers. Space complexity is important in environments with limited memory, such as embedded systems or when handling large in-memory datasets.

45. What is the worst-case time complexity of insertion sort on an array of n elements?

  1. Option A: O(n)
  2. Option B: O(n log n)
  3. Option C: O(n^2)
  4. Option D: O(log n)
Show hint

Each inserted element may need to be compared with almost all previous elements.

Show answer

Answer: C. O(n^2)

Insertion sort builds a sorted prefix by repeatedly taking the next element and inserting it into the correct position within the already-sorted part. In the worst case (when the array is in reverse order), each insertion of the i-th element requires comparing and shifting roughly i − 1 elements. Summing over i from 1 to n gives 1 + 2 + … + (n − 1) = O(n^2). However, insertion sort has O(n) best-case complexity (when the array is already sorted) and performs very well on small or nearly sorted data, which is why it is often used as the base case in hybrid sorting algorithms like introsort.

46. In merge sort, what is the main reason its time complexity is Θ(n log n) in all cases?

  1. Option A: It only uses swapping operations
  2. Option B: It does not use recursion
  3. Option C: It always performs log n levels of merging, each processing n elements
  4. Option D: It uses a heap structure internally
Show hint

Think in terms of repeatedly dividing and then merging.

Show answer

Answer: C. It always performs log n levels of merging, each processing n elements

Merge sort works by repeatedly splitting the array into halves (recursively) until subarrays of size 1 are reached, and then merging those subarrays back together in sorted order. The depth of this recursion tree is about log₂ n (you can divide n by 2 only log n times before reaching 1). At each level of the recursion tree, the algorithm processes all n elements in the merging step. Therefore, the total cost is approximately n (work per level) × log n (number of levels) = Θ(n log n). Mergesort has this complexity in the best, average, and worst cases because the splitting and merging pattern does not depend on the initial arrangement of data.

47. What is the main idea behind radix sort for sorting integers?

  1. Option A: Comparing pairs of keys and swapping them
  2. Option B: Using a binary search tree to store keys and then traversing it
  3. Option C: Sorting keys digit by digit using a stable stable subroutine (like counting sort) for each digit position
  4. Option D: Randomly shuffling elements until they are sorted
Show hint

It is a non-comparison-based algorithm that exploits the structure of keys.

Show answer

Answer: C. Sorting keys digit by digit using a stable stable subroutine (like counting sort) for each digit position

Radix sort sorts integers (or string-like keys) by processing individual digits (or characters) from least significant to most significant (LSD) or vice versa (MSD). For LSD radix sort on base-10 numbers, you repeatedly group numbers according to their 1s digit, then 10s digit, then 100s digit, etc., each time using a stable sorting algorithm like counting sort to preserve the relative order of elements with the same digit. Because it does not rely on direct comparisons between keys, radix sort can achieve O(d·(n + k)) time, where d is the number of digits and k is the digit range (base). For fixed-size integers, d and k are bounded constants, giving linear time complexity in n. Radix sort is effective when keys have fixed maximum length and the base is chosen appropriately.

48. Which of the following best describes the binary search algorithm on a sorted array?

  1. Option A: It scans the array from left to right until the element is found
  2. Option B: It repeatedly divides the search interval in half by comparing the target to the middle element
  3. Option C: It builds a search tree and then performs in-order traversal
  4. Option D: It hashes all elements and checks the hash table
Show hint

Each comparison discards half of the remaining search space.

Show answer

Answer: B. It repeatedly divides the search interval in half by comparing the target to the middle element

Binary search maintains a search interval [low, high] on a sorted array. At each step, it computes mid = (low + high)/2, compares the target value to arr[mid], and discards half the interval: if target < arr[mid], it continues searching in [low, mid − 1]; if target > arr[mid], it continues in [mid + 1, high]. This halving continues until the element is found or the interval becomes empty. Because the search space size halves at each step, the worst-case running time is O(log n). Binary search is one of the classic divide-and-conquer algorithms and relies critically on the array being sorted and random access being O(1).

49. What is the main purpose of a hash function in a hash table?

  1. Option A: To sort all keys before insertion
  2. Option B: To map keys to array indices in a way that spreads them out uniformly
  3. Option C: To ensure cryptographic security of stored data
  4. Option D: To compress large files
Show hint

It converts a key into an index into the bucket array.

Show answer

Answer: B. To map keys to array indices in a way that spreads them out uniformly

A hash function h(key) takes a key (for example, a string, integer, or other object) and computes an integer index within the bounds of the hash table array. A good hash function distributes keys approximately uniformly across the table to minimize the number and length of collisions (when different keys map to the same index). Ideal hashing would give O(1) expected time for lookup, insertion, and deletion, but in practice some collisions are unavoidable. Collision resolution strategies (like chaining or open addressing) are used in combination with the hash function. While cryptographic hash functions also map arbitrary data to fixed-size outputs, hash tables typically use faster non-cryptographic hash functions designed for uniform distribution rather than security.

50. Which collision resolution technique in hashing uses a linked list at each table slot?

  1. Option A: Linear probing
  2. Option B: Quadratic probing
  3. Option C: Separate chaining
  4. Option D: Double hashing
Show hint

Colliding keys are stored in a secondary structure attached to each bucket.

Show answer

Answer: C. Separate chaining

In separate chaining, each index (bucket) of the hash table stores a pointer to a linked list (or another structure like a balanced tree). All keys that hash to the same index are inserted into that list. Lookup and deletion involve traversing only the list for that bucket. If the load factor (n / table_size) remains bounded (by resizing when too large), the expected length of each chain remains constant, keeping average operation times near O(1). This method is simple to implement and works well when the underlying memory allocator handles small allocations efficiently. Open addressing schemes like linear probing, quadratic probing, and double hashing instead store all keys directly in the array and resolve collisions by probing alternative indices.

51. In an undirected graph with n vertices and no self-loops, what is the maximum possible number of edges?

  1. Option A: n^2
  2. Option B: n(n − 1)
  3. Option C: n(n − 1)/2
  4. Option D: 2n
Show hint

Think of choosing any unordered pair of distinct vertices.

Show answer

Answer: C. n(n − 1)/2

In an undirected simple graph (no parallel edges, no self-loops), each edge connects a distinct unordered pair of vertices. The number of such pairs is the binomial coefficient C(n, 2) = n(n − 1)/2. This is the maximum number of edges because any additional edge would either duplicate an existing edge between the same two vertices or create a self-loop, both of which are disallowed in a simple graph. Graph density, adjacency matrix vs adjacency list storage, and complexity of algorithms like DFS and BFS all depend strongly on the number of edges relative to n.

52. Which traversal algorithm always uses a queue data structure to explore a graph level by level?

  1. Option A: Depth First Search (DFS)
  2. Option B: Breadth First Search (BFS)
  3. Option C: Dijkstra's algorithm
  4. Option D: Prim's algorithm
Show hint

It visits all neighbors of a vertex before going deeper.

Show answer

Answer: B. Breadth First Search (BFS)

Breadth First Search explores a graph in layers starting from a source vertex. It uses a FIFO queue: initially, the source vertex is enqueued, then BFS repeatedly dequeues a vertex, visits it, and enqueues all its unvisited neighbors. This leads to a level-order traversal where all vertices at distance 1 from the source are visited before those at distance 2, and so on. BFS is used to compute shortest paths in unweighted graphs, to test connectivity, and as a building block in algorithms like bipartite graph checking. DFS, in contrast, uses a stack (explicit or via recursion) and explores as deep as possible along each path before backtracking.

53. Which of the following algorithms is specifically designed to compute a minimum spanning tree (MST) of a connected weighted undirected graph?

  1. Option A: Dijkstra's algorithm
  2. Option B: Kruskal's algorithm
  3. Option C: Bellman–Ford algorithm
  4. Option D: Warshall's algorithm
Show hint

It repeatedly picks the lightest edge that does not create a cycle.

Show answer

Answer: B. Kruskal's algorithm

Kruskal's algorithm is a greedy algorithm for finding a minimum spanning tree in a connected weighted undirected graph. It sorts all edges in non-decreasing order of weight and then, starting from an empty forest, repeatedly adds the lightest edge that does not form a cycle until all vertices are connected. Cycle detection is typically implemented with a disjoint-set (union–find) data structure. Prim's algorithm is another MST algorithm that grows a tree from an arbitrary root by repeatedly selecting the minimum-weight edge that connects a visited vertex to an unvisited vertex. Dijkstra's and Bellman–Ford are shortest-path algorithms, and Warshall's algorithm computes transitive closure/all-pairs reachability.

54. What problem does Dijkstra's algorithm solve on a weighted graph?

  1. Option A: Finding a minimum spanning tree
  2. Option B: Finding a topological ordering
  3. Option C: Finding single-source shortest paths in a graph with non-negative edge weights
  4. Option D: Computing the transitive closure
Show hint

It uses a greedy strategy with a priority queue to relax edges.

Show answer

Answer: C. Finding single-source shortest paths in a graph with non-negative edge weights

Dijkstra's algorithm finds the shortest path from a single source vertex to all other vertices in a weighted graph, assuming all edge weights are non-negative. It maintains a set of vertices whose shortest distance from the source is known, and in each step, selects the vertex with the minimum tentative distance (often using a min-priority queue) and relaxes its outgoing edges. Repeating this process n times in a graph with adjacency list representation and a binary heap yields time complexity O((V + E) log V). If negative edge weights are present, Dijkstra's algorithm can give incorrect results and algorithms like Bellman–Ford or Johnson's algorithm are used instead.

55. Which graph algorithm is commonly used to compute the transitive closure of a directed graph represented as an adjacency matrix?

  1. Option A: Warshall's algorithm
  2. Option B: Prim's algorithm
  3. Option C: Kruskal's algorithm
  4. Option D: DFS tree construction
Show hint

It is an all-pairs reachability algorithm based on dynamic programming.

Show answer

Answer: A. Warshall's algorithm

Warshall's algorithm (often called Floyd–Warshall when extended to weighted graphs) computes the transitive closure of a directed graph, meaning it determines for every pair of vertices (i, j) whether there exists a path from i to j. Using an adjacency matrix representation, it iteratively updates reachability information by allowing intermediate vertices in paths. At each step k, it checks whether going from i to j via k gives a new reachable path. The algorithm runs in O(V^3) time for a graph with V vertices and is especially suitable when V is relatively small and the graph is dense. For sparse graphs, repeated DFS or BFS from each vertex may be more efficient.

56. Which of the following describes a topological ordering of a directed acyclic graph (DAG)?

  1. Option A: An ordering of vertices where every edge goes from a vertex later in the order to one earlier
  2. Option B: An ordering of vertices such that for every directed edge u → v, u appears before v in the ordering
  3. Option C: An ordering that minimizes the number of edges
  4. Option D: An ordering produced only by breadth-first search
Show hint

It respects all precedence constraints encoded by edges.

Show answer

Answer: B. An ordering of vertices such that for every directed edge u → v, u appears before v in the ordering

A topological sort of a DAG is a linear ordering of its vertices such that if there is a directed edge u → v, then u precedes v in the order. This is possible only if the graph has no cycles. Topological ordering is fundamental in scheduling tasks with dependencies, resolving symbol dependencies in compilers, and evaluating circuits. Standard algorithms to compute such an order use DFS (recording vertices in reverse post-order) or Kahn’s algorithm (repeatedly removing nodes with zero in-degree). Both rely on the acyclic nature of the graph.

57. Efficient for sorted data?

  1. Option A: Insertion sort
  2. Option B: Merge sort
  3. Option C: Quick sort
  4. Option D: Bubble sort
Show hint

O(n) for sorted.

Show answer

Answer: A. Insertion sort

Insertion sort is efficient for already sorted data with O(n) complexity.

58. Best case quicksort?

  1. Option A: O(n)
  2. Option B: O(n log n)
  3. Option C: O(n²)
  4. Option D: O(log n)
Show hint

Balanced partition.

Show answer

Answer: B. O(n log n)

Best-case quicksort is O(n log n) with balanced partitioning.

59. Complexity DFS?

  1. Option A: O(n)
  2. Option B: O(n²)
  3. Option C: O(log n)
  4. Option D: O(n log n)
Show hint

Visit each vertex once.

Show answer

Answer: A. O(n)

DFS has O(V+E) or O(n) complexity visiting each node once.

60. Graph traversal BFS?

  1. Option A: Stack
  2. Option B: Queue
  3. Option C: Heap
  4. Option D: Tree
Show hint

Level-by-level.

Show answer

Answer: B. Queue

BFS uses queue for level-by-level traversal.

61. Merge sort complexity?

  1. Option A: O(n)
  2. Option B: O(n log n)
  3. Option C: O(n²)
  4. Option D: O(log n)
Show hint

Divide and conquer.

Show answer

Answer: B. O(n log n)

Merge sort has O(n log n) complexity in all cases.

62. Shortest path algorithm?

  1. Option A: DFS
  2. Option B: BFS
  3. Option C: Dijkstra
  4. Option D: Floyd
Show hint

Weights considered.

Show answer

Answer: C. Dijkstra

Dijkstra finds shortest path in weighted graphs.

63. What is the hash function used in the division method?

NEC model set
  1. Option A: h(k) = k·m
  2. Option B: h(k) = k mod m
  3. Option C: h(k) = m·k
  4. Option D: h(k) = m mod k
Show hint

Division method uses modulo operation to map keys to hash table positions.

Show answer

Answer: B. h(k) = k mod m

The division method hash function is: h(k) = k mod m, where k is the key and m is the hash table size. Division method characteristics: (1) Simple to implement - Just one modulo operation, (2) Fast computation - Direct calculation, (3) Widely used - Common in practice. How it works: (1) Divide key by table size (m), (2) Remainder is hash value, (3) Result is between 0 and m-1 (valid table indices). Example: (1) Table size m = 10, (2) Key k = 23, (3) h(23) = 23 mod 10 = 3, (4) Key stored at index 3. Choosing m (table size): (1) Avoid m as power of 2 - Poor distribution for binary keys, (2) Avoid m as power of 10 - Poor distribution for decimal keys, (3) Use prime number - Generally provides good distribution, (4) Example: m = 11, 13, 17, 19, 23 (primes) work well. Hash function quality: (1) Uniform distribution - Keys spread evenly across table, (2) Deterministic - Same key always produces same hash, (3) Fast computation - O(1) time. Load factor: (1) λ = n/m (n = number of keys, m = table size), (2) Affects collision frequency, (3) Typically keep λ < 0.75. Other hash methods: (1) Multiplication method - h(k) = ⌊m(kA mod 1)⌋, (2) Universal hashing - Multiple hash functions. Collision resolution: (1) Chaining - Store colliding keys in linked list, (2) Open addressing - Find another empty slot (linear probing, quadratic probing, double hashing). The division method is practical despite its simplicity.

64. Time complexity of Merge Sort in the best case is:

NEC model set
  1. Option A: a) O(n)
  2. Option B: b) O(n log n)
  3. Option C: c) O(n²)
  4. Option D: d) O(log n)
Show hint

Merge sort's performance is consistent regardless of input. What's the complexity?

Show answer

Answer: B. b) O(n log n)

The time complexity of Merge Sort in the best case is O(n log n). Unlike quick sort which has best case O(n log n) and worst case O(n²), merge sort maintains O(n log n) in all cases: best, average, and worst. This consistency makes merge sort a stable, predictable sorting algorithm. The n log n comes from dividing the array logarithmically and merging linearly at each level.

65. Which data structure is used to implement Breadth First Search (BFS)?

Recalled from Jan 2026 exam
  1. Option A: Stack
  2. Option B: Queue
  3. Option C: Linked List
  4. Option D: Tree
Show hint

BFS explores nodes level by level. What FIFO structure enables this?

Show answer

Answer: B. Queue

Queue is the data structure used to implement Breadth First Search (BFS). BFS uses a FIFO (First-In-First-Out) queue to explore nodes level by level. Starting from a source node, BFS adds all its unvisited neighbors to the queue. Then it processes the first node in the queue, adds its unvisited neighbors, and continues. This ensures that all nodes at distance k are visited before nodes at distance k+1, providing level-by-level exploration. Stack would implement DFS (Depth-First Search). Linked lists and trees are not data structures for implementing search algorithms but rather the structures being searched.

66. Which sorting algorithm has the best average-case time complexity?

  1. Option A: Bubble Sort
  2. Option B: Insertion Sort
  3. Option C: Quick Sort
  4. Option D: Selection Sort
Show answer

Answer: C. Quick Sort

67. The time complexity of binary search is:

  1. Option A: O(n)
  2. Option B: O(log n)
  3. Option C: O(n log n)
  4. Option D: O(n²)
Show answer

Answer: B. O(log n)

68. Binary search can be applied to:

  1. Option A: Any list
  2. Option B: Sorted list only
  3. Option C: Linked list only
  4. Option D: Unsorted list only
Show answer

Answer: B. Sorted list only

69. A collision in hashing occurs when:

  1. Option A: Two different keys hash to the same value
  2. Option B: A key cannot be hashed
  3. Option C: The hash table is full
  4. Option D: The hash function returns a negative value
Show answer

Answer: A. Two different keys hash to the same value

70. Hashing is used for:

  1. Option A: Sorting data
  2. Option B: Fast data retrieval
  3. Option C: Data compression
  4. Option D: Data encryption
Show answer

Answer: B. Fast data retrieval

71. Which algorithm finds the shortest path from a single source to all other vertices in a weighted graph?

  1. Option A: Prim's algorithm
  2. Option B: Kruskal's algorithm
  3. Option C: Dijkstra's algorithm
  4. Option D: Warshall's algorithm
Show answer

Answer: C. Dijkstra's algorithm

72. Topological sorting can be applied to:

  1. Option A: Any graph
  2. Option B: Undirected graph
  3. Option C: Directed acyclic graph
  4. Option D: Complete graph
Show answer

Answer: C. Directed acyclic graph

73. Which traversal of a graph uses a queue?

  1. Option A: Depth-First Search
  2. Option B: Breadth-First Search
  3. Option C: Both A and B
  4. Option D: Neither A nor B
Show answer

Answer: B. Breadth-First Search

74. A minimum spanning tree of a graph is:

  1. Option A: A tree that connects all vertices with minimum total edge weight
  2. Option B: A tree with the minimum number of edges
  3. Option C: A tree with the minimum number of vertices
  4. Option D: A tree with the minimum height
Show answer

Answer: A. A tree that connects all vertices with minimum total edge weight

75. The time complexity of searching in a binary search tree in the worst case is:

  1. Option A: O(1)
  2. Option B: O(log n)
  3. Option C: O(n)
  4. Option D: O(n²)
Show answer

Answer: C. O(n)

76. Which of the following is NOT a collision resolution technique in hashing?

  1. Option A: Open addressing
  2. Option B: Chaining
  3. Option C: Double hashing
  4. Option D: Sorting
Show answer

Answer: D. Sorting

77. The time complexity of Prim's algorithm for finding a minimum spanning tree using an adjacency matrix is:

  1. Option A: O(V²)
  2. Option B: O(E log V)
  3. Option C: O(V + E)
  4. Option D: O(V log E)
Show answer

Answer: A. O(V²)

78. The worst-case time complexity of Quicksort is:

  1. Option A: O(n)
  2. Option B: O(n log n)
  3. Option C: O(n²)
  4. Option D: O(n³)
Show answer

Answer: C. O(n²)

79. Which sorting algorithm is based on the divide-and-conquer strategy?

  1. Option A: Insertion Sort
  2. Option B: Selection Sort
  3. Option C: Bubble Sort
  4. Option D: Merge Sort
Show answer

Answer: D. Merge Sort

7.3 Data models, normalization and SQL

29 questions · ACtE0703

80. What SQL command removes content without changing structure?

  1. Option A: DROP
  2. Option B: TRUNCATE
  3. Option C: DELETE
  4. Option D: REMOVE
Show hint

Removes rows, keeps table structure.

Show answer

Answer: C. DELETE

DELETE removes rows while preserving table structure. DROP removes entire table. TRUNCATE removes all rows but faster than DELETE.

81. In a relational database, what does a functional dependency X → Y signify?

  1. Option A: Y uniquely determines X
  2. Option B: Whenever two tuples agree on attributes X, they must also agree on attributes Y
  3. Option C: X and Y are independent attributes
  4. Option D: X and Y must both be primary keys
Show hint

Think of X as determining Y in any valid relation instance.

Show answer

Answer: B. Whenever two tuples agree on attributes X, they must also agree on attributes Y

A functional dependency X → Y in a relation R means that for any two tuples t1 and t2 in any valid instance of R, if t1.X = t2.X then t1.Y must equal t2.Y. In other words, the attributes in X functionally determine the attributes in Y. This concept is central to normalization: higher normal forms restrict the presence of certain types of functional dependencies to reduce redundancy and anomalies. A key of a relation is a set of attributes K such that K → all attributes in R, and no proper subset of K has that property. Understanding functional dependencies is necessary to reason about schema design, normalization, and lossless-join and dependency-preserving decompositions.

82. A relation schema R(A, B, C, D) has functional dependencies A → B and B → C. Which of the following is true?

  1. Option A: A functionally determines C via transitivity
  2. Option B: C functionally determines A
  3. Option C: A and C are independent
  4. Option D: D is functionally determined by A
Show hint

Use Armstrong’s axiom of transitivity: if X → Y and Y → Z, then X → Z.

Show answer

Answer: A. A functionally determines C via transitivity

Given A → B and B → C, Armstrong’s transitivity axiom implies A → C: since knowing A determines B and knowing B determines C, knowing A is sufficient to determine C. There is no given functional dependency involving D, so nothing can be concluded about D from these dependencies alone. Reasoning about closures of attribute sets under given FDs (using reflexivity, augmentation, transitivity, etc.) is a standard technique for testing keys, checking normal forms, and designing decompositions.

83. Which normal form specifically eliminates transitive functional dependencies of non-key attributes on a candidate key?

  1. Option A: First Normal Form (1NF)
  2. Option B: Second Normal Form (2NF)
  3. Option C: Third Normal Form (3NF)
  4. Option D: Boyce–Codd Normal Form (BCNF)
Show hint

It addresses dependencies like key → X → Y with Y non-key.

Show answer

Answer: C. Third Normal Form (3NF)

Third Normal Form (3NF) requires that, for every non-trivial functional dependency X → A in a relation, either X is a superkey or A is a prime attribute (part of some candidate key). This condition eliminates transitive dependencies where a non-key attribute depends on a key via another non-key attribute. For example, if in a table we have key K, and K → X, X → Y, and Y is non-key, then K → Y is a transitive dependency that 3NF aims to remove by decomposition. 2NF only eliminates partial dependencies (where a non-key attribute depends on part of a composite key), while BCNF is stricter than 3NF and demands that for every non-trivial FD X → A, X be a superkey, with no exception for prime attributes.

84. In the Entity–Relationship (E-R) model, what distinguishes a weak entity set from a strong entity set?

  1. Option A: A weak entity set can have attributes; a strong entity set cannot
  2. Option B: A weak entity set does not have a primary key and is identified by being related to another entity set
  3. Option C: A weak entity set cannot participate in relationships
  4. Option D: There is no difference; the terms are synonyms
Show hint

Think of entities that depend on another entity for identity, like 'Dependents' of an 'Employee'.

Show answer

Answer: B. A weak entity set does not have a primary key and is identified by being related to another entity set

A strong entity set has a primary key that uniquely identifies each of its entities independently. A weak entity set, however, does not have a sufficient primary key of its own. It is identified by a combination of its partial key (a discriminator) and the primary key of an owning or identifying strong entity set, through an identifying relationship. For example, in an HR database, an 'Employee' is a strong entity (identified by EmployeeID), while 'Dependent' (child or spouse of employee) may be modeled as a weak entity identified by (EmployeeID, DependentName). This modeling is reflected later in relational design by foreign keys and composite primary keys.

85. Which SQL command category does the CREATE TABLE statement belong to?

  1. Option A: Data Definition Language (DDL)
  2. Option B: Data Manipulation Language (DML)
  3. Option C: Data Control Language (DCL)
  4. Option D: Transaction Control Language (TCL)
Show hint

Think about commands that define schema objects.

Show answer

Answer: A. Data Definition Language (DDL)

CREATE TABLE is a Data Definition Language (DDL) command that defines a new relation (table) in the database schema, specifying its attributes, data types, constraints, and keys. Other DDL commands include ALTER TABLE (to change an existing schema) and DROP TABLE (to remove a relation). Data Manipulation Language (DML) commands such as SELECT, INSERT, UPDATE, and DELETE operate on the data within existing schema objects. DCL (like GRANT, REVOKE) controls privileges, and TCL (like COMMIT, ROLLBACK) manages transaction boundaries.

86. In relational algebra, which operation corresponds most closely to the SQL SELECT-FROM-WHERE combination (ignoring projection of specific columns)?

  1. Option A: Selection followed by Cartesian product
  2. Option B: Join followed by union
  3. Option C: Selection (σ) over a Cartesian product (×) of relations
  4. Option D: Projection (π) only
Show hint

Conceptually, SQL joins are selection over product, plus projection.

Show answer

Answer: C. Selection (σ) over a Cartesian product (×) of relations

In basic relational algebra, the FROM clause that lists multiple tables corresponds to the Cartesian product of those relations. The WHERE clause then restricts the rows via selection (σ) with a predicate. Finally, the SELECT clause projects specific attributes (π). Thus, a simple SQL query like SELECT A.x, B.y FROM A, B WHERE A.id = B.id AND A.z > 10 is represented as π_{x,y}(σ_{A.id = B.id ∧ A.z > 10}(A × B)). Modern relational algebra adds explicit join operators, but joins are logically definable as selection over Cartesian product. Understanding this mapping is crucial for reasoning about query optimization and expressing queries formally.

87. Which of the following best describes the purpose of query optimization in a relational DBMS?

  1. Option A: To change the meaning of the query
  2. Option B: To find an equivalent logical formulation that uses fewer relations
  3. Option C: To choose an efficient physical execution plan for a given logical query expression
  4. Option D: To automatically normalize the schema
Show hint

The logical query is fixed; we are selecting the best way to execute it.

Show answer

Answer: C. To choose an efficient physical execution plan for a given logical query expression

Query optimization takes a logical query (usually an algebraic expression derived from SQL) and explores alternative physical execution plans (different join orders, join algorithms, index usage, and access paths) to minimize estimated cost (I/O, CPU, memory). The optimizer uses statistics about table sizes, value distributions, and index selectivity to estimate costs of various plans. It then picks a near-optimal plan. The logical meaning of the query does not change; only the method of evaluation does. Effective query optimization is crucial to performance in large-scale database systems where naive plans could be orders of magnitude slower.

88. Which attribute AGE?

  1. Option A: Single-valued
  2. Option B: Derived
  3. Option C: Composite
  4. Option D: Multi-valued
Show hint

One value per entity.

Show answer

Answer: A. Single-valued

AGE is single-valued attribute: one value per person.

89. Redundancy is reduced in a database table by using the ------------- form.

NEC model set
  1. Option A: Abnormal
  2. Option B: Normal
  3. Option C: Special
  4. Option D: Exactly
Show hint

Database normalization removes redundancy and improves data integrity through normal forms.

Show answer

Answer: B. Normal

Redundancy is reduced in database tables by using Normal form. Normalization is the process of organizing database design to reduce redundancy: (1) 1NF (First Normal Form) - Eliminate repeating groups, atomic values only, (2) 2NF (Second Normal Form) - Remove partial dependencies on composite keys, (3) 3NF (Third Normal Form) - Remove transitive dependencies, (4) BCNF (Boyce-Codd Normal Form) - Stricter than 3NF. Benefits of normalization: (1) Reduces data redundancy - Less storage space, (2) Improves data integrity - Eliminates anomalies, (3) Easier updates - No need to update multiple locations, (4) Prevents insert/update/delete anomalies. Normalization process: (1) Start with unnormalized data, (2) Apply rules progressively (1NF → 2NF → 3NF), (3) Each step removes certain types of dependencies. Example of denormalized vs normalized: Denormalized: (Student, Course, Grade, Professor), Normalized: Separate tables for Student, Course, Enrollment with foreign keys. Anomalies in denormalized data: (1) Insert anomaly - Cannot insert new course without student, (2) Update anomaly - Change one grade, must change in multiple places, (3) Delete anomaly - Deleting student removes course information. Trade-offs: (1) Normalization improves integrity but increases complexity, (2) Over-normalization (beyond 3NF) may hurt performance, (3) Denormalization may be necessary for specific queries. Most databases use 3NF as standard balance between normalization and performance.

90. Which normal form in database normalization requires that every determinant must be a candidate key?

Recalled from Jan 2026 exam
  1. Option A: First Normal Form (1NF)
  2. Option B: Second Normal Form (2NF)
  3. Option C: Boyce-Codd Normal Form (BCNF)
  4. Option D: Third Normal Form (3NF)
Show hint

This strict normal form requires every determinant to be a candidate key. What is it?

Show answer

Answer: C. Boyce-Codd Normal Form (BCNF)

Boyce-Codd Normal Form (BCNF) requires that every determinant must be a candidate key. BCNF is a stricter version of 3NF. In BCNF, every non-trivial functional dependency X→Y must have X as a candidate key or superkey. This eliminates anomalies that can still exist in 3NF. BCNF is considered the ideal form for most databases but can sometimes lead to lossless decomposition issues. Most practical databases aim for 3NF as BCNF can be overly restrictive.

91. What is a characteristic of Boyce-Codd Normal Form (BCNF)?

Recalled from Jan 2026 exam
  1. Option A: Eliminates all non-key dependencies
  2. Option B: Eliminates only partial dependencies
  3. Option C: Eliminates transitive dependencies
  4. Option D: Eliminates all non-trivial functional dependencies where the determinant is not a candidate key
Show hint

BCNF is the strictest normal form. What dependencies does it eliminate?

Show answer

Answer: D. Eliminates all non-trivial functional dependencies where the determinant is not a candidate key

A characteristic of BCNF is that it eliminates all non-trivial functional dependencies where the determinant is not a candidate key. In other words, in BCNF, every determinant must be a candidate key. This is the defining characteristic and the strictest constraint of BCNF. First Normal Form eliminates repeating groups. Second Normal Form eliminates partial dependencies. Third Normal Form eliminates transitive dependencies. BCNF goes beyond 3NF by requiring that every determinant be a candidate key, not just non-key attributes determining other attributes.

92. Data abstraction in database systems refers to:

  1. Option A: Physical data organization
  2. Option B: Hiding implementation details
  3. Option C: Data compression
  4. Option D: Data encryption
Show answer

Answer: B. Hiding implementation details

93. In an E-R diagram, an entity is represented by:

  1. Option A: Rectangle
  2. Option B: Ellipse
  3. Option C: Diamond
  4. Option D: Triangle
Show answer

Answer: A. Rectangle

94. The primary key of a relation is:

  1. Option A: Any attribute
  2. Option B: An attribute that uniquely identifies each tuple
  3. Option C: The first attribute
  4. Option D: An attribute with the most values
Show answer

Answer: B. An attribute that uniquely identifies each tuple

95. A weak entity in an E-R model is one that:

  1. Option A: Has few attributes
  2. Option B: Depends on another entity for identification
  3. Option C: Has no primary key
  4. Option D: Is not important to the database
Show answer

Answer: B. Depends on another entity for identification

96. A relation is in First Normal Form (1NF) if:

  1. Option A: It has no repeating groups
  2. Option B: It has no partial dependencies
  3. Option C: It has no transitive dependencies
  4. Option D: It has no multi-valued dependencies
Show answer

Answer: A. It has no repeating groups

97. A relation is in Second Normal Form (2NF) if:

  1. Option A: It is in 1NF and has no repeating groups
  2. Option B: It is in 1NF and has no partial dependencies
  3. Option C: It is in 1NF and has no transitive dependencies
  4. Option D: It is in 1NF and has no multi-valued dependencies
Show answer

Answer: B. It is in 1NF and has no partial dependencies

98. SQL stands for:

  1. Option A: Structured Query Language
  2. Option B: Simple Query Language
  3. Option C: Standard Query Language
  4. Option D: System Query Language
Show answer

Answer: A. Structured Query Language

99. A relation is in Third Normal Form (3NF) if:

  1. Option A: It is in 2NF and has no repeating groups
  2. Option B: It is in 2NF and has no partial dependencies
  3. Option C: It is in 2NF and has no transitive dependencies
  4. Option D: It is in 2NF and has no multi-valued dependencies
Show answer

Answer: C. It is in 2NF and has no transitive dependencies

100. Which SQL command is used to modify existing data in a table?

  1. Option A: MODIFY
  2. Option B: ALTER
  3. Option C: CHANGE
  4. Option D: UPDATE
Show answer

Answer: D. UPDATE

101. A view in SQL is:

  1. Option A: A physical table
  2. Option B: A virtual table based on a query
  3. Option C: A graphical representation of data
  4. Option D: A database schema
Show answer

Answer: B. A virtual table based on a query

102. Which SQL command is used to create a new table?

  1. Option A: CREATE TABLE
  2. Option B: NEW TABLE
  3. Option C: ADD TABLE
  4. Option D: INSERT TABLE
Show answer

Answer: A. CREATE TABLE

103. Which SQL command is used to add new data to a table?

  1. Option A: ADD
  2. Option B: CREATE
  3. Option C: INSERT
  4. Option D: UPDATE
Show answer

Answer: C. INSERT

104. Relational algebra is:

  1. Option A: A procedural query language
  2. Option B: A non-procedural query language
  3. Option C: A data definition language
  4. Option D: A data manipulation language
Show answer

Answer: A. A procedural query language

105. Query optimization in databases aims to:

  1. Option A: Reduce the size of the database
  2. Option B: Improve query execution efficiency
  3. Option C: Simplify query syntax
  4. Option D: Increase database security
Show answer

Answer: B. Improve query execution efficiency

106. Which normal form deals with multi-valued dependencies?

  1. Option A: 3NF
  2. Option B: BCNF
  3. Option C: 4NF
  4. Option D: 5NF
Show answer

Answer: C. 4NF

107. Which SQL clause is used to filter rows?

  1. Option A: SELECT
  2. Option B: FROM
  3. Option C: WHERE
  4. Option D: GROUP BY
Show answer

Answer: C. WHERE

108. A trigger in SQL is:

  1. Option A: A type of query
  2. Option B: A stored procedure that automatically executes when an event occurs
  3. Option C: A constraint on a table
  4. Option D: A type of join
Show answer

Answer: B. A stored procedure that automatically executes when an event occurs

7.4 Transaction processing, concurrency control and crash recovery

13 questions · ACtE0704

109. Which of the following best describes ACID properties in transaction processing?

  1. Option A: Atomicity, Consistency, Isolation, Durability
  2. Option B: Association, Concurrency, Integrity, Durability
  3. Option C: Atomicity, Concurrency, Independence, Distribution
  4. Option D: Accuracy, Consistency, Isolation, Distribution
Show hint

Each letter corresponds to a fundamental guarantee of a transaction.

Show answer

Answer: A. Atomicity, Consistency, Isolation, Durability

ACID stands for Atomicity, Consistency, Isolation, and Durability. Atomicity means that a transaction's operations are all-or-nothing: either all are performed or none are. Consistency means that a transaction, when executed alone, takes the database from one valid state to another, preserving all defined integrity constraints. Isolation means that concurrent executions of transactions do not interfere in a way visible to each transaction; each transaction behaves as if it were executing alone. Durability means that once a transaction commits, its effects survive system crashes, typically ensured by writing to stable storage (logs, checkpoints). Together, these properties form the cornerstone of reliable transaction processing in database systems.

110. What is the main goal of a lock-based concurrency control protocol in a DBMS?

  1. Option A: To ensure that all transactions run as slowly as possible
  2. Option B: To prevent any two transactions from ever running at the same time
  3. Option C: To coordinate concurrent access to data items so that the resulting schedule is serializable
  4. Option D: To avoid logging overhead by eliminating undo/redo operations
Show hint

Think of locks as a way to serialize conflicting operations while allowing non-conflicting ones to overlap.

Show answer

Answer: C. To coordinate concurrent access to data items so that the resulting schedule is serializable

Lock-based protocols (such as two-phase locking) use locks (shared and exclusive) to regulate which transactions can access which data items at what times. The idea is that operations that could conflict (for example, two writes to the same item, or a read and a write) are prevented from executing simultaneously by requiring one transaction to wait until another releases its lock. A well-designed locking protocol, especially strict two-phase locking, guarantees conflict-serializable schedules, meaning the effect of interleaved execution is equivalent to some serial order of the transactions. This preserves the Isolation property of ACID without sacrificing all concurrency.

111. Which of the following is a typical cause of deadlock in a lock-based concurrency control system?

  1. Option A: A transaction releasing all locks before acquiring new ones
  2. Option B: Two transactions each holding a lock on one item and waiting for a lock on the other's item
  3. Option C: Using read-only transactions
  4. Option D: Having only one transaction in the system
Show hint

Think of a circular wait scenario where each waits for the other.

Show answer

Answer: B. Two transactions each holding a lock on one item and waiting for a lock on the other's item

Deadlock occurs when there is a circular wait among two or more transactions: each transaction holds a lock on some data item that the others need and simultaneously waits to acquire locks that will never be released because the waiting transactions cannot proceed. For example, T1 locks A and then requests B, while T2 locks B and then requests A. Neither can proceed, and both are blocked indefinitely. Deadlock handling strategies include prevention (ensuring one of the Coffman conditions never holds), avoidance (like wait-die and wound-wait schemes), detection (periodically building a wait-for graph and looking for cycles), and recovery (aborting one or more transactions to break the cycle).

112. What is the primary purpose of log-based recovery in a DBMS?

  1. Option A: To compress database files
  2. Option B: To record changes so that the system can undo or redo them after a crash
  3. Option C: To speed up query processing
  4. Option D: To avoid the need for concurrency control
Show hint

Think of the log as a chronological history of all updates.

Show answer

Answer: B. To record changes so that the system can undo or redo them after a crash

A write-ahead log (WAL) records all modifications to the database before they are applied to the data pages on disk. Each log record typically specifies the transaction ID, the affected data item, and the old and new values. In case of a crash, the DBMS recovers by reading the log: undo records for transactions that had not committed (to roll back their partial effects) and redo records for committed transactions whose changes might not have reached stable storage. This ensures Atomicity (incomplete transactions are undone) and Durability (completed transactions are redone if necessary) even in the presence of system failures. Logging is central to modern recovery algorithms such as ARIES.

113. Which DBMS concept ensures that a transaction's intermediate results are not visible to other concurrent transactions, thereby preventing phenomena like dirty reads?

  1. Option A: Atomicity
  2. Option B: Consistency
  3. Option C: Isolation
  4. Option D: Durability
Show hint

It controls the visibility of partial updates among concurrent transactions.

Show answer

Answer: C. Isolation

Isolation is the ACID property dealing with concurrency anomalies. It ensures that concurrently executing transactions do not interfere with each other in a way that would reveal partial or intermediate states. Ideally, each transaction behaves as if it were executing alone on the system, yielding a schedule that is equivalent to some serial ordering of transactions (serializability). In practice, different isolation levels (such as Read Uncommitted, Read Committed, Repeatable Read, Serializable) provide different trade-offs between strict isolation and performance. Dirty reads, non-repeatable reads, and phantom reads are examples of phenomena controlled by appropriate isolation levels and concurrency control mechanisms like locking and timestamp ordering.

114. Atomicity property ensures?

  1. Option A: All or nothing
  2. Option B: Data consistency
  3. Option C: System reliability
  4. Option D: Transaction isolation
Show hint

Transaction commitment.

Show answer

Answer: A. All or nothing

Atomicity ensures transaction either completes fully or not at all.

115. Not transaction property?

  1. Option A: Atomicity
  2. Option B: Durability
  3. Option C: Isolation
  4. Option D: Concurrency
Show hint

Four ACID properties.

Show answer

Answer: D. Concurrency

Concurrency is not transaction property; ACID properties are Atomicity, Consistency, Isolation, Durability.

116. It is advisable, to store the ---------before applying the actual transaction to the database.

NEC model set
  1. Option A: Data
  2. Option B: Logs
  3. Option C: Receive
  4. Option D: Record
Show hint

Recovery mechanisms require recording transaction information. What should be stored for backup/recovery?

Show answer

Answer: B. Logs

It is advisable to store Logs before applying the actual transaction to the database. Transaction logging (write-ahead logging): (1) Before any transaction is applied to database, (2) Write information about transaction to permanent log/storage, (3) Then apply transaction to database. Why logs are essential: (1) Recovery - If system crashes, use logs to recover state, (2) Atomicity - Ensure all-or-nothing transaction property, (3) Durability - Transactions persisted permanently. ACID properties related to logging: (1) Atomicity - All-or-nothing via commit/rollback (uses logs), (2) Consistency - Data relationships maintained (logs track changes), (3) Isolation - Concurrent transaction separation (logs track order), (4) Durability - Permanent once committed (logs backed up). Log contents: (1) Transaction ID - Identifies specific transaction, (2) Operation type - INSERT, UPDATE, DELETE, (3) Before-image - Original values, (4) After-image - New values, (5) Timestamp - When operation occurred. Logging strategies: (1) Write-ahead logging (WAL) - Log written before change to database, (2) Undo logging - Can rollback (undo) transactions, (3) Redo logging - Can recover (redo) transactions, (4) Undo-redo logging - Supports both. Recovery process: (1) Redo transactions in log if not completed, (2) Undo transactions if not committed, (3) Database restored to consistent state. Practical implementation: (1) Transaction log on separate disk - Survives disk failures, (2) Log shadowing - Duplicate copies, (3) Log archiving - Historical records for audit. This is critical for database reliability and is standard in all enterprise databases.

117. Serializability in transaction processing ensures:

  1. Option A: Transactions are executed in a specific order
  2. Option B: Concurrent transactions produce the same result as if executed serially
  3. Option C: Transactions are converted to a serial format
  4. Option D: Transactions are executed as quickly as possible
Show answer

Answer: B. Concurrent transactions produce the same result as if executed serially

118. ACID properties in transaction processing stand for:

  1. Option A: Atomicity, Consistency, Isolation, Durability
  2. Option B: Availability, Consistency, Integrity, Durability
  3. Option C: Atomicity, Correctness, Integrity, Durability
  4. Option D: Availability, Consistency, Isolation, Distribution
Show answer

Answer: A. Atomicity, Consistency, Isolation, Durability

119. A deadlock in database systems occurs when:

  1. Option A: The database is full
  2. Option B: Two or more transactions are waiting for each other to release locks
  3. Option C: A transaction is aborted
  4. Option D: The database server crashes
Show answer

Answer: B. Two or more transactions are waiting for each other to release locks

120. Log-based recovery in database systems is used to:

  1. Option A: Prevent deadlocks
  2. Option B: Optimize queries
  3. Option C: Recover from system failures
  4. Option D: Encrypt data
Show answer

Answer: C. Recover from system failures

121. The two-phase locking protocol is used for:

  1. Option A: Deadlock prevention
  2. Option B: Ensuring serializability
  3. Option C: Query optimization
  4. Option D: Data recovery
Show answer

Answer: B. Ensuring serializability

7.5 Operating systems and process management

37 questions · ACtE0705

122. What is Purpose of Wait-for graph?

Aasadh 2081 exam
  1. Option A: Process scheduling
  2. Option B: Memory allocation
  3. Option C: Deadlock detection
  4. Option D: File management
Show hint

Detects cycles indicating circular wait.

Show answer

Answer: C. Deadlock detection

Wait-for graph is used for deadlock detection by identifying cycles in resource waiting relationships.

123. In an operating system, a process is:

  1. Option A: A program in execution
  2. Option B: A program stored on disk
  3. Option C: A single instruction
  4. Option D: A hardware component
Show answer

Answer: A. A program in execution

124. A semaphore is used for:

  1. Option A: Memory management
  2. Option B: Process synchronization
  3. Option C: File management
  4. Option D: I/O management
Show answer

Answer: B. Process synchronization

125. The difference between a process and a thread is:

  1. Option A: Processes are faster than threads
  2. Option B: Threads share memory space while processes have separate memory spaces
  3. Option C: Processes can be multitasked but threads cannot
  4. Option D: Threads require more resources than processes
Show answer

Answer: B. Threads share memory space while processes have separate memory spaces

126. Which synchronization mechanism can lead to busy waiting?

  1. Option A: Semaphores
  2. Option B: Message passing
  3. Option C: Spinlocks
  4. Option D: Monitors
Show answer

Answer: C. Spinlocks

127. The primary difference between mutex and semaphore is:

  1. Option A: Mutex can only be used for process synchronization
  2. Option B: Semaphore can only be used for thread synchronization
  3. Option C: Mutex is owned by a thread and only that thread can release it
  4. Option D: Semaphore is faster than mutex
Show answer

Answer: C. Mutex is owned by a thread and only that thread can release it

128. Which type of software is responsible for managing and controlling the hardware resources of a computer system?

  1. Option A: Application software
  2. Option B: System software
  3. Option C: Programming software
  4. Option D: Utility software
Show answer

Answer: B. System software

129. Which of the following best describes a process in an operating system?

  1. Option A: A program stored on disk
  2. Option B: An instance of a program in execution, including its code, data, and execution context
  3. Option C: A single CPU instruction
  4. Option D: A function call within a program
Show hint

Think of dynamic execution plus its OS-managed state, not just the static code.

Show answer

Answer: B. An instance of a program in execution, including its code, data, and execution context

A process is an active entity that represents a running program. It includes the program code (text segment), data segments (global, heap), stack, and the current execution context: register contents, program counter, and other OS-managed metadata such as open file descriptors and scheduling information. A program on disk is a passive entity (an executable file), while a process represents that program in motion. Multiple processes can be instances of the same program. The OS uses the Process Control Block (PCB) to store per-process state and to perform context switches among processes.

130. What is the main difference between a process and a thread within an operating system?

  1. Option A: A process has no address space; a thread does
  2. Option B: Threads within the same process share the same address space, while processes have separate address spaces
  3. Option C: A thread cannot be scheduled independently
  4. Option D: Only processes can perform I/O operations
Show hint

Focus on memory protection and sharing.

Show answer

Answer: B. Threads within the same process share the same address space, while processes have separate address spaces

A process has its own virtual address space, including code, data, heap, and stack segments, and is isolated from other processes at the memory level. Threads are lighter-weight execution units that run within a process. All threads of a process share the same address space and many OS resources (such as open files), but each thread has its own stack and registers (i.e., its own execution context). This sharing makes context switches between threads cheaper than between processes and allows efficient inter-thread communication via shared variables, at the cost of requiring explicit synchronization (locks, semaphores, etc.) to avoid race conditions.

131. In CPU scheduling, which algorithm may cause starvation of long-running processes if small time quanta are used?

  1. Option A: First-Come, First-Served (FCFS)
  2. Option B: Shortest Job Next (SJN) without preemption
  3. Option C: Round Robin (RR)
  4. Option D: Preemptive priority scheduling without aging
Show hint

Consider a low-priority process that is always preempted by higher-priority arrivals.

Show answer

Answer: D. Preemptive priority scheduling without aging

In preemptive priority scheduling, the CPU is always assigned to the ready process with the highest priority. If new high-priority processes arrive frequently, low-priority processes may never get CPU time, a situation called starvation. Without aging (a technique that gradually increases the priority of waiting processes), these low-priority processes might be postponed indefinitely. FCFS and non-preemptive SJN do not cause starvation by design (though SJN can be unfair in other ways), while Round Robin ensures all ready processes eventually get time slices, preventing starvation at the expense of potential overhead due to frequent context switching.

132. What is a race condition in the context of concurrent processes or threads?

  1. Option A: A situation where processes compete for CPU time but are scheduled fairly
  2. Option B: A condition where the output depends on the relative timing of concurrent operations on shared data
  3. Option C: A performance optimization technique for parallel programs
  4. Option D: A method of allocating memory dynamically
Show hint

If operations interleave differently, the final result can change unpredictably.

Show answer

Answer: B. A condition where the output depends on the relative timing of concurrent operations on shared data

A race condition occurs when two or more concurrent threads or processes access shared data, and at least one of them performs a write, without proper synchronization. The program's behavior then depends on the precise timing and interleaving of operations, which is usually unpredictable and non-deterministic. For example, if two threads increment a shared counter without atomic operations or locks, interleavings can cause increments to be lost. Proper synchronization mechanisms (critical sections, mutexes, semaphores, monitors) are needed to enforce mutual exclusion, ensuring that critical regions of code are not executed by more than one thread at the same time and thus avoiding race conditions.

133. Which of the following synchronization primitives provides a mutual exclusion mechanism with only two operations, often called wait (P) and signal (V)?

  1. Option A: Monitor
  2. Option B: Semaphore
  3. Option C: Message queue
  4. Option D: Condition variable
Show hint

It can be binary or counting and was introduced by Dijkstra.

Show answer

Answer: B. Semaphore

A semaphore is an abstract data type that maintains a non-negative integer value and supports two atomic operations: wait (P) and signal (V). A wait operation decrements the semaphore if it is positive or blocks the calling process if it is zero; a signal operation increments the semaphore and may wake up a blocked process. A binary semaphore (value 0 or 1) can implement mutual exclusion by allowing only one process into a critical section at a time. Counting semaphores generalize this to allow up to N concurrent entries. Semaphores are powerful but can be error-prone if misused (for example, forgetting to signal), so higher-level constructs like monitors and mutex locks are often preferred in modern systems.

134. Which classic synchronization problem illustrates the need for careful use of semaphores or monitors to avoid both deadlock and starvation among competing processes?

  1. Option A: Producer–Consumer problem
  2. Option B: Readers–Writers problem
  3. Option C: Dining Philosophers problem
  4. Option D: Bounded Buffer problem
Show hint

Think about philosophers needing two shared resources (forks) to eat.

Show answer

Answer: C. Dining Philosophers problem

The Dining Philosophers problem, introduced by Dijkstra, involves a number of philosophers sitting around a table with one fork between each pair. To eat, a philosopher needs to hold both forks adjacent to them. If each philosopher picks up one fork and waits for the other, a deadlock can occur. Solutions must balance mutual exclusion (only one philosopher may use a fork at a time) with avoidance of deadlock and starvation (some philosophers never getting to eat). The problem is often used to illustrate subtleties in lock acquisition ordering, resource hierarchy, and fairness in scheduling. Producer–Consumer and Readers–Writers are also classical problems but with different characteristics and solutions.

135. Purpose of Wait-for graph?

  1. Option A: Scheduling
  2. Option B: Memory
  3. Option C: Deadlock detection
  4. Option D: File manage
Show hint

Detects cycles.

Show answer

Answer: C. Deadlock detection

Wait-for graph detects deadlock by identifying circular waits.

136. Multiple processes single-user term?

  1. Option A: Multiprocessing
  2. Option B: Multitasking
  3. Option C: Multithreading
  4. Option D: Time-sharing
Show hint

CPU time sharing.

Show answer

Answer: B. Multitasking

Multitasking allows multiple processes to share single CPU.

137. Process vs thread?

  1. Option A: Process independent
  2. Option B: Thread independent
  3. Option C: Process subset
  4. Option D: Thread has memory
Show hint

Hierarchy.

Show answer

Answer: A. Process independent

Process is independent; thread is subset of process sharing memory.

138. Synchronization in multiprocessor?

  1. Option A: Semaphores
  2. Option B: Shared memory
  3. Option C: Coherence
  4. Option D: Message passing
Show hint

Prevents race conditions.

Show answer

Answer: A. Semaphores

Semaphores and mutexes prevent race conditions in shared resources.

139. Preemptive scheduling algorithm?

  1. Option A: FCFS
  2. Option B: SJN
  3. Option C: Round Robin
  4. Option D: HRRN
Show hint

Time slice based.

Show answer

Answer: C. Round Robin

Round Robin is preemptive: each process gets time slice then preempted.

140. In fork() system call?

  1. Option A: Same memory
  2. Option B: Different processes
  3. Option C: Parent wait
  4. Option D: Child priority
Show hint

Creates new process.

Show answer

Answer: B. Different processes

fork() creates new child process separate from parent.

141. To enforce ............................... two functions are provided enter-critical and exit-critical, where each function takes as an argument the name of the resource that is the subject of competition.

NEC model set
  1. Option A: Mutual Exclusion
  2. Option B: Synchronization
  3. Option C: Deadlock
  4. Option D: Starvation
Show hint

Mutual exclusion prevents simultaneous access to shared resources. What do enter/exit critical sections enforce?

Show answer

Answer: A. Mutual Exclusion

To enforce Mutual Exclusion, two functions are provided: enter-critical and exit-critical. Mutual exclusion ensures only one process/thread accesses shared resource at a time. Critical section: (1) Code segment accessing shared resource, (2) Only one process can execute at a time, (3) Protected by locks/semaphores. Enter-critical function: (1) Called before accessing shared resource, (2) If resource free, allows entry and locks it, (3) If resource locked, process waits/blocks. Exit-critical function: (1) Called after using shared resource, (2) Unlocks the resource, (3) Allows waiting process to acquire resource. Example pseudocode: process1: enter-critical(resource); access shared resource; exit-critical(resource); Implementation mechanisms: (1) Semaphores - Counter-based synchronization, (2) Mutexes - Binary lock/unlock, (3) Monitors - Higher-level synchronization, (4) Spinlocks - Busy-wait locking. Problems without mutual exclusion: (1) Race condition - Unpredictable results from concurrent access, (2) Data corruption - Inconsistent state, (3) Lost updates - One process overwrites another's changes. Related concepts: (1) Synchronization - Coordinate multiple processes (broader term), (2) Deadlock - Mutual waiting (different problem), (3) Starvation - Process never gets resource (different problem). Practical importance: (1) Database transactions - Concurrent access control, (2) Operating systems - Process/thread management, (3) Embedded systems - Shared hardware resources, (4) Multithreading - Thread-safe code. Modern solutions: (1) Locks (explicit), (2) Atomic operations (implicit), (3) Message passing - Avoids shared resources.

142. If mutual exclusion is not enforced, what can occur?

NEC model set
  1. Option A: a) Starvation
  2. Option B: b) Semaphore overflow
  3. Option C: c) Deadlock
  4. Option D: d) Race condition
Show hint

Without mutual exclusion, multiple processes access the same resource. What problem happens?

Show answer

Answer: D. d) Race condition

If mutual exclusion is not enforced, a race condition can occur. Multiple processes access shared resources simultaneously, and the final result depends on the timing of access (the 'race'). This leads to inconsistent and unpredictable behavior. Mutual exclusion ensures only one process accesses a critical section at a time. Techniques like locks, semaphores, and monitors implement mutual exclusion to prevent race conditions.

143. Which of the following has its own memory, stack, and code?

Past question
  1. Option A: Process
  2. Option B: Thread
  3. Option C: Kernel
  4. Option D: Containers
Show hint

Processes are independent units of execution with complete isolated resources.

Show answer

Answer: A. Process

A Process has its own memory, stack, and code. Process Characteristics: (1) Independent execution unit, (2) Separate memory space, (3) Each has own stack, (4) Each has own code/text segment, (5) Protected from other processes. Process Memory Organization: (1) Text segment - Program code, (2) Data segment - Global variables, (3) Heap - Dynamic memory, (4) Stack - Function calls and local variables, (5) All isolated from other processes. How Processes Differ from Threads: (1) Thread - Shares memory with other threads in same process, (2) Thread - Has own stack but shared code/data, (3) Process - Completely isolated, (4) Process - Heavier resource usage. Process Structure: (1) Process ID (PID), (2) Program counter, (3) CPU registers, (4) Memory tables (page tables), (5) File descriptor table. Context Switch: (1) Saving current process state, (2) Loading new process state, (3) Expensive operation (thousands of cycles), (4) More overhead than thread switching. Protection: (1) Hardware memory management, (2) Memory protection prevents corruption, (3) One process crash doesn't affect others, (4) Isolation enforced by OS. Creation: (1) fork() in Linux creates new process, (2) CreateProcess() in Windows, (3) Inherits parent code/data by default. vs Threads: (1) Lightweight thread - Easy to create, (2) Heavy-weight process - More expensive to create, (3) Thread switching - Cheaper, (4) Process switching - More expensive. Containers vs Processes: (1) Containers use processes, (2) Containers share some OS resources, (3) Processes are fundamental unit. This is fundamental to operating system concepts.

144. Which component of an operating system kernel manages process execution and resource allocation?

Recalled from Jan 2026 exam
  1. Option A: File manager
  2. Option B: Memory manager
  3. Option C: Process scheduler
  4. Option D: Device driver
Show hint

This OS component decides which process runs when. What is it?

Show answer

Answer: C. Process scheduler

The process scheduler is the OS kernel component that manages process execution and resource allocation. It decides which process should run next, for how long (time slice/quantum), and allocates CPU time among competing processes. The scheduler implements scheduling algorithms like Round-Robin, Priority-Based, or SJF. Process scheduling is critical for system responsiveness and throughput. File manager handles file operations. Memory manager handles memory allocation. Device drivers handle hardware communication.

145. Which of the following is NOT a type of operating system?

  1. Option A: Batch Operating System
  2. Option B: Time-Sharing Operating System
  3. Option C: Distributed Operating System
  4. Option D: Sequential Operating System
Show answer

Answer: D. Sequential Operating System

146. The main function of an operating system is:

  1. Option A: To provide a user interface
  2. Option B: To manage computer resources
  3. Option C: To run application programs
  4. Option D: To provide internet connectivity
Show answer

Answer: B. To manage computer resources

147. A process in an operating system is:

  1. Option A: A program in execution
  2. Option B: A program stored on disk
  3. Option C: A processor
  4. Option D: A thread
Show answer

Answer: A. A program in execution

148. The process state when it is ready to run but waiting for the CPU is:

  1. Option A: Running
  2. Option B: Ready
  3. Option C: Blocked
  4. Option D: Terminated
Show answer

Answer: B. Ready

149. Which scheduling algorithm gives the CPU to the process with the shortest expected processing time?

  1. Option A: First-Come-First-Served
  2. Option B: Shortest Job First
  3. Option C: Round Robin
  4. Option D: Priority Scheduling
Show answer

Answer: B. Shortest Job First

150. A thread is:

  1. Option A: A heavy-weight process
  2. Option B: A light-weight process
  3. Option C: A program
  4. Option D: An operating system
Show answer

Answer: B. A light-weight process

151. A critical region in concurrent programming is:

  1. Option A: A region of memory that cannot be accessed
  2. Option B: A segment of code that accesses shared resources
  3. Option C: A region of the disk that contains critical data
  4. Option D: A part of the operating system that manages critical processes
Show answer

Answer: B. A segment of code that accesses shared resources

152. A race condition occurs when:

  1. Option A: Two processes compete for CPU time
  2. Option B: The outcome depends on the relative timing of events
  3. Option C: A process is running too fast
  4. Option D: A process is waiting for an event
Show answer

Answer: B. The outcome depends on the relative timing of events

153. Mutual exclusion ensures that:

  1. Option A: All processes can access shared resources simultaneously
  2. Option B: Only one process can access a shared resource at a time
  3. Option C: Processes are executed in a specific order
  4. Option D: Processes are excluded from execution
Show answer

Answer: B. Only one process can access a shared resource at a time

154. A semaphore is used for:

  1. Option A: Process creation
  2. Option B: Memory allocation
  3. Option C: Process synchronization
  4. Option D: File management
Show answer

Answer: C. Process synchronization

155. The difference between a mutex and a semaphore is:

  1. Option A: A mutex can only be used for mutual exclusion, while a semaphore can be used for both mutual exclusion and synchronization
  2. Option B: A semaphore can only be used for mutual exclusion, while a mutex can be used for both mutual exclusion and synchronization
  3. Option C: A mutex is faster than a semaphore
  4. Option D: A semaphore is used in Windows, while a mutex is used in Unix
Show answer

Answer: A. A mutex can only be used for mutual exclusion, while a semaphore can be used for both mutual exclusion and synchronization

156. The dining philosophers problem is an example of:

  1. Option A: Deadlock
  2. Option B: Race condition
  3. Option C: Starvation
  4. Option D: All of these
Show answer

Answer: D. All of these

157. Which of the following is NOT a process state?

  1. Option A: New
  2. Option B: Ready
  3. Option C: Running
  4. Option D: Idle
Show answer

Answer: D. Idle

158. Context switching refers to:

  1. Option A: Changing the context of a program
  2. Option B: Switching from user mode to kernel mode
  3. Option C: Saving the state of one process and loading the state of another
  4. Option D: Switching between different user interfaces
Show answer

Answer: C. Saving the state of one process and loading the state of another

7.6 Memory management, file systems and system administration

31 questions · ACtE0706

159. In the demand paging memory, what is the effective access time with 1000ms page fault service and 10ms memory access for fault rate 0.01?

Chaitra 2080 exam
  1. Option A: 12.9ms
  2. Option B: 20.9ms
  3. Option C: 19.9ms
  4. Option D: 0.01ms
Show hint

Use: EAT = Ma + Pf × (Tf - Ma), where Ma=memory access, Pf=fault rate, Tf=fault time

Show answer

Answer: C. 19.9ms

EAT = 10 + 0.01 × (1000 - 10) = 10 + 9.9 = 19.9ms. This accounts for impact of page faults on average memory access time.

160. What is Direct Access in file systems?

Aasadh 2081 exam
  1. Option A: disk
  2. Option B: RAM
  3. Option C: cache
  4. Option D: register
Show hint

Which storage device allows random access to any location?

Show answer

Answer: A. disk

Direct access is seen in disk storage where any location can be accessed directly without sequential traversal.

161. What manages virtual memory in computer?

  1. Option A: Control unit
  2. Option B: Arithmetic logic unit
  3. Option C: Operating system
  4. Option D: Cache memory
Show hint

Software manages virtual memory.

Show answer

Answer: C. Operating system

Operating system manages virtual memory by maintaining page tables and handling page faults.

162. What is page translation device in CPU?

  1. Option A: Page table
  2. Option B: Memory controller
  3. Option C: Hard drive
  4. Option D: RAM
Show hint

Maps virtual to physical addresses.

Show answer

Answer: A. Page table

Page table in memory translates virtual addresses to physical addresses for virtual memory management.

163. What is BIOS primarily used for?

  1. Option A: CPU operations
  2. Option B: RAM access
  3. Option C: Bootloader functions
  4. Option D: Graphics processing
Show hint

System initialization.

Show answer

Answer: C. Bootloader functions

BIOS performs system initialization and bootstrap operations during computer startup.

164. The primary purpose of a Translation Lookaside Buffer (TLB) is:

  1. Option A: To translate assembly code to machine code
  2. Option B: To speed up virtual-to-physical address translation
  3. Option C: To buffer data between CPU and memory
  4. Option D: To translate between different instruction sets
Show answer

Answer: B. To speed up virtual-to-physical address translation

165. The primary function of the Memory Management Unit (MMU) is:

  1. Option A: To increase memory capacity
  2. Option B: To translate virtual addresses to physical addresses
  3. Option C: To improve memory access speed
  4. Option D: To compress data in memory
Show answer

Answer: B. To translate virtual addresses to physical addresses

166. What is the purpose of the Memory Management Unit (MMU) in a computer system?

  1. Option A: To manage data flow between input/output devices
  2. Option B: To store instructions that the CPU can execute
  3. Option C: To regulate the flow of data between the CPU and memory
  4. Option D: To map virtual memory addresses to physical memory addresses
Show answer

Answer: D. To map virtual memory addresses to physical memory addresses

167. Which of the following is not a function of the memory management unit (MMU)?

  1. Option A: Caching of frequently used data
  2. Option B: Translation of virtual addresses to physical addresses
  3. Option C: Access control to memory locations
  4. Option D: Paging of memory to disk when needed
Show answer

Answer: A. Caching of frequently used data

168. Which of the following is not a characteristic of virtual memory?

  1. Option A: Allows programs to exceed physical memory capacity
  2. Option B: Uses a page table to map virtual addresses to physical addresses
  3. Option C: Stores data in registers
  4. Option D: Provides memory protection between programs
Show answer

Answer: C. Stores data in registers

169. In virtual memory systems, what is demand paging?

  1. Option A: Loading all pages of a process into memory before execution starts
  2. Option B: Loading pages into memory only when they are actually referenced
  3. Option C: Keeping all processes permanently in memory
  4. Option D: Swapping out all pages whenever memory is full
Show hint

It avoids bringing in unused pages at process start.

Show answer

Answer: B. Loading pages into memory only when they are actually referenced

Demand paging is a lazy loading strategy for virtual memory in which only those pages that a process actually accesses are brought into physical memory. Initially, many of a process's pages are marked as not present. When the CPU attempts to access such a page, a page fault occurs. The operating system then locates the page on disk (in the swap area or program file), brings it into a free frame, updates the page table, and resumes execution. This strategy can significantly reduce memory usage and startup time, especially for large programs that do not use all their pages. However, if the working set of pages does not fit in memory or if the replacement algorithm is poor, the system can thrash, spending most of its time handling page faults.

170. Which page replacement algorithm replaces the page that has not been used for the longest period of time?

  1. Option A: First-In, First-Out (FIFO)
  2. Option B: Least Recently Used (LRU)
  3. Option C: Optimal (Belady's)
  4. Option D: Clock (Second Chance)
Show hint

It approximates the optimal algorithm based on recency of use.

Show answer

Answer: B. Least Recently Used (LRU)

The Least Recently Used (LRU) page replacement algorithm selects for eviction the page that has not been referenced for the longest time in the past, based on the heuristic that pages used recently are likely to be used again soon (temporal locality). LRU is not the optimal algorithm (which would require knowledge of the future), but it is a good practical approximation. Implementing exact LRU can be expensive, requiring tracking usage order precisely, so real systems often use approximations such as the Clock algorithm or NFU (Not Frequently Used). FIFO replaces the oldest loaded page, which can perform poorly (Belady's anomaly). Optimal (Belady's algorithm) is theoretical, replacing the page that will not be used for the longest time in the future.

171. What is internal fragmentation in the context of memory allocation?

  1. Option A: Unallocated memory between allocated blocks
  2. Option B: Wasted space inside an allocated block due to fixed-size allocation units
  3. Option C: Memory left unused at the end of physical memory
  4. Option D: Loss of memory due to page replacement
Show hint

The process receives more memory than it requested, and the remainder cannot be used by others.

Show answer

Answer: B. Wasted space inside an allocated block due to fixed-size allocation units

Internal fragmentation occurs when memory is allocated in fixed-size units (such as fixed-size partitions or pages), and a process does not use the entire allocated unit. For example, if the system allocates memory in 4 KB pages and a process segment needs 6 KB, it will use two pages (8 KB), leaving 2 KB unused but reserved within the second page. This unused space cannot be allocated to other processes and is thus wasted internally. External fragmentation, by contrast, refers to small free holes scattered between allocated blocks that are collectively large enough to satisfy a request but not contiguous. Paging eliminates external fragmentation but not internal fragmentation; segmentation has the opposite trade-offs.

172. In a typical file system, what is the role of a directory?

  1. Option A: To store the actual file contents
  2. Option B: To map file names to file metadata (such as inode or file control block) and sometimes to their locations
  3. Option C: To manage disk scheduling
  4. Option D: To perform data compression
Show hint

Think of it as a table of contents mapping names to file descriptors.

Show answer

Answer: B. To map file names to file metadata (such as inode or file control block) and sometimes to their locations

A directory is a special type of file that stores entries associating file names with their metadata and sometimes disk location information. In Unix-like file systems, a directory maps file names to inode numbers, and the inode then contains information about file type, permissions, owner, size, timestamps, and disk block addresses. This separation allows multiple directory entries (hard links) to reference the same inode. In other systems, the directory may store a full file control block (FCB) with all metadata and pointers. Directories allow hierarchical naming: users perceive a tree of directories and files, while the file system translates these paths into specific metadata structures and disk blocks.

173. Which file allocation strategy stores each file as a linked list of disk blocks, with each block containing a pointer to the next block?

  1. Option A: Contiguous allocation
  2. Option B: Linked allocation
  3. Option C: Indexed allocation
  4. Option D: Hashed allocation
Show hint

Think of following pointers from block to block.

Show answer

Answer: B. Linked allocation

In linked allocation, each file is a linked list of disk blocks. Each block contains a pointer to the next block in the file. The directory entry stores the starting block (and sometimes the last block) for each file. This scheme eliminates external fragmentation, since any free block can be used, and file size can grow dynamically. However, random access is inefficient because to reach the k-th block of a file, the system must follow k − 1 pointers from the start, leading to O(k) access. To improve this, some systems maintain a File Allocation Table (FAT) in memory that stores these links centrally, allowing faster traversal and partial indexing.

174. During system startup (boot), which of the following tasks is typically performed by the operating system?

  1. Option A: Executing user login scripts only
  2. Option B: Loading the kernel into memory, initializing device drivers, mounting file systems, and starting system services
  3. Option C: Formatting all disks
  4. Option D: Deleting temporary files from user directories
Show hint

Think about the core steps that transition from firmware to a running OS environment.

Show answer

Answer: B. Loading the kernel into memory, initializing device drivers, mounting file systems, and starting system services

During boot, the firmware (BIOS or UEFI) initializes basic hardware and locates a bootloader. The bootloader then loads the operating system kernel into memory, transfers control to it, and the kernel proceeds to initialize core subsystems (memory management, process scheduler), load and initialize device drivers, mount root and other essential file systems, and start system services or daemons (such as logging, networking, and display managers). Only after these steps does the system present a login prompt or graphical login to the user. Shutdown performs the reverse: stopping services, syncing and unmounting file systems, and powering off safely to avoid data loss.

175. What manages virtual memory?

  1. Option A: CPU
  2. Option B: ALU
  3. Option C: Operating System
  4. Option D: Cache
Show hint

Software manages VM.

Show answer

Answer: C. Operating System

Operating system manages virtual memory through page tables.

176. Process after Kernel bootstrap?

  1. Option A: /sbin/init
  2. Option B: /etc/init.d
  3. Option C: /boot/grub
  4. Option D: /proc/kmsg
Show hint

Starts services.

Show answer

Answer: B. /etc/init.d

/etc/init.d scripts initialize system services.

177. FIFO page replacement?

  1. Option A: Oldest chosen
  2. Option B: Newest chosen
  3. Option C: Median chosen
  4. Option D: None
Show hint

First in first out.

Show answer

Answer: A. Oldest chosen

FIFO replaces oldest page first in memory management.

178. If you wanted to require that a user enter an Administrator password to perform administrative tasks, what type of user account should you create for the user?

NEC model set
  1. Option A: Administrator User account
  2. Option B: Standard User account
  3. Option C: Power User account
  4. Option D: Authenticated User account
Show hint

Standard users require elevated privileges (password) for admin tasks. Admins have unrestricted access.

Show answer

Answer: B. Standard User account

You should create a Standard User account if you want to require that users enter an Administrator password to perform administrative tasks. User account types in Windows: (1) Administrator account - Full unrestricted system access, no prompt needed for admin tasks, (2) Standard account - Limited permissions, prompted for admin password (UAC prompt) to perform admin tasks, (3) Power User - Intermediate privileges (less common in modern Windows), (4) Guest account - Very limited, temporary access. Standard User account benefits: (1) Security - Limits unintended system changes, (2) Protection from malware - Restricted from modifying system files, (3) User privilege separation - Standard vs admin tasks, (4) Audit trail - Admin actions logged separately. UAC (User Account Control) mechanism: (1) Standard user attempts admin task, (2) UAC prompt appears requesting admin credentials, (3) Admin password entered, (4) Task elevated and executed. Security implications: (1) Administrator accounts - Only for actual administrators, (2) Standard accounts - Most users should use these, (3) Run with lowest necessary privileges - Security principle, (4) Separate daily work account from admin account - Best practice. Real-world usage: (1) Enterprise environments - Users in Standard group, (2) Personal computers - Should have standard account for daily use, admin account for maintenance. Administrative task examples: (1) Install/uninstall software, (2) Modify system settings, (3) Access protected files, (4) Manage other user accounts. This principle of least privilege is fundamental to system security.

179. A page fault occurs when:

NEC model set
  1. Option A: a) The CPU is idle
  2. Option B: b) A page is not in memory
  3. Option C: c) Memory cache is full
  4. Option D: d) A process tries to access a page not in memory
Show hint

Page faults happen when a page is needed but missing. Which describes this?

Show answer

Answer: D. d) A process tries to access a page not in memory

A page fault occurs when a process tries to access a page not in memory (RAM). The memory management unit detects this and generates an interrupt. The OS then loads the required page from disk (virtual memory) into physical memory, possibly replacing another page. This mechanism allows systems to use more virtual memory than physical memory. Excessive page faults cause thrashing and performance degradation.

180. What is the process of swapping in operating systems?

Recalled from Jan 2026 exam
  1. Option A: Exchanging data between two registers
  2. Option B: Transferring a process between main memory and secondary storage
  3. Option C: Switching between multiple processes
  4. Option D: Copying data from cache to main memory
Show hint

Swapping moves entire processes between RAM and disk. What is this process?

Show answer

Answer: B. Transferring a process between main memory and secondary storage

Swapping in operating systems is the process of transferring an entire process (including its code, data, and stack) between main memory (RAM) and secondary storage (hard disk). When memory is needed, the OS swaps out a less-used process to disk, freeing RAM for other processes. When the swapped-out process is needed, it's swapped back into RAM. Swapping enables systems to run processes larger than physical memory and to manage limited memory resources. However, swapping is slow due to disk I/O. Paging is a related but more efficient technique that swaps memory pages rather than entire processes.

181. Virtual memory is:

  1. Option A: A type of main memory
  2. Option B: A technique that allows execution of processes that may not be completely in memory
  3. Option C: A memory that does not physically exist
  4. Option D: A memory used for virtual machines
Show answer

Answer: B. A technique that allows execution of processes that may not be completely in memory

182. Demand paging is:

  1. Option A: Loading pages into memory only when they are needed
  2. Option B: Loading all pages of a process before execution
  3. Option C: A technique to reduce page faults
  4. Option D: A page replacement algorithm
Show answer

Answer: A. Loading pages into memory only when they are needed

183. A page fault occurs when:

  1. Option A: A page is corrupted
  2. Option B: A process accesses a page not in memory
  3. Option C: The page table is full
  4. Option D: A process terminates abnormally
Show answer

Answer: B. A process accesses a page not in memory

184. The Least Recently Used (LRU) algorithm is used for:

  1. Option A: CPU scheduling
  2. Option B: Memory allocation
  3. Option C: Page replacement
  4. Option D: Disk scheduling
Show answer

Answer: C. Page replacement

185. A file in an operating system is:

  1. Option A: A collection of related records
  2. Option B: A named collection of related information
  3. Option C: A physical storage unit
  4. Option D: A system program
Show answer

Answer: B. A named collection of related information

186. A directory in a file system is:

  1. Option A: A file containing other files
  2. Option B: A special type of file that contains file names and pointers
  3. Option C: A physical location on disk
  4. Option D: A memory location
Show answer

Answer: B. A special type of file that contains file names and pointers

187. File allocation methods include:

  1. Option A: Contiguous, linked, and indexed allocation
  2. Option B: Sequential, random, and direct allocation
  3. Option C: Primary, secondary, and tertiary allocation
  4. Option D: Fixed, dynamic, and static allocation
Show answer

Answer: A. Contiguous, linked, and indexed allocation

188. Fragmentation in file systems refers to:

  1. Option A: Breaking a file into fragments
  2. Option B: Wasted space due to allocation methods
  3. Option C: Corrupted files
  4. Option D: File system errors
Show answer

Answer: B. Wasted space due to allocation methods

189. Which of the following is NOT a responsibility of a system administrator?

  1. Option A: User account management
  2. Option B: System startup and shutdown
  3. Option C: Application development
  4. Option D: Backup management
Show answer

Answer: C. Application development

Questions from bibhushansaakha/MCQ (MIT License, © 2024 Bibhushan Saakha) and SamirWagle/NECPrep. Exact duplicates are shown once. Where the source’s answer is missing, repeated, or disagrees between copies, the question carries a note. Questions are sorted into the official NEC syllabus topics; a few that sit between two topics may be filed under either.