OA. free
Free
Texas Instruments Data Structures & Algorithms Data Structures & Algorithms Medium

Software ends mi 1.

Texas Instruments technical mcq question, verified with a worked answer. Free to practise - no sign-up.

Software ends mi 1. Performing an operation Aptitude You are given an nxn matrix of integers and asked to perform the following operation on it: Submitted 1. Compute the minimum value in each row. Software 2. Find the maximum of all the minimum values. C1) 2 3 What is the time complexity of performing this operation? 4 5 6 7 8 9 10 - A) O(n) - B) O(n log n) - C) O(n2) - D) O(n3) G&G a © G> --- [PAGE/IMAGE BREAK] --- Software ends mi 2. Preventing deadlocks Oo Previous | GXtway Aptitude Read the following statements about deadlocks in an OS and choose the most appropriate option. Submitted A: Permitting resource preemption alone will prevent deadlocks. Software B: Preventing circular wait for resources alone will prevent deadlocks. :@> 4 5 6 7 8 9 10

Choose one option.
Show answer & explanation
Answer: C. O(n*2)

To find the minimum of each row in an n x n matrix, every element must be visited once, requiring O(n^2) time. Finding the maximum of the resulting n minimum values takes O(n) time, leading to a total time complexity of O(n^2 + n), which simplifies to O(n^2).

Step-by-step Derivation:
Step 1: Analyze the first operation: 'Compute the minimum value in each row'. For a single row of length n, finding the minimum takes O(n) time. Since there are n rows, the total time for this step is n * O(n) = O(n^2).
Step 2: Analyze the second operation: 'Find the maximum of all the minimum values'. After Step 1, we have a list of n minimum values. Finding the maximum of n elements takes O(n) time.
Step 3: Combine the complexities: Total Time = O(n^2) + O(n).
Step 4: In Big O notation, the dominant term is kept. Therefore, O(n^2 + n) simplifies to O(n^2).
Step 5: Match with the provided options. Option C is listed as O(n*2), which is a notation for O(n^2).