← Legal Metrology

Past Questions — 2010

Legal Metrology • 2010 • Computer Science & Engineering Paper-II

The time required to search an element in a binary search tree having n elements is

A) O(1)
B) O(log2 n)
C) O(n)
D) O(n log2 n)
To determine the time complexity of searching for an element in a Binary Search Tree (BST), we must consider both the average case and the worst case. 1. **Average Case:** In a balanced BST (like an AVL tree or Red-Black tree), the height of the tree is O(log n). Searching for an element involves traversing from the root to a leaf, resulting in a time complexity of O(log n). 2. **Worst Case:** A standard BST does not guarantee balance. If elements are inserted in sorted or reverse-sorted order, the tree becomes 'skewed' (essentially becoming a linked list). In a skewed tree, the height of the tree is n. To find an element at the deepest leaf, the algorithm must visit every single node. 3. **Complexity Analysis:** In computer science, when a question asks for 'the time required' without specifying 'average case', it refers to the worst-case time complexity. Since the worst-case height of a BST is O(n), the search time is O(n). **Analysis of Options:** - **a. O(1):** This is the complexity for hash table lookups, not BSTs. - **b. O(log2 n):** This is the average case or the complexity for a *balanced* BST, but not for a general BST. - **c. O(n):** This is the correct worst-case time complexity for a general BST. - **d. O(n log2 n):** This is typical for sorting algorithms (like Merge Sort), not for searching a single element in a BST.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

In the following pair of addressing modes the first element refers to one having minimum operand fetching time and second one refers to the addressing mode with maximum operand fetching time; pick up the correct pair:

A) register direct and memory indirect
B) immediate and indexed indirect
C) register direct and indexed
D) immediate and Base-displacement
E) immediate and extended memory
To determine the operand fetching time, we must analyze the number of memory accesses required to retrieve the actual operand for each addressing mode. Memory access is significantly slower than register access. 1. **Minimum Fetching Time:** - **Immediate Addressing:** The operand is part of the instruction itself. No separate fetch is needed after the instruction is fetched. - **Register Direct Addressing:** The operand is stored in a CPU register. Accessing a register is the fastest possible way to retrieve data. - Between these two, Immediate is technically fastest (part of the instruction stream), but Register Direct is also extremely fast. Both are candidates for the 'minimum' side of the pair. 2. **Maximum Fetching Time:** - **Direct Addressing:** Requires 1 memory access. - **Indirect Addressing (Memory Indirect):** The instruction contains the address of a memory location, which in turn contains the address of the operand. This requires **two** memory accesses to get the operand. - **Indexed/Base-displacement:** Usually requires 1 memory access (after a quick ALU calculation). 3. **Evaluating the Options:** - **Option (a): Register Direct (Fast) and Memory Indirect (Slowest).** This pair correctly identifies a very fast mode and the slowest common mode (due to double memory indirection). - **Option (b): Immediate (Fast) and Indexed Indirect.** While Indexed Indirect is slow, 'Memory Indirect' is the classic textbook example of maximum latency in basic architecture questions. - **Option (c): Register Direct (Fast) and Indexed (Moderate).** Indexed is faster than Indirect. - **Option (d): Immediate (Fast) and Base-displacement (Moderate).** Base-displacement is faster than Indirect. - **Option (e): Immediate (Fast) and Extended Memory (Moderate).** Extended memory usually refers to a larger address space but still typically involves only one memory access per operand fetch. Conclusion: Memory Indirect requires the most memory references (two), making it the maximum fetching time mode. Register Direct (or Immediate) represents the minimum. Option (a) provides the most distinct contrast between the fastest and slowest mechanisms.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

What is the time complexity of linear search algorithm over an array of n elements?

A) O (log2 n)
B) O (n)
C) O (n log2 n)
D) O (n2 )
Linear search is the simplest searching algorithm. It works by starting at the first element of an array and comparing the target value with each element sequentially until a match is found or the end of the array is reached. 1. **Best Case Complexity**: O(1) - This occurs if the target element is the first element of the array. 2. **Worst Case Complexity**: O(n) - This occurs if the target element is the last element of the array or is not present at all. In this case, the algorithm must perform 'n' comparisons for an array of size 'n'. 3. **Average Case Complexity**: O(n) - On average, the element will be found in the middle (n/2), which simplifies to O(n) in Big O notation. Analysis of other options: - O(log2 n) is the complexity of Binary Search, which requires the array to be sorted. - O(n log2 n) is typical for efficient sorting algorithms like Merge Sort or Quick Sort. - O(n^2) is typical for simple sorting algorithms like Bubble Sort or Selection Sort.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

Which of the following statements is false?

A) Every tree is a bipartite graph
B) A tree contains a cycle
C) A tree with n nodes contains n-1 edges
D) A tree is a connected graph
In graph theory and data structures, a tree is defined as an undirected graph that is connected and acyclic. Let's evaluate each option: - Option (a): Every tree is a bipartite graph. This is TRUE. A bipartite graph is a graph whose vertices can be divided into two disjoint sets such that no two vertices within the same set are adjacent. Since a tree has no cycles (and specifically no odd-length cycles), it can always be 2-colored, making it bipartite. - Option (b): A tree contains a cycle. This is FALSE. By definition, a tree is an acyclic graph. If a graph contains a cycle, it cannot be a tree. - Option (c): A tree with n nodes contains n-1 edges. This is TRUE. This is a fundamental property of trees; any connected graph with n vertices and n-1 edges is necessarily a tree. - Option (d): A tree is a connected graph. This is TRUE. By definition, a tree must be connected. A collection of disjoint trees is called a 'forest'. Since the question asks for the FALSE statement, option (b) is the correct answer.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

A sort which uses the binary tree concept such that any number is larger than all the numbers in the subtree below it is called

A) selection sort
B) insertion sort
C) heap sort
D) quick sort
The question describes the fundamental property of a Max-Heap. A Heap is a specialized complete binary tree. In a Max-Heap, for any given node, the value of that node is greater than or equal to the values of its children (the subtree below it). Heap Sort utilizes this data structure by building a max-heap and repeatedly extracting the maximum element (the root) to sort the array. Why other options are incorrect: - a. Selection Sort: This is a comparison-based sort that repeatedly finds the minimum element from the unsorted part and puts it at the beginning. It does not use a tree structure. - b. Insertion Sort: This builds the final sorted array one item at a time by shifting elements. It does not use a tree structure. - d. Quick Sort: While Quick Sort uses a divide-and-conquer approach that can be visualized as a recursion tree, it does not maintain a binary tree where a parent is always larger than its subtree; it partitions elements based on a pivot.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

An undirected graph with n vertices and e edges are represented by Adjacency matrix. What is the time required to determine the degree of any vertex?

A) O(e)
B) O(n)
C) O(n2)
D) O(e+n)
1. Understanding the Data Structure: An adjacency matrix for a graph with 'n' vertices is a 2D array of size n x n. If there is an edge between vertex i and vertex j, the cell matrix[i][j] is set to 1 (or the weight of the edge); otherwise, it is 0. 2. Defining the Degree: In an undirected graph, the degree of a vertex is the total number of edges connected to it. 3. Process to find the Degree: To find the degree of a specific vertex 'v', we must examine the entire row (or column) corresponding to that vertex in the adjacency matrix. This involves checking every cell from matrix[v][0] to matrix[v][n-1]. 4. Time Complexity Analysis: Since there are 'n' columns in the row for vertex 'v', the algorithm must perform 'n' operations (checks/additions) to count the number of 1s. Therefore, the time complexity is proportional to the number of vertices, which is O(n). 5. Evaluating other options: - O(e): This would be the complexity if we were iterating through an edge list. - O(n²): This is the time required to find the degrees of ALL vertices or to initialize the matrix, not a single vertex. - O(e+n): This is typical for graph traversal (like BFS or DFS) using an adjacency list, not for finding a single vertex's degree in a matrix.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

What is the time required to search an element in a linked list of length n?

A) O (log2 n)
B) O (n)
C) O (1)
D) O (n2 )
In a linked list, elements are not stored in contiguous memory locations; instead, each node contains a pointer to the next node. Because there is no direct index-based access (unlike an array), the only way to search for a specific element is to perform a 'Linear Search'. This involves starting at the head node and traversing the list sequentially one node at a time until the target element is found or the end of the list is reached. In the worst-case scenario (where the element is at the very end of the list or not present at all), the algorithm must visit all 'n' nodes. Therefore, the time complexity is proportional to the number of elements, which is expressed in Big O notation as O(n). Why other options are incorrect: - O(log2 n): This is the complexity of a Binary Search. Binary search requires random access to the middle element, which is not possible in a standard linked list. - O(1): This is constant time. This would only be possible if we had a direct pointer to the element we were searching for. - O(n2): This is quadratic time, typically associated with nested loops (like Bubble Sort). Searching a list only requires a single pass.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

An indexing operation

A) sorts a file using a single key
B) sorts a file using two keys
C) establishes an i
Indexing establishes an index (or indexed organization) to allow fast access without sorting file.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

An instruction with an indexed operand having address field with all 0’s bit is effectively a

A) register indirect mode of operation
B) register direct mode of operation
C) memory indirect mode of operation
D) base-register addressing mode of operation
In indexed addressing mode, the effective address (EA) of the operand is calculated by adding the contents of an index register (X) to the address field (displacement/offset) provided in the instruction. The formula is: EA = Content of Index Register + Address Field. If the address field consists of all 0's bits, the formula becomes: EA = Content of Index Register + 0, which simplifies to EA = Content of Index Register. This means the instruction is using the value stored in the register as the memory address to access the operand. This is the definition of Register Indirect Addressing, where the register holds the pointer to the memory location of the operand. Why other options are incorrect: - b. Register Direct: In this mode, the operand itself is stored in the register, not at a memory address pointed to by the register. - c. Memory Indirect: This involves accessing memory twice (once for the address and once for the operand), which is not the case here. - d. Base-register addressing: While similar to indexed addressing, base-register addressing typically uses a base register to point to the start of a segment and a non-zero offset to find a specific element; if the offset is zero, it still functions as a register indirect access, but the specific mechanism described (indexed operand with 0 offset) is the classic definition of transforming indexed mode into register indirect mode.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

An instruction with two extended memory address operands using base register of length 12, number of operation codes 150, and 1M byte memory has a length of:

A) 32
B) 24
C) 16
D) 20
To determine the length of the instruction, we need to calculate the number of bits required for each component of the instruction: the opcode and the two memory address operands. 1. **Opcode bits**: The number of operation codes is 150. To represent 150 distinct operations, we need $\lceil \log_2(150) \rceil$ bits. Since $2^7 = 128$ and $2^8 = 256$, we need 8 bits for the opcode. 2. **Memory Address bits**: The memory size is 1M byte. $1\text{M} = 2^{20}$ bytes. Therefore, a full memory address requires 20 bits. 3. **Extended Memory Address (Displacement)**: The problem specifies the use of a base register of length 12 bits. In a base-displacement addressing mode, the effective address is calculated as: $\text{Effective Address} = \text{Base Register} + \text{Displacement}$. To reach any location in a 20-bit address space using a 12-bit base register, the displacement (the part stored in the instruction) must be able to cover the remaining range. $\text{Displacement bits} = \text{Total Address bits} - \text{Base Register bits} = 20 - 12 = 8$ bits. 4. **Total Instruction Length**: The instruction has two such extended memory address operands. $\text{Total Length} = \text{Opcode bits} + (2 \times \text{Displacement bits})$ $\text{Total Length} = 8 + (2 \times 8) = 8 + 16 = 24$ bits. **Correction/Re-evaluation based on standard exam interpretation**: In many competitive exam contexts for this specific question, 'extended memory address' is interpreted as the full address required to index the memory if the base register is used as a pointer to a segment or if the displacement is treated as the primary address component. However, if we look at the options provided (16, 20, 24, 32), and the standard architecture of such problems, if the 'extended' part implies the full address is needed or if the base register is used to offset a larger block, the calculation changes. If the instruction requires the full 12-bit base register reference (to select which base register to use) plus the displacement, or if the displacement itself is larger: Let's re-examine: If the 'base register of length 12' refers to the number of bits used to *address* the base register (i.e., $2^{12}$ base registers), then the displacement would be the full 20 bits. That would be too large. If the displacement is 12 bits (matching the base register length) and the opcode is 8 bits: $8 + 12 + 12 = 32$ bits. This matches option (a). In this interpretation, the 'base register of length 12' implies the offset/displacement field provided in the instruction is also 12 bits to complement the base register's scale. Given the options, the most logically consistent architectural fit for a 32-bit instruction is: Opcode (8 bits) + Operand 1 (12 bits) + Operand 2 (12 bits) = 32 bits.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

Recursive procedures are implemented by

A) Queues
B) Stacks
C) Linked lists
D) Strings
Recursion occurs when a function calls itself. To manage these nested calls, the computer must keep track of where to return after a function call completes, as well as the local variables and parameters for each specific call. This is handled by a system data structure called the 'Call Stack'. 1. When a recursive function is called, a new 'stack frame' (containing the return address, arguments, and local variables) is 'pushed' onto the stack. 2. This process continues until the base case is reached. 3. Once the base case is satisfied, the function begins to return, and the stack frames are 'popped' off the stack in Last-In-First-Out (LIFO) order, returning control to the previous call. Why other options are incorrect: - a. Queues: These follow First-In-First-Out (FIFO) logic, which would return the first call made before the most recent call, breaking the logic of nested recursion. - c. Linked lists: While a stack can be implemented using a linked list, a linked list itself is a general-purpose linear structure and not the specific mechanism used for procedure implementation. - d. Strings: These are sequences of characters used for text representation and have no mechanism for managing function execution flow.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

The goal of hashing is to produce a search that takes

A) O(1) time
B) O(n2) time
C) O(log n) time
D) O(n log n) time
Hashing is a technique used to uniquely identify a specific object from a group of similar objects using a hash function. The primary goal of hashing is to map a key to a specific index in a hash table such that the time required to insert, delete, or search for an element is independent of the number of elements (n) stored in the table. 1. **O(1) - Constant Time**: In an ideal scenario (with a good hash function and minimal collisions), the hash function computes the address of the data instantly, allowing for search operations to be performed in constant time, denoted as O(1). This is the fundamental objective of using a hash table over other data structures. 2. **O(log n) - Logarithmic Time**: This is the typical search time for balanced binary search trees (BSTs) or binary search on sorted arrays. Hashing aims to be faster than this. 3. **O(n log n)**: This is common for efficient sorting algorithms (like Merge Sort or Heap Sort), not for searching in a hash table. 4. **O(n²)**: This represents quadratic time, which is highly inefficient and typical of nested loops in simple algorithms (like Bubble Sort), not a search goal.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

A complete binary tree with the property that the value at each node is at least as large as the values at its children in known as

A) binary search tree
B) AVL-tree
C) completely balanced tree
D) heap
The question describes the fundamental properties of a Max-Heap. 1. **Structural Property**: The question specifies a 'complete binary tree'. A complete binary tree is one where every level, except possibly the last, is completely filled, and all nodes are as far left as possible. This is a requirement for a binary heap. 2. **Heap Property**: The condition that 'the value at each node is at least as large as the values at its children' is the definition of the Max-Heap property. In a Max-Heap, for any given node I, the value of I is greater than or equal to the values of its children. Why other options are incorrect: - **a. binary search tree**: In a BST, the left child must be smaller than the parent, and the right child must be larger. It does not require the tree to be complete, nor does it require the parent to be larger than both children. - **b. AVL-tree**: An AVL tree is a self-balancing binary search tree. While it maintains a height balance, it follows BST ordering rules, not the heap property. - **c. completely balanced tree**: This refers to the structural balance of a tree (where the heights of subtrees differ by at most 1), but it does not define a specific relationship between the values of parents and children.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

Consider that n elements are to be sorted. What is the worst case time complexity of Bubble sort?

A) O(1)
B) O(log2 n)
C) O(n)
D) O(n2)
Bubble Sort is a simple comparison-based sorting algorithm. It works by repeatedly stepping through the list, comparing adjacent elements and swapping them if they are in the wrong order. 1. **Mechanism**: In the first pass, the algorithm performs (n-1) comparisons to move the largest element to the end of the list. In the second pass, it performs (n-2) comparisons, and so on. 2. **Worst-Case Scenario**: The worst case occurs when the input array is sorted in reverse order. In this scenario, the algorithm must perform the maximum number of comparisons and swaps for every single pass. 3. **Mathematical Calculation**: The total number of comparisons is the sum of the first (n-1) integers: (n-1) + (n-2) + ... + 1 = [n(n-1)] / 2. 4. **Complexity**: Expanding this gives (n^2 - n) / 2. In Big O notation, we drop constant coefficients and lower-order terms, resulting in a time complexity of O(n^2). Analysis of other options: - O(1) represents constant time, which is impossible for sorting n elements. - O(log2 n) represents logarithmic time, typically seen in binary search, not sorting. - O(n) represents linear time, which is the best-case complexity for an optimized Bubble Sort (when the array is already sorted), but not the worst case.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as

A) queues
B) stacks
C) tree
D) deque
The question describes a data structure that follows the First-In-First-Out (FIFO) principle. 1. **Queues**: A queue is a linear data structure where elements are inserted at one end (called the 'rear' or 'tail') and removed from the other end (called the 'front' or 'head'). This matches the description perfectly. 2. **Stacks**: A stack follows the Last-In-First-Out (LIFO) principle. Both insertion (push) and deletion (pop) occur at the same end, known as the 'top'. 3. **Tree**: A tree is a non-linear, hierarchical data structure, not a linear list. 4. **Deque (Double-Ended Queue)**: A deque allows insertion and deletion from both the front and the rear ends, which is more flexible than the specific restriction described in the question.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

Which of the following sorting procedure is the slowest?

A) Quick sort
B) Heap sort
C) Shell sort
D) Bubble sort
To determine which sorting procedure is the slowest, we compare their time complexities (specifically the average and worst-case scenarios): 1. **Bubble Sort (Option d):** It is a simple comparison-based algorithm with a worst-case and average-case time complexity of O(n²). It repeatedly steps through the list, compares adjacent elements, and swaps them if they are in the wrong order. This makes it highly inefficient for large datasets. 2. **Quick Sort (Option a):** It uses a divide-and-conquer strategy. Its average-case time complexity is O(n log n), which is significantly faster than O(n²). Although its worst-case is O(n²), it is practically one of the fastest sorting algorithms. 3. **Heap Sort (Option b):** It uses a binary heap data structure. It guarantees a worst-case and average-case time complexity of O(n log n), making it consistently faster than Bubble Sort. 4. **Shell Sort (Option c):** It is an optimization of insertion sort. Its complexity depends on the gap sequence used, but it generally ranges from O(n log n) to O(n^1.5) or O(n²). In almost all practical implementations, it outperforms Bubble Sort. Comparing O(n log n) and O(n²) for large values of n, O(n²) grows much faster, meaning the algorithm takes more time. Therefore, Bubble Sort is the slowest among the given options.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

One of the most popular addressing schemes is Base-displacement addressing mode because it has the power of:

A) preindexed register indirect mode
B) postindexed register indirect mode
C) program relocatability
D) addressing an N-word memory with an address field having length less than log2 N bits
E) both (c) and (d) are true
Base-displacement addressing mode (also known as Base-Offset addressing) calculates the effective address by adding a constant value (displacement) to the contents of a base register. 1. **Program Relocatability (Option c):** This is a primary advantage of base-displacement addressing. Because the program refers to memory locations relative to a base register rather than using absolute addresses, the entire program can be loaded into any part of the physical memory. The OS only needs to update the base register to point to the start of the allocated memory block, making the code 'relocatable'. 2. **Addressing Large Memory with Small Fields (Option d):** In an N-word memory, a direct address would require log2(N) bits. However, by using a base register to hold the high-order bits of the address and a small displacement field in the instruction for the low-order bits, the instruction length can be significantly reduced. This allows the CPU to address a large memory space without requiring a massive address field in every single instruction. Since both (c) and (d) are fundamental strengths of this addressing mode, option (e) is the correct choice.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

A list of data items usually words or bytes, with the accessing restriction that elements can be added or removed at one end of the list only, is known as

A) stack
B) memory
C) linked list
D) heap
The question describes a linear data structure with a specific access restriction: elements can only be added (pushed) or removed (popped) from one end. This is the fundamental definition of a Stack, which follows the LIFO (Last-In, First-Out) principle. Analysis of options: - a. Stack: Correct. It restricts insertion and deletion to a single end called the 'top'. - b. Memory: Incorrect. Memory refers to the physical or virtual storage space (RAM) where data is kept, not a specific logical data structure with access restrictions. - c. Linked List: Incorrect. A linked list is a general linear collection of nodes where elements can typically be added or removed from both ends or any position in the list, provided the pointer is known. - d. Heap: Incorrect. A heap is a specialized tree-based data structure that satisfies the heap property (max-heap or min-heap). While it has specific rules for insertion and deletion to maintain its structure, it does not restrict access to a single 'end' in the linear sense described.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

A database management system

A) allows simultaneous access to multiple files
B) can do more than a record management system
C) is a collection of programs for managing data in a single file
D) both (a) and (b)
Step-by-step analysis of the options: 1. **Option (a): 'allows simultaneous access to multiple files'** - This is correct. A DBMS provides concurrency control mechanisms that allow multiple users or applications to access and modify data stored across various files/tables simultaneously without compromising data integrity. 2. **Option (b): 'can do more than a record management system'** - This is correct. A Record Management System (RMS) or a traditional File Processing System is limited to basic CRUD operations on individual files. A DBMS adds sophisticated layers such as data independence, transaction management (ACID properties), complex querying (SQL), security, and relationship management between different data entities. 3. **Option (c): 'is a collection of programs for managing data in a single file'** - This is incorrect. A DBMS is designed to manage large volumes of data that are typically spread across multiple files, tables, and indices. Limiting it to a 'single file' describes a simple flat-file system, not a full DBMS. Since both (a) and (b) are accurate descriptions of the capabilities and nature of a Database Management System, the correct choice is (d).
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

A linear list in which elements can be added or removed at either end but not in the middle, is known as

A) queue
B) deque
C) stack
D) tree
The question describes a data structure that allows insertion and deletion at both the front and the rear ends. 1. **Deque (Double-Ended Queue):** By definition, a deque is a generalized version of a queue that allows elements to be added or removed from either the front or the back. This matches the description perfectly. 2. **Queue:** A standard queue follows the FIFO (First-In-First-Out) principle, where elements are added at the rear and removed from the front. It does not allow operations at both ends for both addition and removal. 3. **Stack:** A stack follows the LIFO (Last-In-First-Out) principle, where all insertions and deletions occur at only one end (the top). 4. **Tree:** A tree is a non-linear, hierarchical data structure, not a linear list. Therefore, the correct answer is 'deque'.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

The time required to find shortest path in a graph with n vertices and e edges is

A) O(e)
B) O(n)
C) O(e2)
D) O(n2)
The question asks for the time complexity to find the shortest path in a graph with n vertices and e edges. In the context of standard competitive exams for CSE, this typically refers to the Single Source Shortest Path (SSSP) problem using Dijkstra's Algorithm. 1. Dijkstra's Algorithm using a simple array (linear search for the minimum distance vertex) has a time complexity of O(n^2). This is the most basic implementation and is optimal for dense graphs where e is close to n^2. 2. Dijkstra's Algorithm using a Binary Heap has a complexity of O(e log n). 3. Dijkstra's Algorithm using a Fibonacci Heap has a complexity of O(e + n log n). Looking at the provided options: - O(e) and O(n) are too low for general shortest path algorithms. - O(e^2) is not a standard complexity for these algorithms. - O(n^2) is the standard complexity for the basic implementation of Dijkstra's algorithm. While O(e log n) is often more efficient for sparse graphs, among the given choices, O(n^2) is the only mathematically recognized complexity for a standard shortest path algorithm (Dijkstra's) implementation.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

A full binary tree with n leaves contains

A) n nodes
B) log2 n nodes
C) 2n-1 nodes
D) 2n nodes
In a full binary tree (also known as a proper or plane binary tree), every node has either 0 or 2 children. Let 'n' be the number of leaf nodes and 'i' be the number of internal nodes. 1. Total number of nodes (N) = i + n. 2. In any binary tree, the number of edges is N - 1. 3. In a full binary tree, every internal node has exactly 2 children, so the total number of edges is also 2 * i. 4. Therefore, 2i = N - 1. 5. Substituting N = i + n into the equation: 2i = (i + n) - 1. 6. Solving for i: i = n - 1. 7. Now, substitute i back into the total nodes equation: N = (n - 1) + n = 2n - 1. Example: If a full binary tree has 3 leaves (n=3), it must have 2 internal nodes (i=2), totaling 5 nodes (2*3 - 1 = 5).
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

A sort which compares adjacent elements in a list and switches where necessary is a

A) insertion sort
B) heap sort
C) quick sort
D) bubble sort
The question describes the fundamental mechanism of the Bubble Sort algorithm. 1. **Bubble Sort**: This algorithm works by repeatedly stepping through the list, comparing each pair of adjacent elements, and swapping them if they are in the wrong order (e.g., if the left element is greater than the right element in an ascending sort). This process is repeated until the largest element 'bubbles up' to its correct position at the end of the list. 2. **Why other options are incorrect**: - **Insertion Sort (a)**: This algorithm builds the final sorted array one item at a time by taking an element and inserting it into its correct position among the already-sorted elements. It does not simply swap adjacent elements throughout the list. - **Heap Sort (b)**: This is a comparison-based sorting technique based on a Binary Heap data structure. It involves building a max-heap and repeatedly extracting the maximum element; it does not rely on adjacent element comparisons. - **Quick Sort (c)**: This is a divide-and-conquer algorithm that picks an element as a 'pivot' and partitions the given array around the picked pivot. While it involves swapping, it is not limited to adjacent elements.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

Which of the following best describes sorting?

A) Accessing and processing each record exactly once
B) Finding the location of the record with a given key
C) Arranging the data (record) in some given order
D) Adding a new record to the data structure
Sorting is a fundamental operation in computer science and algorithms defined as the process of rearranging a collection of items (data or records) into a specific logical order. This order is typically either numerical (ascending or descending) or lexicographical (alphabetical). Analysis of options: - Option (a) 'Accessing and processing each record exactly once' describes a linear traversal or a single-pass algorithm, not sorting. - Option (b) 'Finding the location of the record with a given key' describes the process of Searching (e.g., Binary Search or Linear Search). - Option (c) 'Arranging the data (record) in some given order' is the precise definition of Sorting. - Option (d) 'Adding a new record to the data structure' describes the Insertion operation.
Legal Metrology • 2010 • Computer Science & Engineering Paper-II

If each node in a tree has value greater than every value in its left subtree and has value less than every value in its right subtree, the tree is known as

A) complete tree
B) full binary tree
C) binary search tree
D) threaded tree
The question describes the fundamental property of a Binary Search Tree (BST). In a BST, for any given node: 1. All nodes in its left subtree must have values strictly less than the node's value. 2. All nodes in its right subtree must have values strictly greater than the node's value. This property allows for efficient searching, insertion, and deletion operations, typically achieving O(log n) time complexity in balanced trees. Why other options are incorrect: - a. Complete Tree: A complete binary tree is defined by its structure (every level is filled except possibly the last, which is filled from left to right), not by the values of its nodes. - b. Full Binary Tree: A full binary tree is one where every node has either 0 or 2 children. This is a structural property and does not dictate the ordering of values. - d. Threaded Tree: A threaded binary tree is a binary tree where null pointers are replaced by 'threads' to the in-order predecessor or successor to facilitate easier traversal. This is an implementation detail for traversal, not a value-ordering property.