Computer Science Test 8 Nddc Scholarship
Computer Science Test 8 Nddc Scholarship
Question 61
Slow sorting algorithms, such as Bubble Sort or Selection Sort, typically have a worst-case running time in the order of:
In computational complexity, 'slow' sorting algorithms are those that use nested loops to compare elements, resulting in a quadratic time complexity of \(O(n^2)\). This means that if the number of elements doubles, the time taken to sort them increases by fourfold. While efficient algorithms like Mergesort run in \(O(n \log n)\), these simpler algorithms are considered slow for large datasets because their execution time grows too rapidly as \(n\) increases.
Not clear enough?
Question 62
In the analysis of the Selection algorithm using the sieve technique, what is the maximum number of recursive passes or phases that might be required?
When using a sieve-based selection algorithm (like Quickselect), the problem size is reduced by a constant fraction in each phase. If we successfully eliminate half of the elements in each pass, the number of steps follows a logarithmic pattern relative to the total number of elements. Specifically, the total work is the sum of a geometric series starting from \(n\). While the 'work' is linear, the number of distinct recursive levels or phases is proportional to \(\log n\). However, in many academic contexts relating specifically to the reduction steps of the sieve, \(T(n/2)\) represents the recursive sub-problem call.
Not clear enough?
Question 63
The sieve technique is considered a special case of algorithmic design where the number of sub-problems generated in each step is exactly:
The sieve technique (often associated with 'Decrease and Conquer') is unique because, unlike Divide and Conquer which splits a problem into multiple sub-problems (like Mergesort's 2 sub-problems), the sieve technique reduces the problem to only '1' sub-problem of smaller size. By identifying and discarding a portion of the data that cannot contain the solution, the algorithm only needs to recurse on the remaining single subset, making it highly efficient.
Not clear enough?
Question 64
In which order can standard sorting algorithms arrange data?
Sorting is the process of arranging elements in a systematic order. Depending on the requirements, data can be sorted in 'increasing order' (ascending, e.g., 1, 2, 3) or 'decreasing order' (descending, e.g., 3, 2, 1). Most sorting algorithms are flexible; by simply reversing the comparison logic (changing a 'less than' to a 'greater than' check), the same algorithm can produce either order.
Not clear enough?
Question 65
The mathematical analysis of the Selection algorithm (like finding the median) results in a total work summation that looks like:
In a successful selection phase, we perform \(n\) work to partition and then move to a sub-problem of size \(n/2\). The total time is expressed as the sum of work across all levels: \[ T(n) = n + \frac{n}{2} + \frac{n}{4} + ... \] This is represented as the current work (\(n\)) plus the work of the subsequent sub-problems (starting with \(n/2\)). The sum of this infinite geometric series converges to \(2n\), which proves the algorithm is linear in time complexity.
Not clear enough?
Question 66
The analysis of the Selection algorithm demonstrates that the total running time is effectively __________ in terms of \(n\):
Although the work in each phase of the Selection algorithm forms a geometric series (\(n, n/2, n/4, ...\)), the sum of that series results in a value proportional to \(n\) (specifically \(2n\)). In Big-O notation, any function where the highest power of \(n\) is 1 is classified as 'linear'. This is the ideal complexity for a selection problem because it means the time taken grows at the same rate as the input size.
Not clear enough?
Question 67
In an idealised Analysis of the Selection algorithm (Sieve Technique), how many elements do we aim to eliminate in each phase?
The most efficient sieve-based selection algorithms, such as those using a median-of-medians or an ideal pivot, aim to eliminate a constant fraction of the dataset. Eliminating 'n / 2' elements (half the remaining array) in each step is the standard theoretical model. This ensures that the problem size decreases rapidly, leading to the convergent geometric series that allows for a linear total running time.
Not clear enough?
Question 68
For the heap sort, when we store the tree nodes in an array, they are placed in the order of a:
To store a complete binary tree in an array without pointers, nodes are mapped to indices based on their position in a 'level-order traversal' (also known as Breadth-First Search). The root is at index 0, its children are at indices 1 and 2, and so on, level by level from left to right. This specific traversal ensures that there are no 'gaps' in the array, making memory usage perfectly efficient for complete trees.
Not clear enough?
Question 69
One of the clever aspects of heaps is that they can be stored in arrays without using any _______________.
Unlike standard linked binary trees that require 'pointers' (memory addresses) to link a parent node to its left and right children, a heap uses simple arithmetic to navigate. Because the heap is a complete binary tree, the position of any node's children or parent can be calculated using its index. This removes the memory overhead of storing pointers and makes the data structure more cache-friendly and compact.
Not clear enough?
Question 70
What is the time complexity of the Merge Sort algorithm for an array of \(n\) numbers?
Merge Sort is a highly efficient, comparison-based sorting algorithm. It consistently divides the array in half (logarithmic number of divisions) and then performs a linear-time merge operation at each level. Mathematically, this is represented by the recurrence \(T(n) = 2T(n/2) + n\). According to the Master Theorem, this results in a total time complexity of \(O(n \log n)\) in all cases (worst, average, and best).
Not clear enough?
You might like
This question is based on Literary Appreciation.
"Cliph... Son. Open all your ears. May Allah grant us the fortitude to accept his commands. Now the rest is my burden. I am willing to accept Allah's will in the matter."
The language of the speaker above is:
A tank has two pipes. The first pipe can fill it in 4 hours and the second can empty it in 16 hours. If two pipes be opened together at a time, then the tank will be filled in ?
