Introduction to limits and behaviour of logic
Easy
A.Its number of variables
B.Its behavior near a point
C.Its value at every input
D.Its largest possible output
Correct Answer: Its behavior near a point
Explanation:
A limit describes how a function behaves as its input approaches a particular value.
Incorrect! Try again.
2In algorithm analysis, what does asymptotic behavior mainly describe?
Introduction to limits and behaviour of logic
Easy
A.The number of comments written
B.The programming language used
C.Performance for small inputs
D.Performance for large inputs
Correct Answer: Performance for large inputs
Explanation:
Asymptotic behavior focuses on how an algorithm performs as the input size becomes very large.
Incorrect! Try again.
3Which notation commonly represents an upper bound on an algorithm's growth rate?
Introduction to limits and behaviour of logic
Easy
A. notation
B. notation
C. notation
D. notation
Correct Answer: notation
Explanation:
notation expresses an asymptotic upper bound on an algorithm's growth rate.
Incorrect! Try again.
4What happens to the importance of constant operations as input size grows?
Introduction to limits and behaviour of logic
Easy
A.They become more important
B.They remain the main factor
C.They determine the input size
D.They become less important
Correct Answer: They become less important
Explanation:
For large inputs, the growth rate of the algorithm usually matters more than constant factors.
Incorrect! Try again.
5What does worst-case analysis measure?
Understanding taxonomy in worst case
Easy
A.The maximum resources required
B.The minimum resources required
C.The average resources required
D.The unused resources available
Correct Answer: The maximum resources required
Explanation:
Worst-case analysis measures the maximum time or space an algorithm may need for inputs of a given size.
Incorrect! Try again.
6Which complexity class generally grows more slowly?
Understanding taxonomy in worst case
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
Linear complexity, , grows more slowly than quadratic, exponential, and factorial complexity.
Incorrect! Try again.
7What is the worst-case time complexity of accessing an element by index in an array?
Understanding taxonomy in worst case
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
Array indexing directly calculates the memory location, so it takes constant time, .
Incorrect! Try again.
8Which notation represents a tight asymptotic bound?
Understanding taxonomy in worst case
Easy
A. notation
B. notation
C. notation
D. notation
Correct Answer: notation
Explanation:
notation describes both an asymptotic upper bound and a lower bound.
Incorrect! Try again.
9What is the worst-case time complexity of a linear search in an unsorted array?
Understanding taxonomy in worst case
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
In the worst case, linear search checks every element, giving a time complexity of .
Incorrect! Try again.
10What does the effectiveness of an algorithm mainly refer to?
Analysing the effectiveness and efficiency of algorithms
Easy
A.Having the shortest code
B.Producing the correct result
C.Using the newest hardware
D.Using the most variables
Correct Answer: Producing the correct result
Explanation:
An effective algorithm solves the intended problem and produces the correct output.
Incorrect! Try again.
11What does the efficiency of an algorithm mainly measure?
Analysing the effectiveness and efficiency of algorithms
Easy
A.Its resource usage
B.Its documentation style
C.Its variable names
D.Its output format
Correct Answer: Its resource usage
Explanation:
Efficiency concerns how much time and memory an algorithm uses while solving a problem.
Incorrect! Try again.
12Two algorithms solve the same problem correctly. Which one is generally more efficient?
Analysing the effectiveness and efficiency of algorithms
Easy
A.The one using more steps
B.The one using fewer resources
C.The one using more memory
D.The one containing more code
Correct Answer: The one using fewer resources
Explanation:
When correctness is equal, an algorithm using less time or memory is generally considered more efficient.
Incorrect! Try again.
13Why are algorithms analyzed before implementation?
Analysing the effectiveness and efficiency of algorithms
Easy
A.To avoid writing any code
B.To remove all input values
C.To choose better variable names
D.To estimate resource requirements
Correct Answer: To estimate resource requirements
Explanation:
Analysis helps estimate time and space requirements before the algorithm is implemented.
Incorrect! Try again.
14Which factor is most important when comparing algorithm efficiency for large inputs?
Analysing the effectiveness and efficiency of algorithms
Easy
A.The growth rate
B.The screen size
C.The number of comments
D.The file name
Correct Answer: The growth rate
Explanation:
The growth rate shows how resource usage changes as the input size increases.
Incorrect! Try again.
15What does time complexity measure?
Measuring time and space complexity of algorithm
Easy
A.The growth of running steps
B.The size of the source file
C.The clock time on one machine
D.The number of output lines
Correct Answer: The growth of running steps
Explanation:
Time complexity describes how the number of operations grows with the input size.
Incorrect! Try again.
16What does space complexity measure?
Measuring time and space complexity of algorithm
Easy
A.The input's numerical value
B.The execution speed only
C.The number of program functions
D.The memory used by an algorithm
Correct Answer: The memory used by an algorithm
Explanation:
Space complexity measures the memory required by an algorithm as the input size changes.
Incorrect! Try again.
17What is the time complexity of a loop that runs exactly times?
Measuring time and space complexity of algorithm
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
A loop that performs one constant-time operation times has linear time complexity, .
Incorrect! Try again.
18What is the time complexity of two separate nested loops, each running times?
Measuring time and space complexity of algorithm
Easy
A.
B.
C.
D.
Correct Answer:
Explanation:
The inner loop runs times for each of the outer-loop iterations, resulting in operations.
Incorrect! Try again.
19What is an algorithmic trade-off?
Trade-off concept
Easy
A.Removing all resource requirements
B.Improving one resource while affecting another
C.Ignoring the algorithm's output
D.Using identical algorithms everywhere
Correct Answer: Improving one resource while affecting another
Explanation:
A trade-off occurs when improving one aspect, such as speed, causes a change in another, such as memory usage.
Incorrect! Try again.
20What does a time-space trade-off usually mean?
Trade-off concept
Easy
A.Using hardware to change correctness
B.Using less memory to remove output
C.Using more time to reduce input
D.Using memory to reduce running time
Correct Answer: Using memory to reduce running time
Explanation:
A time-space trade-off often uses extra memory, such as a lookup table, to make an algorithm run faster.
Incorrect! Try again.
21For and , what does imply?
Introduction to limits and behaviour of logic
Medium
A. grows asymptotically slower than
B. and have identical growth
C. grows asymptotically faster than
D. eventually becomes equal to
Correct Answer: grows asymptotically slower than
Explanation:
Since the ratio approaches , becomes negligible relative to . Thus, .
Incorrect! Try again.
22An algorithm repeatedly replaces by until . Which expression best describes the number of repetitions?
Introduction to limits and behaviour of logic
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
After repetitions, the value is . Reaching a value below requires proportional to .
Incorrect! Try again.
23Suppose and . What is ?
Introduction to limits and behaviour of logic
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
Dividing by gives . The second term approaches , so the limit is .
Incorrect! Try again.
24A condition is evaluated as x != 0 && 100 / x > 5 using short-circuit logic. What happens when ?
Introduction to limits and behaviour of logic
Medium
A.Both conditions are evaluated and the result is false
B.The expression causes division by zero before comparison
C.The second condition is skipped, avoiding division by zero
D.The second condition is evaluated before the first condition
Correct Answer: The second condition is skipped, avoiding division by zero
Explanation:
For logical AND, evaluation stops when the first operand is false. Since x != 0 is false, 100 / x is not evaluated.
Incorrect! Try again.
25Which statement correctly interprets a worst-case bound of for an algorithm?
Understanding taxonomy in worst case
Medium
A.Its average running time must grow at the same rate as
B.Its running time is exactly operations for every possible input
C.Its running time is eventually bounded below by a constant times
D.Its running time is eventually bounded above by a constant times
Correct Answer: Its running time is eventually bounded above by a constant times
Explanation:
Big-O gives an asymptotic upper bound. It does not require the running time to equal that bound for every input.
Incorrect! Try again.
26Insertion sort is applied to an array of distinct values. Which input arrangement produces its worst-case running time?
Understanding taxonomy in worst case
Medium
A.Values arranged in descending order
B.Values arranged in ascending order
C.Values arranged in cyclic order
D.Values arranged with one inversion
Correct Answer: Values arranged in descending order
Explanation:
In descending order, each new value must be compared with and shifted past all previously processed values, producing work.
Incorrect! Try again.
27An algorithm has worst-case complexity and best-case complexity . Which claim is valid for all inputs of size ?
Understanding taxonomy in worst case
Medium
A.The running time is always
B.The running time is
C.The running time is
D.The running time is always
Correct Answer: The running time is
Explanation:
The worst-case bound limits the running time of every input of size from above by .
Incorrect! Try again.
28Binary search is performed on a sorted array of elements. What is the maximum number of element comparisons under the standard midpoint implementation?
Understanding taxonomy in worst case
Medium
A. comparisons
B. comparisons
C. comparisons
D. comparisons
Correct Answer: comparisons
Explanation:
A balanced search over elements has five levels, so the worst case requires comparisons.
Incorrect! Try again.
29Algorithm A takes operations, while Algorithm B takes operations. Ignoring machine effects, for which listed input size is Algorithm A more efficient?
Analysing the effectiveness and efficiency of algorithms
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
Algorithm A is better when , which simplifies to . Among the choices, only satisfies this condition.
Incorrect! Try again.
30Two sorting algorithms have the same time complexity, but Algorithm X performs fewer comparisons and uses the same memory as Algorithm Y. What is the most justified conclusion?
Analysing the effectiveness and efficiency of algorithms
Medium
A.Algorithm X may be faster while having the same asymptotic efficiency
B.Algorithm Y must become faster for every sufficiently large input
C.Algorithm Y is more effective because it performs more comparisons
D.Algorithm X must belong to a lower asymptotic complexity class
Correct Answer: Algorithm X may be faster while having the same asymptotic efficiency
Explanation:
Asymptotic notation ignores constant factors. Fewer comparisons can improve actual running time without changing the classification.
Incorrect! Try again.
31An algorithm runs quickly but sometimes returns an incorrect result. How should it be evaluated?
Analysing the effectiveness and efficiency of algorithms
Medium
A.It is efficient but not fully effective
B.It is neither measurable nor analysable
C.It is effective but not fully efficient
D.It is both effective and efficient
Correct Answer: It is efficient but not fully effective
Explanation:
Efficiency concerns resource use, while effectiveness requires solving the problem correctly. Fast execution does not compensate for incorrect results.
Incorrect! Try again.
32Algorithm P requires operations, while Algorithm Q requires operations. Which algorithm is generally more scalable for sufficiently large ?
Analysing the effectiveness and efficiency of algorithms
Medium
A.Algorithm P, because it has a smaller exponent
B.Algorithm Q, because polynomial growth is slower
C.Algorithm P, because exponential growth is slower
D.Algorithm Q, because cubic growth is constant
Correct Answer: Algorithm Q, because polynomial growth is slower
Explanation:
Although either algorithm may be faster for small inputs, eventually grows faster than any fixed-degree polynomial such as .
Incorrect! Try again.
33What is the time complexity of the following loop?
for i = 1 to n:
for j = 1 to i:
perform_constant_work()
Measuring time and space complexity of algorithm
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
The total work is , which grows as .
Incorrect! Try again.
34An algorithm first executes a loop and then executes a separate loop. What is its total time complexity?
Measuring time and space complexity of algorithm
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
Sequential costs are added. Since grows faster than , the sum is dominated by .
Incorrect! Try again.
35A recursive function makes one call on input size and stores a constant amount of local data per call. What is its auxiliary space complexity if recursion reaches ?
Measuring time and space complexity of algorithm
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
The call stack contains active calls at maximum depth, and each call uses constant additional space.
Incorrect! Try again.
36A loop starts with and updates after each iteration until . What is its time complexity?
Measuring time and space complexity of algorithm
Medium
A.
B.
C.
D.
Correct Answer:
Explanation:
After iterations, . The loop ends when , so is proportional to .
Incorrect! Try again.
37A recursive solution recalculates the same subproblems many times. Memoization is added. What trade-off is being made?
Trade-off concept
Medium
A.Additional execution time is used to reduce memory
B.Additional memory is used to reduce execution time
C.Lower accuracy is accepted to improve execution time
D.Higher input size is accepted to improve correctness
Correct Answer: Additional memory is used to reduce execution time
Explanation:
Memoization stores previously computed results. This increases space usage but avoids repeated calculations and usually reduces running time.
Incorrect! Try again.
38A program replaces repeated linear searches in a list with lookups in a hash table. What is the primary expected trade-off?
Trade-off concept
Medium
A.Slower average lookup with lower memory usage
B.Faster average lookup with greater memory usage
C.Faster worst-case lookup with no extra memory
D.Slower worst-case lookup with greater accuracy
Correct Answer: Faster average lookup with greater memory usage
Explanation:
A hash table typically provides average lookup instead of linear search, but it requires extra storage for its table structure.
Incorrect! Try again.
39A large file is compressed before being sent through a slow network. Under which condition is compression most likely to reduce the total completion time?
Trade-off concept
Medium
A.Decompression requires more space than the original file
B.Compression time is less than the transmission time saved
C.Compressed and original files require equal transmission time
D.Compression time is greater than the original transmission time
Correct Answer: Compression time is less than the transmission time saved
Explanation:
Compression is beneficial when its processing overhead is smaller than the reduction in network transmission time.
Incorrect! Try again.
40A stable merge sort and an in-place heap sort both take time. Which requirement most strongly favors heap sort?
Trade-off concept
Medium
A.Optimizing nearly sorted input
B.Supporting sequential disk access
C.Preserving the order of equal keys
D.Minimizing auxiliary memory usage
Correct Answer: Minimizing auxiliary memory usage
Explanation:
Heap sort can operate with auxiliary array space, whereas standard merge sort requires additional space. Heap sort is generally not stable.
Incorrect! Try again.
41Let and be positive functions for sufficiently large . Which statement about the limit is correct?
Introduction to limits and behaviour of logic
Hard
A.If the limit does not exist, the functions are incomparable
B.If , then
C.If , then
D.If , then
Correct Answer: If , then
Explanation:
A finite positive ratio bounds above and below by positive constants for sufficiently large , establishing .
Incorrect! Try again.
42Suppose and . Which asymptotic conclusion is valid?
Introduction to limits and behaviour of logic
Hard
A. because the multiplier exceeds one
B. and are asymptotically incomparable
C. although the ratio has no limit
D. because the sine term oscillates
Correct Answer: although the ratio has no limit
Explanation:
Since , the function is bounded between and . A ratio limit is sufficient but not necessary for a bound.
Incorrect! Try again.
43For positive functions and , assume . Which conclusion follows directly?
Introduction to limits and behaviour of logic
Hard
A. and therefore
B. but not
C. but not
D. and therefore
Correct Answer: and therefore
Explanation:
A ratio tending to zero is the definition of strict asymptotic domination: . Every little- relationship also implies the corresponding big- relationship.
Incorrect! Try again.
44Let for sufficiently large . How does compare asymptotically with ?
Introduction to limits and behaviour of logic
Hard
A. because the exponent averages to one
B. but
C. is neither nor
D. but
Correct Answer: is neither nor
Explanation:
The ratio becomes arbitrarily large along some subsequences and arbitrarily small along others, so neither one-sided bound holds.
Incorrect! Try again.
45An algorithm's worst-case running time is known to satisfy and . What is the strongest justified classification?
Understanding taxonomy in worst case
Hard
A.
B. lies between the two bounds but need not match either
C. must alternate between linearithmic and quadratic time
D.
Correct Answer: lies between the two bounds but need not match either
Explanation:
The upper and lower bounds are not tight enough to establish a class. For example, satisfies both stated bounds.
Incorrect! Try again.
46A deterministic quicksort implementation always chooses the first array element as its pivot. Which statement correctly characterizes its worst case on arrays of distinct keys?
Understanding taxonomy in worst case
Hard
A.It is because every level performs quadratic work
B.It is because each partition creates two recursive calls
C.It is because partitions can have sizes and
D.It is because each partition is linear
Correct Answer: It is because partitions can have sizes and
Explanation:
Sorted or reverse-sorted input produces the recurrence , whose sum is .
Incorrect! Try again.
47A dynamic program runs in time, where is a positive integer supplied in binary. Which interpretation is most accurate?
Understanding taxonomy in worst case
Hard
A.It is pseudopolynomial and may be exponential in the encoding length of
B.It is logarithmic in because binary encoding uses bits
C.It is polynomial in the total bit length because is an input
D.It is strongly polynomial because the running time contains two parameters
Correct Answer: It is pseudopolynomial and may be exponential in the encoding length of
Explanation:
Binary encoding uses bits, while the algorithm depends on the numeric value . Thus can be exponential in the input's bit length.
Incorrect! Try again.
48For every input of size , an algorithm executes exactly one of two feasible branches. Their tight worst-case costs are and . What is the overall tight worst-case cost?
Understanding taxonomy in worst case
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
Only one branch runs on an input, while worst-case analysis selects an input reaching the more expensive feasible branch. The result is the maximum, not the sum.
Incorrect! Try again.
49Algorithm A uses primitive operations, while Algorithm B uses operations. Both are correct. What can be concluded about their practical running times for inputs up to a fixed limit ?
Analysing the effectiveness and efficiency of algorithms
Hard
A.Their ordering requires a cost model or measurement over the target range
B.A is always faster because its asymptotic class is smaller
C.B is always faster because its leading constant is smaller
D.Their running times are equal when both process the same input
Correct Answer: Their ordering requires a cost model or measurement over the target range
Explanation:
Asymptotic growth predicts eventual behavior, not performance over every finite range. Constants, operation costs, hardware, and the value of affect the practical crossover.
Incorrect! Try again.
50A procedure returns a correct answer whenever it terminates, but on some valid inputs it loops forever. Which property does it possess?
Analysing the effectiveness and efficiency of algorithms
Hard
A.Termination correctness but not functional correctness
B.Asymptotic correctness but not semantic correctness
C.Partial correctness but not total correctness
D.Total correctness but not partial correctness
Correct Answer: Partial correctness but not total correctness
Explanation:
Partial correctness guarantees that any returned result is correct. Total correctness additionally requires termination on every valid input.
Incorrect! Try again.
51A Las Vegas randomized algorithm always returns the correct result and has expected running time , but it may repeatedly restart. Which claim is justified?
Analysing the effectiveness and efficiency of algorithms
Hard
A.Its average over internal randomness is without a deterministic bound
B.Its worst-case running time is by Markov's inequality
C.At least half of all executions take exactly time
D.Every execution terminates within time
Correct Answer: Its average over internal randomness is without a deterministic bound
Explanation:
An expected bound controls the mean over random choices. It does not by itself impose a finite deterministic worst-case bound on every execution.
Incorrect! Try again.
52An algorithm reports all intersections among geometric objects in time. Why can this be more informative than a bound expressed only in ?
Analysing the effectiveness and efficiency of algorithms
Hard
A.It separates preprocessing work from the unavoidable output cost
B.It guarantees is asymptotically smaller than
C.It eliminates the need to consider worst-case values of
D.It proves the algorithm uses constant time for every intersection
Correct Answer: It separates preprocessing work from the unavoidable output cost
Explanation:
Writing distinct results already requires time. An output-sensitive bound exposes both the input-processing cost and this unavoidable output work.
Incorrect! Try again.
53Consider a loop where, for each integer from through , an inner counter takes the values while it is less than . What is the total running time?
Measuring time and space complexity of algorithm
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
The inner loop executes times. Summing gives by the harmonic series.
Incorrect! Try again.
54What is the tight asymptotic solution of with constant base cases?
Measuring time and space complexity of algorithm
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
Each recursion level has at most of the previous level's total subproblem size. The nonrecursive work therefore forms a decreasing geometric series totaling .
Incorrect! Try again.
55A depth-first divide-and-conquer algorithm splits a problem into two halves. Each active call allocates an auxiliary array proportional to its subproblem size and keeps it until that call returns. What is the peak auxiliary space?
Measuring time and space complexity of algorithm
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
Only one root-to-leaf path is active during depth-first execution. Its arrays total , while stack metadata adds only .
Incorrect! Try again.
56A dynamic array triples its capacity whenever full. Copying an array of capacity costs . Starting empty, what is the total copying cost of the first append operations?
Measuring time and space complexity of algorithm
Hard
A.
B.
C.
D.
Correct Answer:
Explanation:
The copied capacities form a geometric sequence whose sum is dominated by its final term. Thus total copying is and amortized append cost is .
Incorrect! Try again.
57A naive recursive solver for a problem with state repeatedly recomputes states and takes exponential time. There are reachable states, each requiring transition work. What trade-off does full memoization provide?
Trade-off concept
Hard
A. time using additional space
B. time using additional space
C. time using additional space
D. time using additional space
Correct Answer: time using additional space
Explanation:
Memoization evaluates each reachable state once and stores its result. It exchanges table space for eliminating repeated recursive computation.
Incorrect! Try again.
58Compared with storing all keys exactly in a hash set, which guarantee describes a standard Bloom filter with no deletions?
Trade-off concept
Hard
A.It uses less space but permits false positives
B.It uses equal space and supports exact membership
C.It uses less space but permits false negatives
D.It uses more space and eliminates hash collisions
Correct Answer: It uses less space but permits false positives
Explanation:
A Bloom filter compactly records hashed bit positions. A missing key is detected reliably, but collisions can make an absent key appear present.
Incorrect! Try again.
59For exact subset sum on unrestricted integers, a meet-in-the-middle method stores all sums from each half. What time-space profile does it typically achieve?
Trade-off concept
Hard
A. time and space
B. time and space
C. time and space
D. time and space
Correct Answer: time and space
Explanation:
Splitting the set into two halves produces about sums per half. Storing and searching these lists reduces time from exhaustive enumeration at the cost of exponential space.
Incorrect! Try again.
60A data structure can precompute a table in time and space, after which each query costs . Without the table, each query costs and preprocessing is constant. For queries, when is precomputation asymptotically faster?
Trade-off concept
Hard
A.When
B.When
C.When
D.When
Correct Answer: When
Explanation:
The costs are with preprocessing and without it. Their ratio tends to zero precisely when tends to infinity.
Incorrect! Try again.
Did this save you a night before the exam?
LPU Notes is free, and it stays free. Ads cover part of the server bill.
The rest comes out of a student's own pocket: the domain, the storage,
and keeping the site up through the weeks everyone needs it at once.
The payment button didn't load. An ad blocker or a filtered network is the usual reason.
to try again.
Nothing here is ever locked, and nothing unlocks. Chip in only if it was worth it.
What it pays for →