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- Option A: 2^h
- Option B: 2^h - 1
- Option C: 2^(h+1) - 1
- Option D: 2^(h-1)
Show hintHide hint
A complete binary tree with height h has this many maximum nodes.
Show answerHide 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?
- Option A: 2^h
- Option B: 2^h - 1
- Option C: 2^(h+1) - 1
- Option D: 2^(h-1)
Show hintHide hint
Complete tree maximum.
Show answerHide 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)?
- Option A: A data structure is theoretical; an ADT is implementation-oriented
- Option B: A data structure is a concrete implementation; an ADT is a logical model specifying operations and behavior
- Option C: Both terms mean exactly the same thing in computer science
- Option D: An ADT is always implemented using arrays, never linked lists
Show hintHide hint
Think about interface vs implementation: "what" vs "how".
Show answerHide 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?
- Option A: The exact running time of an algorithm for all input sizes
- Option B: The upper bound on the growth rate of an algorithm's time or space as input size tends to infinity
- Option C: The lower bound on the running time of an algorithm
- Option D: The average running time of an algorithm over all inputs
Show hintHide hint
Think of it as a worst-case growth rate classification, ignoring constant factors.
Show answerHide 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)?
- Option A: Θ(n)
- Option B: Θ(n log n)
- Option C: Θ(n^2)
- Option D: Θ(log n)
Show hintHide hint
Identify the dominant term as n grows large and ignore constants.
Show answerHide 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)?
- Option A: Push
- Option B: Searching for an element
- Option C: Removing an element from the bottom of the stack
- Option D: Merging two stacks
Show hintHide hint
Focus on operations that touch only the top and a single index variable.
Show answerHide 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)?
- Option A: AB+CD-*
- Option B: AB+*CD-
- Option C: A+B*C-D
- Option D: ABCD+-*
Show hintHide hint
In postfix, operators appear after their operands; handle inner parentheses first.
Show answerHide 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?
- Option A: Pop first operand as right, second as left
- Option B: Pop first operand as left, second as right
- Option C: Use any order; it does not matter
- Option D: Always treat both popped operands as commutative
Show hintHide hint
Think of how "A B -" should be evaluated as A - B, not B - A.
Show answerHide 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?
- Option A: O(1)
- Option B: O(log n)
- Option C: O(n)
- Option D: O(n log n)
Show hintHide hint
You only need to change a constant number of pointers.
Show answerHide 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?
- Option A: Singly linked list
- Option B: Doubly linked list
- Option C: Circular singly linked list
- Option D: Static array-based list
Show hintHide hint
Each node maintains two links.
Show answerHide 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?
- Option A: It eliminates the need for a head pointer
- Option B: It allows easily cycling through all nodes from any starting node without hitting a null pointer
- Option C: It reduces memory usage for pointers
- Option D: It guarantees faster search operations
Show hintHide hint
Think about structures that model rings or round-robin scheduling.
Show answerHide 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?
- Option A: -1
- Option B: 0
- Option C: 1
- Option D: 2
Show hintHide hint
Count the number of edges, not nodes, on the longest root-to-leaf path.
Show answerHide 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?
- Option A: Pre-order traversal
- Option B: In-order traversal
- Option C: Post-order traversal
- Option D: Level-order traversal
Show hintHide hint
Visit left subtree, then root, then right subtree.
Show answerHide 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?
- Option A: The number of children of the node
- Option B: The height of the node's left subtree minus the height of its right subtree
- Option C: The number of nodes in its left subtree
- Option D: The total height of the tree
Show hintHide hint
AVL trees keep this value within -1, 0, or +1 for every node.
Show answerHide 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?
- Option A: Unbalanced binary search tree
- Option B: AVL tree
- Option C: Singly linked list
- Option D: Hash table with chaining
Show hintHide hint
It uses rotations after insert/delete to keep the tree balanced.
Show answerHide 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?
- Option A: 2^h
- Option B: 2^h - 1
- Option C: 2^(h+1) - 1
- Option D: 2^(h-1)
Show hintHide hint
Complete tree maximum.
Show answerHide answer
Answer: C. 2^(h+1) - 1
Maximum nodes in binary tree of height h = 2^(h+1) - 1.
17. Binary tree requirement?
- Option A: Balanced
- Option B: Complete
- Option C: Sorted
- Option D: One child
Show hintHide hint
BST property.
Show answerHide answer
Answer: C. Sorted
Binary search tree requires sorted order: left < root < right.
18. Which data structure is linear with pointer?
- Option A: Stack
- Option B: Queue
- Option C: Linked List
- Option D: Tree
Show hintHide hint
Each element points to next.
Show answerHide answer
Answer: C. Linked List
Linked list is linear collection where each element points to next.
19. Which follows FIFO principle?
- Option A: Queue
- Option B: Stack
- Option C: Linked List
- Option D: Tree
Show hintHide hint
First in, first out.
Show answerHide answer
Answer: A. Queue
Queue follows FIFO: first element added is first removed.
20. Common for implementing queue?
- Option A: Linked list
- Option B: Array
- Option C: Stack
- Option D: Hash table
Show hintHide hint
Dynamic size needed.
Show answerHide answer
Answer: A. Linked list
Linked lists commonly implement queues for dynamic size management.
21. Which data structure implements LIFO?
- Option A: Queue
- Option B: Stack
- Option C: Heap
- Option D: Tree
Show hintHide hint
Last in, first out.
Show answerHide answer
Answer: B. Stack
Stack implements LIFO: last element added is first removed.
22. Full binary tree leaves?
- Option A: L = 2*I
- Option B: L = I + 1
- Option C: L = I - 1
- Option D: L = 2*I - 1
Show hintHide hint
Leaf-node relation.
Show answerHide answer
Answer: B. L = I + 1
In full binary tree, leaves = internal nodes + 1.
23. What stack property use?
- Option A: FIFO
- Option B: LIFO
- Option C: Random
- Option D: Priority
Show hintHide hint
Last in, first out.
Show answerHide answer
Answer: B. LIFO
Stack uses LIFO: last pushed element popped first.
24. Deque allows?
- Option A: Delete front
- Option B: Insert rear
- Option C: Both
- Option D: Neither
Show hintHide hint
Double-ended queue.
Show answerHide 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- Option A: a) Null
- Option B: b) Last node
- Option C: c) Second node
- Option D: d) Itself
Show hintHide hint
In a circular list, everything points to something (nothing is null). First node's previous?
Show answerHide 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- Option A: AB+C*
- Option B: ABC+*
- Option C: A+BC*
- Option D: CAB+*
Show hintHide hint
Convert infix to postfix: operators come after operands. What is it?
Show answerHide 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?
- Option A: Queue
- Option B: Stack
- Option C: Linked List
- Option D: Tree
Show answerHide answer
Answer: B. Stack
28. The postfix expression for the infix expression A+B*C is:
- Option A: ABC+*
- Option B: AB+C*
- Option C: ABC*+
- Option D: +A*BC
Show answerHide answer
Answer: C. ABC*+
29. Which data structure follows the First-In-First-Out (FIFO) principle?
- Option A: Queue
- Option B: Stack
- Option C: Linked List
- Option D: Tree
Show answerHide answer
Answer: A. Queue
30. An AVL tree is:
- Option A: A binary search tree
- Option B: A balanced binary search tree
- Option C: A complete binary tree
- Option D: A full binary tree
Show answerHide answer
Answer: B. A balanced binary search tree
31. In a singly linked list, each node contains:
- Option A: Data and a pointer to the previous node
- Option B: Data and a pointer to the next node
- Option C: Data and pointers to both previous and next nodes
- Option D: Only data
Show answerHide 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?
- Option A: Big Oh (O)
- Option B: Omega (Ω)
- Option C: Theta (Θ)
- Option D: Delta (Δ)
Show answerHide answer
Answer: A. Big Oh (O)
33. Which of the following is NOT a type of linked list?
- Option A: Singly Linked List
- Option B: Doubly Linked List
- Option C: Circular Linked List
- Option D: Binary Linked List
Show answerHide answer
Answer: D. Binary Linked List
34. The height of a complete binary tree with n nodes is:
- Option A: log₂n
- Option B: n/2
- Option C: ⌊log₂n⌋
- Option D: n-1
Show answerHide answer
Answer: C. ⌊log₂n⌋
35. Which traversal of a binary tree visits the root node first?
- Option A: In-order
- Option B: Pre-order
- Option C: Post-order
- Option D: Level-order
Show answerHide answer
Answer: B. Pre-order
36. The time complexity of insertion in a singly linked list at the beginning is:
- Option A: O(1)
- Option B: O(log n)
- Option C: O(n)
- Option D: O(n²)
Show answerHide 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- Option A: O(n)
- Option B: O(n log n)
- Option C: O(n²)
- Option D: O(n³)
Show hintHide hint
Depends on gap sequence used.
Show answerHide 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- Option A: Transitive closure
- Option B: Shortest distance
- Option C: Minimum spanning tree
- Option D: Topological sorting
Show hintHide hint
Determines reachability between all pairs of vertices.
Show answerHide 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?
- Option A: Greedy
- Option B: Backtracking
- Option C: Dynamic Programming
- Option D: Divide Conquer
Show hintHide hint
Greedy choice at each step.
Show answerHide answer
Answer: A. Greedy
Dijkstra's shortest path uses greedy paradigm.
40. What does Warshall algorithm compute?
- Option A: Transitive closure
- Option B: Shortest distance
- Option C: MST
- Option D: Topological sort
Show hintHide hint
Path existence.
Show answerHide answer
Answer: A. Transitive closure
Warshall's algorithm computes transitive closure of directed graph.
41. Complexity binary search?
- Option A: O(n)
- Option B: O(log n)
- Option C: O(n²)
- Option D: O(n log n)
Show hintHide hint
Divide and conquer.
Show answerHide answer
Answer: B. O(log n)
Binary search has O(log n) complexity.
42. Shell sort worst-case?
- Option A: O(n)
- Option B: O(n log n)
- Option C: O(n²)
- Option D: O(n³)
Show hintHide hint
Gap sequence dependent.
Show answerHide answer
Answer: C. O(n²)
Shell sort worst-case is O(n²) with poor gap sequences.
43. Quicksort average case?
- Option A: O(n)
- Option B: O(n²)
- Option C: O(n log n)
- Option D: O(log n)
Show hintHide hint
Divide and conquer.
Show answerHide 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?
- Option A: It requires additional memory proportional to the input size (O(n))
- Option B: It performs sorting by using only a constant amount of extra memory, aside from the input array
- Option C: It can only sort small datasets that fit in main memory
- Option D: It always uses recursion
Show hintHide hint
Focus on extra space overhead, not whether the data fits into RAM.
Show answerHide 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?
- Option A: O(n)
- Option B: O(n log n)
- Option C: O(n^2)
- Option D: O(log n)
Show hintHide hint
Each inserted element may need to be compared with almost all previous elements.
Show answerHide 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?
- Option A: It only uses swapping operations
- Option B: It does not use recursion
- Option C: It always performs log n levels of merging, each processing n elements
- Option D: It uses a heap structure internally
Show hintHide hint
Think in terms of repeatedly dividing and then merging.
Show answerHide 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?
- Option A: Comparing pairs of keys and swapping them
- Option B: Using a binary search tree to store keys and then traversing it
- Option C: Sorting keys digit by digit using a stable stable subroutine (like counting sort) for each digit position
- Option D: Randomly shuffling elements until they are sorted
Show hintHide hint
It is a non-comparison-based algorithm that exploits the structure of keys.
Show answerHide 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?
- Option A: It scans the array from left to right until the element is found
- Option B: It repeatedly divides the search interval in half by comparing the target to the middle element
- Option C: It builds a search tree and then performs in-order traversal
- Option D: It hashes all elements and checks the hash table
Show hintHide hint
Each comparison discards half of the remaining search space.
Show answerHide 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?
- Option A: To sort all keys before insertion
- Option B: To map keys to array indices in a way that spreads them out uniformly
- Option C: To ensure cryptographic security of stored data
- Option D: To compress large files
Show hintHide hint
It converts a key into an index into the bucket array.
Show answerHide 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?
- Option A: Linear probing
- Option B: Quadratic probing
- Option C: Separate chaining
- Option D: Double hashing
Show hintHide hint
Colliding keys are stored in a secondary structure attached to each bucket.
Show answerHide 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?
- Option A: n^2
- Option B: n(n − 1)
- Option C: n(n − 1)/2
- Option D: 2n
Show hintHide hint
Think of choosing any unordered pair of distinct vertices.
Show answerHide 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?
- Option A: Depth First Search (DFS)
- Option B: Breadth First Search (BFS)
- Option C: Dijkstra's algorithm
- Option D: Prim's algorithm
Show hintHide hint
It visits all neighbors of a vertex before going deeper.
Show answerHide 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?
- Option A: Dijkstra's algorithm
- Option B: Kruskal's algorithm
- Option C: Bellman–Ford algorithm
- Option D: Warshall's algorithm
Show hintHide hint
It repeatedly picks the lightest edge that does not create a cycle.
Show answerHide 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?
- Option A: Finding a minimum spanning tree
- Option B: Finding a topological ordering
- Option C: Finding single-source shortest paths in a graph with non-negative edge weights
- Option D: Computing the transitive closure
Show hintHide hint
It uses a greedy strategy with a priority queue to relax edges.
Show answerHide 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?
- Option A: Warshall's algorithm
- Option B: Prim's algorithm
- Option C: Kruskal's algorithm
- Option D: DFS tree construction
Show hintHide hint
It is an all-pairs reachability algorithm based on dynamic programming.
Show answerHide 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)?
- Option A: An ordering of vertices where every edge goes from a vertex later in the order to one earlier
- Option B: An ordering of vertices such that for every directed edge u → v, u appears before v in the ordering
- Option C: An ordering that minimizes the number of edges
- Option D: An ordering produced only by breadth-first search
Show hintHide hint
It respects all precedence constraints encoded by edges.
Show answerHide 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?
- Option A: Insertion sort
- Option B: Merge sort
- Option C: Quick sort
- Option D: Bubble sort
Show hintHide hint
O(n) for sorted.
Show answerHide answer
Answer: A. Insertion sort
Insertion sort is efficient for already sorted data with O(n) complexity.
58. Best case quicksort?
- Option A: O(n)
- Option B: O(n log n)
- Option C: O(n²)
- Option D: O(log n)
Show hintHide hint
Balanced partition.
Show answerHide answer
Answer: B. O(n log n)
Best-case quicksort is O(n log n) with balanced partitioning.
59. Complexity DFS?
- Option A: O(n)
- Option B: O(n²)
- Option C: O(log n)
- Option D: O(n log n)
Show hintHide hint
Visit each vertex once.
Show answerHide answer
Answer: A. O(n)
DFS has O(V+E) or O(n) complexity visiting each node once.
60. Graph traversal BFS?
- Option A: Stack
- Option B: Queue
- Option C: Heap
- Option D: Tree
Show hintHide hint
Level-by-level.
Show answerHide answer
Answer: B. Queue
BFS uses queue for level-by-level traversal.
61. Merge sort complexity?
- Option A: O(n)
- Option B: O(n log n)
- Option C: O(n²)
- Option D: O(log n)
Show hintHide hint
Divide and conquer.
Show answerHide answer
Answer: B. O(n log n)
Merge sort has O(n log n) complexity in all cases.
62. Shortest path algorithm?
- Option A: DFS
- Option B: BFS
- Option C: Dijkstra
- Option D: Floyd
Show hintHide hint
Weights considered.
Show answerHide 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- Option A: h(k) = k·m
- Option B: h(k) = k mod m
- Option C: h(k) = m·k
- Option D: h(k) = m mod k
Show hintHide hint
Division method uses modulo operation to map keys to hash table positions.
Show answerHide 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- Option A: a) O(n)
- Option B: b) O(n log n)
- Option C: c) O(n²)
- Option D: d) O(log n)
Show hintHide hint
Merge sort's performance is consistent regardless of input. What's the complexity?
Show answerHide 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- Option A: Stack
- Option B: Queue
- Option C: Linked List
- Option D: Tree
Show hintHide hint
BFS explores nodes level by level. What FIFO structure enables this?
Show answerHide 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?
- Option A: Bubble Sort
- Option B: Insertion Sort
- Option C: Quick Sort
- Option D: Selection Sort
Show answerHide answer
Answer: C. Quick Sort
67. The time complexity of binary search is:
- Option A: O(n)
- Option B: O(log n)
- Option C: O(n log n)
- Option D: O(n²)
Show answerHide answer
Answer: B. O(log n)
68. Binary search can be applied to:
- Option A: Any list
- Option B: Sorted list only
- Option C: Linked list only
- Option D: Unsorted list only
Show answerHide answer
Answer: B. Sorted list only
69. A collision in hashing occurs when:
- Option A: Two different keys hash to the same value
- Option B: A key cannot be hashed
- Option C: The hash table is full
- Option D: The hash function returns a negative value
Show answerHide answer
Answer: A. Two different keys hash to the same value
70. Hashing is used for:
- Option A: Sorting data
- Option B: Fast data retrieval
- Option C: Data compression
- Option D: Data encryption
Show answerHide 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?
- Option A: Prim's algorithm
- Option B: Kruskal's algorithm
- Option C: Dijkstra's algorithm
- Option D: Warshall's algorithm
Show answerHide answer
Answer: C. Dijkstra's algorithm
72. Topological sorting can be applied to:
- Option A: Any graph
- Option B: Undirected graph
- Option C: Directed acyclic graph
- Option D: Complete graph
Show answerHide answer
Answer: C. Directed acyclic graph
73. Which traversal of a graph uses a queue?
- Option A: Depth-First Search
- Option B: Breadth-First Search
- Option C: Both A and B
- Option D: Neither A nor B
Show answerHide answer
Answer: B. Breadth-First Search
74. A minimum spanning tree of a graph is:
- Option A: A tree that connects all vertices with minimum total edge weight
- Option B: A tree with the minimum number of edges
- Option C: A tree with the minimum number of vertices
- Option D: A tree with the minimum height
Show answerHide 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:
- Option A: O(1)
- Option B: O(log n)
- Option C: O(n)
- Option D: O(n²)
Show answerHide answer
Answer: C. O(n)
76. Which of the following is NOT a collision resolution technique in hashing?
- Option A: Open addressing
- Option B: Chaining
- Option C: Double hashing
- Option D: Sorting
Show answerHide answer
Answer: D. Sorting
77. The time complexity of Prim's algorithm for finding a minimum spanning tree using an adjacency matrix is:
- Option A: O(V²)
- Option B: O(E log V)
- Option C: O(V + E)
- Option D: O(V log E)
Show answerHide answer
Answer: A. O(V²)
78. The worst-case time complexity of Quicksort is:
- Option A: O(n)
- Option B: O(n log n)
- Option C: O(n²)
- Option D: O(n³)
Show answerHide answer
Answer: C. O(n²)
79. Which sorting algorithm is based on the divide-and-conquer strategy?
- Option A: Insertion Sort
- Option B: Selection Sort
- Option C: Bubble Sort
- Option D: Merge Sort
Show answerHide answer
Answer: D. Merge Sort
7.3 Data models, normalization and SQL
29 questions · ACtE0703
80. What SQL command removes content without changing structure?
- Option A: DROP
- Option B: TRUNCATE
- Option C: DELETE
- Option D: REMOVE
Show hintHide hint
Removes rows, keeps table structure.
Show answerHide 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?
- Option A: Y uniquely determines X
- Option B: Whenever two tuples agree on attributes X, they must also agree on attributes Y
- Option C: X and Y are independent attributes
- Option D: X and Y must both be primary keys
Show hintHide hint
Think of X as determining Y in any valid relation instance.
Show answerHide 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?
- Option A: A functionally determines C via transitivity
- Option B: C functionally determines A
- Option C: A and C are independent
- Option D: D is functionally determined by A
Show hintHide hint
Use Armstrong’s axiom of transitivity: if X → Y and Y → Z, then X → Z.
Show answerHide 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?
- Option A: First Normal Form (1NF)
- Option B: Second Normal Form (2NF)
- Option C: Third Normal Form (3NF)
- Option D: Boyce–Codd Normal Form (BCNF)
Show hintHide hint
It addresses dependencies like key → X → Y with Y non-key.
Show answerHide 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?
- Option A: A weak entity set can have attributes; a strong entity set cannot
- Option B: A weak entity set does not have a primary key and is identified by being related to another entity set
- Option C: A weak entity set cannot participate in relationships
- Option D: There is no difference; the terms are synonyms
Show hintHide hint
Think of entities that depend on another entity for identity, like 'Dependents' of an 'Employee'.
Show answerHide 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?
- Option A: Data Definition Language (DDL)
- Option B: Data Manipulation Language (DML)
- Option C: Data Control Language (DCL)
- Option D: Transaction Control Language (TCL)
Show hintHide hint
Think about commands that define schema objects.
Show answerHide 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)?
- Option A: Selection followed by Cartesian product
- Option B: Join followed by union
- Option C: Selection (σ) over a Cartesian product (×) of relations
- Option D: Projection (π) only
Show hintHide hint
Conceptually, SQL joins are selection over product, plus projection.
Show answerHide 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?
- Option A: To change the meaning of the query
- Option B: To find an equivalent logical formulation that uses fewer relations
- Option C: To choose an efficient physical execution plan for a given logical query expression
- Option D: To automatically normalize the schema
Show hintHide hint
The logical query is fixed; we are selecting the best way to execute it.
Show answerHide 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?
- Option A: Single-valued
- Option B: Derived
- Option C: Composite
- Option D: Multi-valued
Show hintHide hint
One value per entity.
Show answerHide 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- Option A: Abnormal
- Option B: Normal
- Option C: Special
- Option D: Exactly
Show hintHide hint
Database normalization removes redundancy and improves data integrity through normal forms.
Show answerHide 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- Option A: First Normal Form (1NF)
- Option B: Second Normal Form (2NF)
- Option C: Boyce-Codd Normal Form (BCNF)
- Option D: Third Normal Form (3NF)
Show hintHide hint
This strict normal form requires every determinant to be a candidate key. What is it?
Show answerHide 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- Option A: Eliminates all non-key dependencies
- Option B: Eliminates only partial dependencies
- Option C: Eliminates transitive dependencies
- Option D: Eliminates all non-trivial functional dependencies where the determinant is not a candidate key
Show hintHide hint
BCNF is the strictest normal form. What dependencies does it eliminate?
Show answerHide 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:
- Option A: Physical data organization
- Option B: Hiding implementation details
- Option C: Data compression
- Option D: Data encryption
Show answerHide answer
Answer: B. Hiding implementation details
93. In an E-R diagram, an entity is represented by:
- Option A: Rectangle
- Option B: Ellipse
- Option C: Diamond
- Option D: Triangle
Show answerHide answer
Answer: A. Rectangle
94. The primary key of a relation is:
- Option A: Any attribute
- Option B: An attribute that uniquely identifies each tuple
- Option C: The first attribute
- Option D: An attribute with the most values
Show answerHide answer
Answer: B. An attribute that uniquely identifies each tuple
95. A weak entity in an E-R model is one that:
- Option A: Has few attributes
- Option B: Depends on another entity for identification
- Option C: Has no primary key
- Option D: Is not important to the database
Show answerHide answer
Answer: B. Depends on another entity for identification
96. A relation is in First Normal Form (1NF) if:
- Option A: It has no repeating groups
- Option B: It has no partial dependencies
- Option C: It has no transitive dependencies
- Option D: It has no multi-valued dependencies
Show answerHide answer
Answer: A. It has no repeating groups
97. A relation is in Second Normal Form (2NF) if:
- Option A: It is in 1NF and has no repeating groups
- Option B: It is in 1NF and has no partial dependencies
- Option C: It is in 1NF and has no transitive dependencies
- Option D: It is in 1NF and has no multi-valued dependencies
Show answerHide answer
Answer: B. It is in 1NF and has no partial dependencies
98. SQL stands for:
- Option A: Structured Query Language
- Option B: Simple Query Language
- Option C: Standard Query Language
- Option D: System Query Language
Show answerHide answer
Answer: A. Structured Query Language
99. A relation is in Third Normal Form (3NF) if:
- Option A: It is in 2NF and has no repeating groups
- Option B: It is in 2NF and has no partial dependencies
- Option C: It is in 2NF and has no transitive dependencies
- Option D: It is in 2NF and has no multi-valued dependencies
Show answerHide 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?
- Option A: MODIFY
- Option B: ALTER
- Option C: CHANGE
- Option D: UPDATE
Show answerHide answer
Answer: D. UPDATE
101. A view in SQL is:
- Option A: A physical table
- Option B: A virtual table based on a query
- Option C: A graphical representation of data
- Option D: A database schema
Show answerHide answer
Answer: B. A virtual table based on a query
102. Which SQL command is used to create a new table?
- Option A: CREATE TABLE
- Option B: NEW TABLE
- Option C: ADD TABLE
- Option D: INSERT TABLE
Show answerHide answer
Answer: A. CREATE TABLE
103. Which SQL command is used to add new data to a table?
- Option A: ADD
- Option B: CREATE
- Option C: INSERT
- Option D: UPDATE
Show answerHide answer
Answer: C. INSERT
104. Relational algebra is:
- Option A: A procedural query language
- Option B: A non-procedural query language
- Option C: A data definition language
- Option D: A data manipulation language
Show answerHide answer
Answer: A. A procedural query language
105. Query optimization in databases aims to:
- Option A: Reduce the size of the database
- Option B: Improve query execution efficiency
- Option C: Simplify query syntax
- Option D: Increase database security
Show answerHide answer
Answer: B. Improve query execution efficiency
106. Which normal form deals with multi-valued dependencies?
- Option A: 3NF
- Option B: BCNF
- Option C: 4NF
- Option D: 5NF
Show answerHide answer
Answer: C. 4NF
107. Which SQL clause is used to filter rows?
- Option A: SELECT
- Option B: FROM
- Option C: WHERE
- Option D: GROUP BY
Show answerHide answer
Answer: C. WHERE
108. A trigger in SQL is:
- Option A: A type of query
- Option B: A stored procedure that automatically executes when an event occurs
- Option C: A constraint on a table
- Option D: A type of join
Show answerHide 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?
- Option A: Atomicity, Consistency, Isolation, Durability
- Option B: Association, Concurrency, Integrity, Durability
- Option C: Atomicity, Concurrency, Independence, Distribution
- Option D: Accuracy, Consistency, Isolation, Distribution
Show hintHide hint
Each letter corresponds to a fundamental guarantee of a transaction.
Show answerHide 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?
- Option A: To ensure that all transactions run as slowly as possible
- Option B: To prevent any two transactions from ever running at the same time
- Option C: To coordinate concurrent access to data items so that the resulting schedule is serializable
- Option D: To avoid logging overhead by eliminating undo/redo operations
Show hintHide hint
Think of locks as a way to serialize conflicting operations while allowing non-conflicting ones to overlap.
Show answerHide 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?
- Option A: A transaction releasing all locks before acquiring new ones
- Option B: Two transactions each holding a lock on one item and waiting for a lock on the other's item
- Option C: Using read-only transactions
- Option D: Having only one transaction in the system
Show hintHide hint
Think of a circular wait scenario where each waits for the other.
Show answerHide 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?
- Option A: To compress database files
- Option B: To record changes so that the system can undo or redo them after a crash
- Option C: To speed up query processing
- Option D: To avoid the need for concurrency control
Show hintHide hint
Think of the log as a chronological history of all updates.
Show answerHide 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?
- Option A: Atomicity
- Option B: Consistency
- Option C: Isolation
- Option D: Durability
Show hintHide hint
It controls the visibility of partial updates among concurrent transactions.
Show answerHide 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?
- Option A: All or nothing
- Option B: Data consistency
- Option C: System reliability
- Option D: Transaction isolation
Show hintHide hint
Transaction commitment.
Show answerHide answer
Answer: A. All or nothing
Atomicity ensures transaction either completes fully or not at all.
115. Not transaction property?
- Option A: Atomicity
- Option B: Durability
- Option C: Isolation
- Option D: Concurrency
Show hintHide hint
Four ACID properties.
Show answerHide 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- Option A: Data
- Option B: Logs
- Option C: Receive
- Option D: Record
Show hintHide hint
Recovery mechanisms require recording transaction information. What should be stored for backup/recovery?
Show answerHide 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:
- Option A: Transactions are executed in a specific order
- Option B: Concurrent transactions produce the same result as if executed serially
- Option C: Transactions are converted to a serial format
- Option D: Transactions are executed as quickly as possible
Show answerHide answer
Answer: B. Concurrent transactions produce the same result as if executed serially
118. ACID properties in transaction processing stand for:
- Option A: Atomicity, Consistency, Isolation, Durability
- Option B: Availability, Consistency, Integrity, Durability
- Option C: Atomicity, Correctness, Integrity, Durability
- Option D: Availability, Consistency, Isolation, Distribution
Show answerHide answer
Answer: A. Atomicity, Consistency, Isolation, Durability
119. A deadlock in database systems occurs when:
- Option A: The database is full
- Option B: Two or more transactions are waiting for each other to release locks
- Option C: A transaction is aborted
- Option D: The database server crashes
Show answerHide 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:
- Option A: Prevent deadlocks
- Option B: Optimize queries
- Option C: Recover from system failures
- Option D: Encrypt data
Show answerHide answer
Answer: C. Recover from system failures
121. The two-phase locking protocol is used for:
- Option A: Deadlock prevention
- Option B: Ensuring serializability
- Option C: Query optimization
- Option D: Data recovery
Show answerHide 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- Option A: Process scheduling
- Option B: Memory allocation
- Option C: Deadlock detection
- Option D: File management
Show hintHide hint
Detects cycles indicating circular wait.
Show answerHide 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:
- Option A: A program in execution
- Option B: A program stored on disk
- Option C: A single instruction
- Option D: A hardware component
Show answerHide answer
Answer: A. A program in execution
124. A semaphore is used for:
- Option A: Memory management
- Option B: Process synchronization
- Option C: File management
- Option D: I/O management
Show answerHide answer
Answer: B. Process synchronization
125. The difference between a process and a thread is:
- Option A: Processes are faster than threads
- Option B: Threads share memory space while processes have separate memory spaces
- Option C: Processes can be multitasked but threads cannot
- Option D: Threads require more resources than processes
Show answerHide answer
Answer: B. Threads share memory space while processes have separate memory spaces
126. Which synchronization mechanism can lead to busy waiting?
- Option A: Semaphores
- Option B: Message passing
- Option C: Spinlocks
- Option D: Monitors
Show answerHide answer
Answer: C. Spinlocks
127. The primary difference between mutex and semaphore is:
- Option A: Mutex can only be used for process synchronization
- Option B: Semaphore can only be used for thread synchronization
- Option C: Mutex is owned by a thread and only that thread can release it
- Option D: Semaphore is faster than mutex
Show answerHide 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?
- Option A: Application software
- Option B: System software
- Option C: Programming software
- Option D: Utility software
Show answerHide answer
Answer: B. System software
129. Which of the following best describes a process in an operating system?
- Option A: A program stored on disk
- Option B: An instance of a program in execution, including its code, data, and execution context
- Option C: A single CPU instruction
- Option D: A function call within a program
Show hintHide hint
Think of dynamic execution plus its OS-managed state, not just the static code.
Show answerHide 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?
- Option A: A process has no address space; a thread does
- Option B: Threads within the same process share the same address space, while processes have separate address spaces
- Option C: A thread cannot be scheduled independently
- Option D: Only processes can perform I/O operations
Show hintHide hint
Focus on memory protection and sharing.
Show answerHide 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?
- Option A: First-Come, First-Served (FCFS)
- Option B: Shortest Job Next (SJN) without preemption
- Option C: Round Robin (RR)
- Option D: Preemptive priority scheduling without aging
Show hintHide hint
Consider a low-priority process that is always preempted by higher-priority arrivals.
Show answerHide 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?
- Option A: A situation where processes compete for CPU time but are scheduled fairly
- Option B: A condition where the output depends on the relative timing of concurrent operations on shared data
- Option C: A performance optimization technique for parallel programs
- Option D: A method of allocating memory dynamically
Show hintHide hint
If operations interleave differently, the final result can change unpredictably.
Show answerHide 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)?
- Option A: Monitor
- Option B: Semaphore
- Option C: Message queue
- Option D: Condition variable
Show hintHide hint
It can be binary or counting and was introduced by Dijkstra.
Show answerHide 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?
- Option A: Producer–Consumer problem
- Option B: Readers–Writers problem
- Option C: Dining Philosophers problem
- Option D: Bounded Buffer problem
Show hintHide hint
Think about philosophers needing two shared resources (forks) to eat.
Show answerHide 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?
- Option A: Scheduling
- Option B: Memory
- Option C: Deadlock detection
- Option D: File manage
Show hintHide hint
Detects cycles.
Show answerHide answer
Answer: C. Deadlock detection
Wait-for graph detects deadlock by identifying circular waits.
136. Multiple processes single-user term?
- Option A: Multiprocessing
- Option B: Multitasking
- Option C: Multithreading
- Option D: Time-sharing
Show hintHide hint
CPU time sharing.
Show answerHide answer
Answer: B. Multitasking
Multitasking allows multiple processes to share single CPU.
137. Process vs thread?
- Option A: Process independent
- Option B: Thread independent
- Option C: Process subset
- Option D: Thread has memory
Show hintHide hint
Hierarchy.
Show answerHide answer
Answer: A. Process independent
Process is independent; thread is subset of process sharing memory.
138. Synchronization in multiprocessor?
- Option A: Semaphores
- Option B: Shared memory
- Option C: Coherence
- Option D: Message passing
Show hintHide hint
Prevents race conditions.
Show answerHide answer
Answer: A. Semaphores
Semaphores and mutexes prevent race conditions in shared resources.
139. Preemptive scheduling algorithm?
- Option A: FCFS
- Option B: SJN
- Option C: Round Robin
- Option D: HRRN
Show hintHide hint
Time slice based.
Show answerHide answer
Answer: C. Round Robin
Round Robin is preemptive: each process gets time slice then preempted.
140. In fork() system call?
- Option A: Same memory
- Option B: Different processes
- Option C: Parent wait
- Option D: Child priority
Show hintHide hint
Creates new process.
Show answerHide 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- Option A: Mutual Exclusion
- Option B: Synchronization
- Option C: Deadlock
- Option D: Starvation
Show hintHide hint
Mutual exclusion prevents simultaneous access to shared resources. What do enter/exit critical sections enforce?
Show answerHide 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- Option A: a) Starvation
- Option B: b) Semaphore overflow
- Option C: c) Deadlock
- Option D: d) Race condition
Show hintHide hint
Without mutual exclusion, multiple processes access the same resource. What problem happens?
Show answerHide 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- Option A: Process
- Option B: Thread
- Option C: Kernel
- Option D: Containers
Show hintHide hint
Processes are independent units of execution with complete isolated resources.
Show answerHide 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- Option A: File manager
- Option B: Memory manager
- Option C: Process scheduler
- Option D: Device driver
Show hintHide hint
This OS component decides which process runs when. What is it?
Show answerHide 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?
- Option A: Batch Operating System
- Option B: Time-Sharing Operating System
- Option C: Distributed Operating System
- Option D: Sequential Operating System
Show answerHide answer
Answer: D. Sequential Operating System
146. The main function of an operating system is:
- Option A: To provide a user interface
- Option B: To manage computer resources
- Option C: To run application programs
- Option D: To provide internet connectivity
Show answerHide answer
Answer: B. To manage computer resources
147. A process in an operating system is:
- Option A: A program in execution
- Option B: A program stored on disk
- Option C: A processor
- Option D: A thread
Show answerHide answer
Answer: A. A program in execution
148. The process state when it is ready to run but waiting for the CPU is:
- Option A: Running
- Option B: Ready
- Option C: Blocked
- Option D: Terminated
Show answerHide answer
Answer: B. Ready
149. Which scheduling algorithm gives the CPU to the process with the shortest expected processing time?
- Option A: First-Come-First-Served
- Option B: Shortest Job First
- Option C: Round Robin
- Option D: Priority Scheduling
Show answerHide answer
Answer: B. Shortest Job First
150. A thread is:
- Option A: A heavy-weight process
- Option B: A light-weight process
- Option C: A program
- Option D: An operating system
Show answerHide answer
Answer: B. A light-weight process
151. A critical region in concurrent programming is:
- Option A: A region of memory that cannot be accessed
- Option B: A segment of code that accesses shared resources
- Option C: A region of the disk that contains critical data
- Option D: A part of the operating system that manages critical processes
Show answerHide answer
Answer: B. A segment of code that accesses shared resources
152. A race condition occurs when:
- Option A: Two processes compete for CPU time
- Option B: The outcome depends on the relative timing of events
- Option C: A process is running too fast
- Option D: A process is waiting for an event
Show answerHide answer
Answer: B. The outcome depends on the relative timing of events
153. Mutual exclusion ensures that:
- Option A: All processes can access shared resources simultaneously
- Option B: Only one process can access a shared resource at a time
- Option C: Processes are executed in a specific order
- Option D: Processes are excluded from execution
Show answerHide answer
Answer: B. Only one process can access a shared resource at a time
154. A semaphore is used for:
- Option A: Process creation
- Option B: Memory allocation
- Option C: Process synchronization
- Option D: File management
Show answerHide answer
Answer: C. Process synchronization
155. The difference between a mutex and a semaphore is:
- Option A: A mutex can only be used for mutual exclusion, while a semaphore can be used for both mutual exclusion and synchronization
- Option B: A semaphore can only be used for mutual exclusion, while a mutex can be used for both mutual exclusion and synchronization
- Option C: A mutex is faster than a semaphore
- Option D: A semaphore is used in Windows, while a mutex is used in Unix
Show answerHide 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:
- Option A: Deadlock
- Option B: Race condition
- Option C: Starvation
- Option D: All of these
Show answerHide answer
Answer: D. All of these
157. Which of the following is NOT a process state?
- Option A: New
- Option B: Ready
- Option C: Running
- Option D: Idle
Show answerHide answer
Answer: D. Idle
158. Context switching refers to:
- Option A: Changing the context of a program
- Option B: Switching from user mode to kernel mode
- Option C: Saving the state of one process and loading the state of another
- Option D: Switching between different user interfaces
Show answerHide 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- Option A: 12.9ms
- Option B: 20.9ms
- Option C: 19.9ms
- Option D: 0.01ms
Show hintHide hint
Use: EAT = Ma + Pf × (Tf - Ma), where Ma=memory access, Pf=fault rate, Tf=fault time
Show answerHide 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- Option A: disk
- Option B: RAM
- Option C: cache
- Option D: register
Show hintHide hint
Which storage device allows random access to any location?
Show answerHide 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?
- Option A: Control unit
- Option B: Arithmetic logic unit
- Option C: Operating system
- Option D: Cache memory
Show hintHide hint
Software manages virtual memory.
Show answerHide 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?
- Option A: Page table
- Option B: Memory controller
- Option C: Hard drive
- Option D: RAM
Show hintHide hint
Maps virtual to physical addresses.
Show answerHide 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?
- Option A: CPU operations
- Option B: RAM access
- Option C: Bootloader functions
- Option D: Graphics processing
Show hintHide hint
System initialization.
Show answerHide 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:
- Option A: To translate assembly code to machine code
- Option B: To speed up virtual-to-physical address translation
- Option C: To buffer data between CPU and memory
- Option D: To translate between different instruction sets
Show answerHide answer
Answer: B. To speed up virtual-to-physical address translation
165. The primary function of the Memory Management Unit (MMU) is:
- Option A: To increase memory capacity
- Option B: To translate virtual addresses to physical addresses
- Option C: To improve memory access speed
- Option D: To compress data in memory
Show answerHide 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?
- Option A: To manage data flow between input/output devices
- Option B: To store instructions that the CPU can execute
- Option C: To regulate the flow of data between the CPU and memory
- Option D: To map virtual memory addresses to physical memory addresses
Show answerHide 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)?
- Option A: Caching of frequently used data
- Option B: Translation of virtual addresses to physical addresses
- Option C: Access control to memory locations
- Option D: Paging of memory to disk when needed
Show answerHide answer
Answer: A. Caching of frequently used data
168. Which of the following is not a characteristic of virtual memory?
- Option A: Allows programs to exceed physical memory capacity
- Option B: Uses a page table to map virtual addresses to physical addresses
- Option C: Stores data in registers
- Option D: Provides memory protection between programs
Show answerHide answer
Answer: C. Stores data in registers
169. In virtual memory systems, what is demand paging?
- Option A: Loading all pages of a process into memory before execution starts
- Option B: Loading pages into memory only when they are actually referenced
- Option C: Keeping all processes permanently in memory
- Option D: Swapping out all pages whenever memory is full
Show hintHide hint
It avoids bringing in unused pages at process start.
Show answerHide 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?
- Option A: First-In, First-Out (FIFO)
- Option B: Least Recently Used (LRU)
- Option C: Optimal (Belady's)
- Option D: Clock (Second Chance)
Show hintHide hint
It approximates the optimal algorithm based on recency of use.
Show answerHide 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?
- Option A: Unallocated memory between allocated blocks
- Option B: Wasted space inside an allocated block due to fixed-size allocation units
- Option C: Memory left unused at the end of physical memory
- Option D: Loss of memory due to page replacement
Show hintHide hint
The process receives more memory than it requested, and the remainder cannot be used by others.
Show answerHide 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?
- Option A: To store the actual file contents
- Option B: To map file names to file metadata (such as inode or file control block) and sometimes to their locations
- Option C: To manage disk scheduling
- Option D: To perform data compression
Show hintHide hint
Think of it as a table of contents mapping names to file descriptors.
Show answerHide 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?
- Option A: Contiguous allocation
- Option B: Linked allocation
- Option C: Indexed allocation
- Option D: Hashed allocation
Show hintHide hint
Think of following pointers from block to block.
Show answerHide 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?
- Option A: Executing user login scripts only
- Option B: Loading the kernel into memory, initializing device drivers, mounting file systems, and starting system services
- Option C: Formatting all disks
- Option D: Deleting temporary files from user directories
Show hintHide hint
Think about the core steps that transition from firmware to a running OS environment.
Show answerHide 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?
- Option A: CPU
- Option B: ALU
- Option C: Operating System
- Option D: Cache
Show hintHide hint
Software manages VM.
Show answerHide answer
Answer: C. Operating System
Operating system manages virtual memory through page tables.
176. Process after Kernel bootstrap?
- Option A: /sbin/init
- Option B: /etc/init.d
- Option C: /boot/grub
- Option D: /proc/kmsg
Show hintHide hint
Starts services.
Show answerHide answer
Answer: B. /etc/init.d
/etc/init.d scripts initialize system services.
177. FIFO page replacement?
- Option A: Oldest chosen
- Option B: Newest chosen
- Option C: Median chosen
- Option D: None
Show hintHide hint
First in first out.
Show answerHide 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- Option A: Administrator User account
- Option B: Standard User account
- Option C: Power User account
- Option D: Authenticated User account
Show hintHide hint
Standard users require elevated privileges (password) for admin tasks. Admins have unrestricted access.
Show answerHide 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- Option A: a) The CPU is idle
- Option B: b) A page is not in memory
- Option C: c) Memory cache is full
- Option D: d) A process tries to access a page not in memory
Show hintHide hint
Page faults happen when a page is needed but missing. Which describes this?
Show answerHide 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- Option A: Exchanging data between two registers
- Option B: Transferring a process between main memory and secondary storage
- Option C: Switching between multiple processes
- Option D: Copying data from cache to main memory
Show hintHide hint
Swapping moves entire processes between RAM and disk. What is this process?
Show answerHide 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:
- Option A: A type of main memory
- Option B: A technique that allows execution of processes that may not be completely in memory
- Option C: A memory that does not physically exist
- Option D: A memory used for virtual machines
Show answerHide answer
Answer: B. A technique that allows execution of processes that may not be completely in memory
182. Demand paging is:
- Option A: Loading pages into memory only when they are needed
- Option B: Loading all pages of a process before execution
- Option C: A technique to reduce page faults
- Option D: A page replacement algorithm
Show answerHide answer
Answer: A. Loading pages into memory only when they are needed
183. A page fault occurs when:
- Option A: A page is corrupted
- Option B: A process accesses a page not in memory
- Option C: The page table is full
- Option D: A process terminates abnormally
Show answerHide answer
Answer: B. A process accesses a page not in memory
184. The Least Recently Used (LRU) algorithm is used for:
- Option A: CPU scheduling
- Option B: Memory allocation
- Option C: Page replacement
- Option D: Disk scheduling
Show answerHide answer
Answer: C. Page replacement
185. A file in an operating system is:
- Option A: A collection of related records
- Option B: A named collection of related information
- Option C: A physical storage unit
- Option D: A system program
Show answerHide answer
Answer: B. A named collection of related information
186. A directory in a file system is:
- Option A: A file containing other files
- Option B: A special type of file that contains file names and pointers
- Option C: A physical location on disk
- Option D: A memory location
Show answerHide answer
Answer: B. A special type of file that contains file names and pointers
187. File allocation methods include:
- Option A: Contiguous, linked, and indexed allocation
- Option B: Sequential, random, and direct allocation
- Option C: Primary, secondary, and tertiary allocation
- Option D: Fixed, dynamic, and static allocation
Show answerHide answer
Answer: A. Contiguous, linked, and indexed allocation
188. Fragmentation in file systems refers to:
- Option A: Breaking a file into fragments
- Option B: Wasted space due to allocation methods
- Option C: Corrupted files
- Option D: File system errors
Show answerHide answer
Answer: B. Wasted space due to allocation methods
189. Which of the following is NOT a responsibility of a system administrator?
- Option A: User account management
- Option B: System startup and shutdown
- Option C: Application development
- Option D: Backup management
Show answerHide answer
Answer: C. Application development