Unit 1: Behaviour Analysis - Practice Quiz

CSE330 — Competitive Coding Approaches-Techniques 60 Questions
0 Correct 0 Wrong 60 Left
0/60

1 What does the limit of a function describe?

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

2 In 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

3 Which 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

4 What 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

5 What 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

6 Which complexity class generally grows more slowly?

Understanding taxonomy in worst case Easy
A.
B.
C.
D.

7 What 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.

8 Which notation represents a tight asymptotic bound?

Understanding taxonomy in worst case Easy
A. notation
B. notation
C. notation
D. notation

9 What is the worst-case time complexity of a linear search in an unsorted array?

Understanding taxonomy in worst case Easy
A.
B.
C.
D.

10 What 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

11 What 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

12 Two 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

13 Why 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

14 Which 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

15 What 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

16 What 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

17 What is the time complexity of a loop that runs exactly times?

Measuring time and space complexity of algorithm Easy
A.
B.
C.
D.

18 What is the time complexity of two separate nested loops, each running times?

Measuring time and space complexity of algorithm Easy
A.
B.
C.
D.

19 What 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

20 What 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

21 For 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

22 An 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.

23 Suppose and . What is ?

Introduction to limits and behaviour of logic Medium
A.
B.
C.
D.

24 A 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

25 Which 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

26 Insertion 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

27 An 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

28 Binary 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

29 Algorithm 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.

30 Two 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

31 An 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

32 Algorithm 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

33 What 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.

34 An 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.

35 A 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.

36 A 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.

37 A 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

38 A 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

39 A 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

40 A 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

41 Let 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

42 Suppose 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

43 For 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

44 Let 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

45 An 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.

46 A 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

47 A 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

48 For 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.

49 Algorithm 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

50 A 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

51 A 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

52 An 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

53 Consider 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.

54 What is the tight asymptotic solution of with constant base cases?

Measuring time and space complexity of algorithm Hard
A.
B.
C.
D.

55 A 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.

56 A 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.

57 A 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

58 Compared 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

59 For 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

60 A 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