CMI Data Science
    Test Series
    Verified Solutions Included
    Half Syllabus Test for CMI Data Science: 40 Questions with Solutions & Analysis

    Attempt the Half Syllabus Test for CMI Data Science: 40 exam-level questions, detailed solutions and performance analysis. First questions free.

    40 Qs

    Total Questions

    86 Marks

    Total Marks

    143.43 Mins

    Duration

    +3 / -1 / 0

    Marking Scheme

    Section-wise Paper Structure

    Probability Theory

    19 Qs

    48% of total marks

    School Level Mathematics

    12 Qs

    30% of total marks

    Discrete Mathematics

    6 Qs

    15% of total marks

    Programming

    3 Qs

    8% of total marks

    Free Solved Questions with Step-by-Step Solutions

    Authentic examination problems with detailed derivations and answer keys.

    Question 1
    2022 PYQ
    Level 3: Exam Standard
    There are three different approaches that climbers can take to reach the summit of Mount Chernoff, namely, APPROACH-I, APPROACH-II, and APPROACH-III. Each attempt at the summit uses exactly one of these approaches. From climbers’ logs it is known that APPROACH-I is used in 40% of the attempts, and APPROACH-II and APPROACH-III are each used in 30% of the attempts. From the same logs it is also known that in 10% of the attempts which used APPROACH-I the climber lost their way and had to be rescued. Similarly, 15% of the attempts that used APPROACH-II and 17% of the attempts which used APPROACH-III resulted in the climber losing their way.
    It is reported one day that climber Chebyshev has lost her way. What is the probability that she took APPROACH-II?
    Question 2
    2020 PYQ
    Level 3: Exam Standard
    Owing to a defect in a certain machine which makes N95 masks, there is a 0.1% probability that a mask it makes is not effective in preventing airborne viruses from being inhaled.
    (a) What is the probability that the first 1000 masks that the machine produces are effective? (You may leave your solutions as arithmetic expressions; there is no need to compute their decimal representations.)
    (b) What is the probability that among the first one crore masks that the machine produces, there is at least one mask which is not effective?
    Question 3
    2025 PYQ
    Level 3: Exam Standard

    A cloth bag labeled contains two apples, bag contains two oranges and bag one apple and one orange. You pick a bag at random and then remove one fruit from that bag at random. Suppose you removed an apple. What is the probability that the fruit remaining in the bag is also an apple? Justify.

    Question 4
    Level 3: Exam Standard

    Let be an matrix and be an vector. The system represents a set of linear equations. Which of the following conditions guarantee that the system has a unique solution for every ?

    Question 5
    Level 3: Exam Standard

    Let . Find the trace of the matrix .

    Question 6
    Level 3: Exam Standard

    For how many integers does the congruence imply for all integers and ?

    Question 7
    2023 PYQ
    Level 3: Exam Standard
    Each lawyer on a certain remote island is either honest or dishonest (but not both).
    • Honest lawyers always speak the truth.
    • Dishonest lawyers always lie.
    Is it possible for a lawyer on this island to claim that he/ she is dishonest? Explain. A judge asks lawyer , “are you honest?” Before could answer, lawyer says “ will say yes. But then, he’ll be lying”. Which lawyer is honest and which one is dishonest? Explain.
    Question 8
    Level 3: Exam Standard

    In a certain assembly, every member is either a truth-teller (always tells the truth) or a liar (always lies). Four members , , , make the following statements:

    • says: "If is a truth-teller, then is a liar."
    • says: "If is a truth-teller, then is a truth-teller."
    • says: " is a liar."
    • says: " is a truth-teller or is a liar."

    Which of the following statements are necessarily true?

    Question 9
    Level 3: Exam Standard

    Four people , , , are each either a truth-teller (always tells the truth) or a liar (always lies). They make the following statements:

    • says: "Exactly two of us are liars."
    • says: " is a liar."
    • says: " is a truth-teller."
    • says: " is a liar."

    How many valid assignments of types to , , , are consistent with all statements?

    Question 10
    Level 3: Exam Standard

    Consider the following function, where // denotes integer division.

    ```python

    def evaluate(n):

    count = 0

    while n > 2:

    if n % 2 == 1:

    n = n // 2

    else:

    n = n - 2

    count += 1

    return count

    ```

    Match the initial values of in List I with the corresponding return value of evaluate(n) in List II.

    List I

    P.

    Q.

    R.

    S.

    List II

    Question 11
    Level 4: Challenger

    Consider the function steps(n) which takes a positive integer and executes the following pseudocode:

    ```python

    count = 0

    while n > 1:

    if n % 2 == 0:

    n = n // 2

    else:

    n = n - 1

    count = count + 1

    return count

    ```

    Assertion (A): For any integer , the value returned by steps(2^k - 1) is exactly .

    Reason (R): For an input , the first iteration subtracts 1 to make the number even, and the second iteration halves it to , which is a power of 2, ensuring all subsequent steps are halving operations.

    Choose the correct option based on the above statements.

    Question 12
    Level 3: Exam Standard

    Consider the following algorithm executed on an array of integers ():

    M = A[0]

    S = 0

    for i = 1 to n-1:

    if A[i] < M:

    S = S - (A[i] - M)

    M = A[i]

    Which of the following statements is ALWAYS true at the end of the algorithm?

    Unlock All 40 Questions in Real Examination Mode

    Practice with the authentic timer, on-screen calculator, instant percentile ranking, and section-wise analytics.

    More CMI Data Science Test Series

    Free preview ends here

    Login to view the complete test and solutions

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Half Syllabus Test for CMI Data Science: 40 Questions with Solutions & Analysis

    Attempt the Half Syllabus Test for CMI Data Science: 40 exam-level questions, detailed solutions and performance analysis. First questions free.

    Paper breakdown

    40 questions · 86 marks · 143.43 minutes. Probability Theory: 19 · School Level Mathematics: 12 · Discrete Mathematics: 6 · Programming: 3

    Free sample questions from Half Syllabus Test

    Question 1 · Probability Theory · 2022 SUB
    There are three different approaches that climbers can take to reach the summit of Mount Chernoff, namely, APPROACH-I, APPROACH-II, and APPROACH-III. Each attempt at the summit uses exactly one of these approaches. From climbers’ logs it is known that APPROACH-I is used in 40% of the attempts, and APPROACH-II and APPROACH-III are each used in 30% of the attempts. From the same logs it is also known that in 10% of the attempts which used APPROACH-I the climber lost their way and had to be rescued. Similarly, 15% of the attempts that used APPROACH-II and 17% of the attempts which used APPROACH-III resulted in the climber losing their way.
    It is reported one day that climber Chebyshev has lost her way. What is the probability that she took APPROACH-II?
    Correct Answer:

    0.3309

    Step-by-Step Solution

    Key idea: This is a Bayes theorem problem. The approaches form a partition of all attempts, and we observe the evidence that the climber lost her way.

    Step 1: Define events. Let A1, A2, A3 be APPROACH-I, APPROACH-II, APPROACH-III. Let L be the event that the climber lost the way.

    Step 2: Write the prior probabilities: P(A1)=0.4, P(A2)=0.3, P(A3)=0.3.

    Step 3: Write the likelihoods: P(L|A1)=0.10, P(L|A2)=0.15, P(L|A3)=0.17.

    Step 4: We need P(A2|L), the probability of APPROACH-II given that the climber lost her way.

    Step 5: Use Bayes theorem:

    P(A2|L) = P(A2)P(L|A2) / P(L).

    Step 6: Compute the numerator: P(A2)P(L|A2) = 0.3 x 0.15 = 0.045.

    Step 7: Compute the total probability of losing the way using the law of total probability:

    P(L) = 0.4 x 0.10 + 0.3 x 0.15 + 0.3 x 0.17.

    Step 8: Evaluate: 0.04 + 0.045 + 0.051 = 0.136.

    Step 9: Divide the target route by the total evidence:

    P(A2|L) = 0.045 / 0.136 = 45/136, which is approximately 0.3309.

    Answer: 0.3309.

    Question 2 · Probability Theory · 2020 SUB
    Owing to a defect in a certain machine which makes N95 masks, there is a 0.1% probability that a mask it makes is not effective in preventing airborne viruses from being inhaled.
    (a) What is the probability that the first 1000 masks that the machine produces are effective? (You may leave your solutions as arithmetic expressions; there is no need to compute their decimal representations.)
    (b) What is the probability that among the first one crore masks that the machine produces, there is at least one mask which is not effective?
    Correct Answer:

    1

    Step-by-Step Solution

    Key idea: This is a repeated independent Bernoulli trials question with a rare defect. The trigger words are "machine makes masks", "probability that a mask ... is not effective", and "at least one".

    Step 1: Find the probability that one mask is effective.

    The probability that a mask is not effective is . Therefore,

    Step 2: Solve part (a).

    The first 1000 masks are independent. The probability that all 1000 are effective is

    Numerically, this is approximately .

    Step 3: Solve part (b) using the complement rule.

    "At least one mask is not effective" is the complement of "all masks are effective".

    For masks,

    Hence,

    Step 4: Interpret the NAT numeric answer.

    Since

    this number is effectively zero to any usual numerical precision. Therefore the final probability in part (b) is numerically .

    Answer: The exact expressions are for part (a) and for part (b). The single numeric NAT answer for the final part is .

    Question 3 · Probability Theory · 2025 SUB

    A cloth bag labeled contains two apples, bag contains two oranges and bag one apple and one orange. You pick a bag at random and then remove one fruit from that bag at random. Suppose you removed an apple. What is the probability that the fruit remaining in the bag is also an apple? Justify.

    Correct Answer:

    none

    Step-by-Step Solution

    Insight: The remaining fruit is an apple if and only if the all-apple bag was chosen, so we just need the posterior probability of that bag after observing an apple.

    Exam route: . .

    Learning route: This is a Bayes' theorem question with a "remaining item" twist. The bags form a partition, and the question asks for , which equals since only bag can leave an apple after an apple is removed.

    Step 1: Let be the events of choosing bags . .

    Step 2: Let be the event that the removed fruit is an apple. Likelihoods: , , .

    Step 3: Compute total probability of observing an apple: .

    Step 4: Substitute: .

    Step 5: The remaining fruit is an apple if and only if bag was chosen. Bag contains no apples, and bag would leave an orange after an apple is removed.

    Step 6: Use Bayes' theorem: .

    Step 7: Substitute: .

    Question 4 · School Level Mathematics MSQ

    Let be an matrix and be an vector. The system represents a set of linear equations. Which of the following conditions guarantee that the system has a unique solution for every ?

    1. A.

      The columns of are linearly independent.

    2. B.

      The equation has only the trivial solution.

    3. C.

      The matrix can be row-reduced to the identity matrix.

    4. D.

      The determinant of is zero.

    Correct Answer:

    ["A","B","C"]

    Step-by-Step Solution

    Key idea: This is a foundational question connecting the matrix equation to the invertibility of . A unique solution for every is the exact definition of being invertible.

    Step 1: Analyze option A. If the columns of are linearly independent, the column space of spans all of . This means any vector can be written as a unique linear combination of the columns, so has a unique solution.

    Step 2: Analyze option B. If has only the trivial solution, the null space of is trivial. By the Rank-Nullity Theorem, the rank of is , meaning is invertible. Thus, has a unique solution for every .

    Step 3: Analyze option C. If can be row-reduced to the identity matrix , it means is row-equivalent to . This is a standard criterion for invertibility, guaranteeing a unique solution for every .

    Step 4: Analyze option D. If , the matrix is singular. A singular matrix cannot have a unique solution for every (it will either have no solution or infinitely many for some ).

    Answer: A, B, C

    Question 5 · School Level Mathematics SUB

    Let . Find the trace of the matrix .

    Correct Answer:

    10

    Step-by-Step Solution

    Key idea: This is a 2x2 matrix inverse and trace property question, recognizable by the small matrix size and the combination of and .

    Step 1: Recall the formula for the inverse of a matrix. For , .

    Step 2: Compute .

    Step 3: Find .

    Step 4: Compute the trace of . The trace is a linear operator, so .

    Step 5: Calculate the individual traces:

    .

    .

    Step 6: Add them together:

    .

    Answer: 10

    Question 6 · School Level Mathematics MSQ

    For how many integers does the congruence imply for all integers and ?

    1. A.

      32

    2. B.

      34

    3. C.

      33

    4. D.

      35

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is a modular cancellation problem. The congruence holds for all if and only if .

    Step 1: We are given . This can be rewritten as .

    Step 2: For this to imply for all integers and , must share no common factors with 6 other than 1. Thus, we need .

    Step 3: We must count the number of integers in that are coprime to 6.

    Step 4: Since , an integer is coprime to 6 if and only if it is not divisible by 2 and not divisible by 3.

    Step 5: Use the Principle of Inclusion-Exclusion to count the numbers divisible by 2 or 3:

    Divisible by 2: .

    Divisible by 3: .

    Divisible by 6: .

    Step 6: Number of integers divisible by 2 or 3 is .

    Step 7: The number of integers coprime to 6 is .

    Answer: 33

    Question 7 · Discrete Mathematics · 2023 SUB
    Each lawyer on a certain remote island is either honest or dishonest (but not both).
    • Honest lawyers always speak the truth.
    • Dishonest lawyers always lie.
    Is it possible for a lawyer on this island to claim that he/ she is dishonest? Explain. A judge asks lawyer , “are you honest?” Before could answer, lawyer says “ will say yes. But then, he’ll be lying”. Which lawyer is honest and which one is dishonest? Explain.
    Correct Answer:

    none

    Step-by-Step Solution

    Insight: Self-referential dishonesty claims produce (a paradox with no solution in ). Meta-statements about hypothetical answers collapse once you realise every islander answers "Yes" to "Are you honest?".

    Exam route: Part (i) has no solution in , so no lawyer can claim dishonesty. Part (ii) A's hypothetical reply is provably "Yes", so B's compound claim reduces to " is lying", giving . Opposite types, identities undetermined.

    Learning route:

    This is a liar-paradox plus meta-statement question, recognisable because it asks whether a character can make a self-referential identity claim and then layers a hypothetical-report statement on top.

    Part (i) — Can a lawyer claim "I am dishonest"?

    Step 1: Let encode the lawyer's type ( = honest, = dishonest). The claim "I am dishonest" asserts .

    Step 2: Apply the core rule where . This gives .

    Step 3: Test : — contradiction. Test : — contradiction.

    Step 4: No assignment satisfies the equivalence, so no lawyer on this island can claim to be dishonest.

    Part (ii) — Which lawyer is honest and which is dishonest?

    Step 1: Analyse A's hypothetical answer to "Are you honest?" If A is honest (), A truthfully says "Yes". If A is dishonest (), A lies and also says "Yes". Therefore A will definitely say "Yes" regardless of type. The first conjunct of B's statement is a proven fact (truth value ).

    Step 2: Translate B's full statement. B asserts the conjunction: "A will say yes" "A is lying". The first conjunct is (proven). The second conjunct is . So B's statement has truth value .

    Step 3: Apply the core rule to B: . This biconditional means A and B have opposite types.

    Step 4: No further information pins down which is which. Both and are consistent with all constraints.

    Wrong path: A student might reason "B correctly predicts A will say yes, so B must be honest, making A dishonest." This produces the definite answer "B is honest, A is dishonest." The break occurs at assuming B's entire conjunction is true just because one conjunct is true. B's second conjunct ("A is lying") could be false, making B's whole statement false and B a liar.

    Generalization: When a speaker makes a compound statement, evaluate the truth value of the entire compound, not just one part.

    Verification: Check : A says "Yes" truthfully. B says "A says yes AND A is lying" . Since , B's false statement is consistent. Check : A says "Yes" (lying). B says "A says yes AND A is lying" . Since , B's true statement is consistent. Both assignments work.

    Answer: (i) No, it is impossible for a lawyer to claim dishonesty. (ii) A and B have opposite types, but individual identities cannot be determined.

    Question 8 · Discrete Mathematics MSQ

    In a certain assembly, every member is either a truth-teller (always tells the truth) or a liar (always lies). Four members , , , make the following statements:

    • says: "If is a truth-teller, then is a liar."
    • says: "If is a truth-teller, then is a truth-teller."
    • says: " is a liar."
    • says: " is a truth-teller or is a liar."

    Which of the following statements are necessarily true?

    1. A.

      and are of the same type.

    2. B.

      is a truth-teller.

    3. C.

      is a truth-teller.

    4. D.

      is a liar.

    Correct Answer:

    ["A","B"]

    Step-by-Step Solution

    Key idea: This is a conditional logic question inside a binary truth system. The key recognition cue is the "If... then..." phrasing in statements by and . Recall that is logically equivalent to , and is vacuously true when is false.

    Step 1: Translate each statement using .

    Let each variable be (truth-teller) or (liar).

    • , i.e., .
    • , i.e., .
    • .
    • .

    Step 2: Use to reduce.

    This gives . Substitute into 's equation:

    .

    Step 3: Try (Y is a truth-teller).

    Then . From : , so , meaning and .

    Check : . So , giving . Consistent.

    Check : . So , giving . But we derived . Contradiction.

    Therefore is impossible.

    Step 4: Try (Y is a liar).

    Then . From : , so .

    Check : . So .

    Check : . So .

    Verify 's constraint: . Consistent.

    Verify 's statement: says " is a liar." Since , this statement is false. is a liar saying a false statement. Consistent.

    Step 5: Unique solution is .

    Note the critical role of vacuous truth: 's statement "If is a truth-teller then is a truth-teller" has a false hypothesis (), making the conditional vacuously true, which is consistent with .

    Checking the options:

    • (A) and are the same type: both are truth-tellers. True.
    • (B) is a truth-teller: True.
    • (C) is a truth-teller: False, is a liar.
    • (D) is a liar: False, is a truth-teller.

    Answer: Options A and B are necessarily true.

    Question 9 · Discrete Mathematics SUB

    Four people , , , are each either a truth-teller (always tells the truth) or a liar (always lies). They make the following statements:

    • says: "Exactly two of us are liars."
    • says: " is a liar."
    • says: " is a truth-teller."
    • says: " is a liar."

    How many valid assignments of types to , , , are consistent with all statements?

    Correct Answer:

    2

    Step-by-Step Solution

    Key idea: This is a global constraint question. The key recognition cue is 's statement about the total number of liars. When a liar makes such a statement, the negation gives a global constraint that must be satisfied.

    Step 1: Translate each statement using .

    Let where = truth-teller, = liar.

    Let = number of liars = .

    • , i.e.,
    • , i.e.,
    • , i.e.,

    Step 2: Derive relationships from , , .

    From : .

    From : , so .

    From : .

    So we have: , , .

    Step 3: Express in terms of .

    .

    Wait, this gives regardless of ? Let me recheck.

    If : , , . So .

    If : , , . So .

    So in both cases.

    Step 4: Check 's constraint.

    .

    Since always, the right side is always true.

    So , which means .

    But wait, we said can be or . Let me re-examine.

    If : 's statement "" is true. (truth-teller) tells truth. Consistent.

    If : 's statement "" is true. But (liar) must lie, so statement should be false. Contradiction.

    So only works.

    Step 5: Find the unique assignment.

    .

    Verify all statements:

    • says "": , true. OK.
    • says "": , true. OK.
    • says "": , false. is liar, tells lie. OK.
    • says "": , false. is liar, tells lie. OK.

    So there is exactly 1 valid assignment.

    Wait, but the answer is supposed to be 2. Let me re-read the problem.

    Actually, I made an error. Let me reconsider whether is always 2.

    From Step 2: , , .

    .

    So always.

    Then 's statement is always true, so must be a truth-teller ().

    This gives exactly 1 valid assignment, not 2.

    But the problem asks "how many valid assignments," and if the answer is 1, that's a NAT answer.

    Let me double-check by trying all 16 possibilities.

    Actually, the relationships , , are forced by , , 's statements. So we only have 2 possibilities: or .

    : . . 's statement is true. tells truth. Valid.

    : . . 's statement is true. must lie. Invalid.

    So only 1 valid assignment.

    But wait, maybe I should reconsider the problem. Perhaps the answer is indeed 1.

    Let me re-read the question: "How many valid assignments...?"

    If the answer is 1, that's fine for a NAT question.

    But let me reconsider whether there's a different interpretation.

    Actually, I think the answer is 1, not 2. Let me adjust the answer.

    Answer: 1

    Question 10 · Programming MSQ

    Consider the following function, where // denotes integer division.

    ```python

    def evaluate(n):

    count = 0

    while n > 2:

    if n % 2 == 1:

    n = n // 2

    else:

    n = n - 2

    count += 1

    return count

    ```

    Match the initial values of in List I with the corresponding return value of evaluate(n) in List II.

    List I

    P.

    Q.

    R.

    S.

    List II

    1. A.

      P-1, Q-2, R-4, S-3

    2. B.

      P-2, Q-3, R-4, S-3

    3. C.

      P-1, Q-3, R-4, S-2

    4. D.

      P-1, Q-2, R-3, S-4

    Correct Answer:

    A

    Step-by-Step Solution

    Insight: The loop condition is strictly n > 2, meaning the loop terminates the moment reaches or less.

    Exam route: Trace each value step-by-step using a table, updating and count until the condition becomes false.

    Learning route:

    • For P (): (True) , count = 1. (True) , count = 2. (False). Loop ends. Return 2. (Matches 1)
    • For Q (): (True) , count = 1. (True) , count = 2. (True) , count = 3. (False). Loop ends. Return 3. (Matches 2)
    • For R (): (True) , count = 1. (2), (3), (4), (5), (6). (False). Loop ends. Return 6. (Matches 4)
    • For S (): (True) , count = 1. (2), (3), (4). (False). Loop ends. Return 4. (Matches 3)

    The correct matching is P-1, Q-2, R-4, S-3.

    Question 11 · Programming MSQ

    Consider the function steps(n) which takes a positive integer and executes the following pseudocode:

    ```python

    count = 0

    while n > 1:

    if n % 2 == 0:

    n = n // 2

    else:

    n = n - 1

    count = count + 1

    return count

    ```

    Assertion (A): For any integer , the value returned by steps(2^k - 1) is exactly .

    Reason (R): For an input , the first iteration subtracts 1 to make the number even, and the second iteration halves it to , which is a power of 2, ensuring all subsequent steps are halving operations.

    Choose the correct option based on the above statements.

    1. A.

      Both A and R are true, and R is the correct explanation of A.

    2. B.

      Both A and R are true, but R is NOT the correct explanation of A.

    3. C.

      A is true, but R is false.

    4. D.

      A is false, but R is true.

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: Evaluate the Assertion by tracing the algebraic form to find a recurrence, then test the Reason by checking the exact algebraic result of the first two steps.

    Exam route:

    Step 1: Analyze Assertion (A). Let . Since , is odd.

    Step 2: Iteration 1: becomes . (count = 1)

    Step 3: Iteration 2: becomes . (count = 2)

    Step 4: This reduces the problem to . Thus, .

    Step 5: Solving this recurrence with base case gives . Assertion (A) is True.

    Step 6: Analyze Reason (R). It claims the second iteration yields . However, , not . Reason (R) is False.

    Learning route:

    The trap in Reason (R) is an algebraic oversight: assuming that halving a number that is 2 less than a power of 2 yields the next lower power of 2. In reality, , which is still odd (for ), forcing another subtraction. The constraint that the numerator must be exactly a power of 2 to yield a power of 2 upon halving is ignored.

    Answer: C

    Question 12 · Programming MSQ

    Consider the following algorithm executed on an array of integers ():

    M = A[0]

    S = 0

    for i = 1 to n-1:

    if A[i] < M:

    S = S - (A[i] - M)

    M = A[i]

    Which of the following statements is ALWAYS true at the end of the algorithm?

    1. A.

      S = M - A[0]

    2. B.

      S = A[0] - M

    3. C.

      S < 0

    4. D.

      S = \sum_{i=1}^{n-1} (A[i-1] - A[i])

    Correct Answer:

    B

    Step-by-Step Solution

    Key idea: This is an estimation question where the variable accumulates differences during a running minimum scan, forming a telescoping sum.

    Exam route: Let the sequence of values that takes be , where and (the final minimum of the array).

    The updates to occur only when a new minimum is found. The update rule is , which simplifies to .

    Summing these updates over all changes gives a telescoping sum:

    All intermediate terms cancel out, leaving:

    .

    Since is the minimum element of the entire array, it must be that . Therefore, .

    Thus, statement B is always true. Statement A has the wrong sign. Statement C is false because . Statement D is false because it sums all adjacent drops, overcounting local increases (e.g., gives , but D gives ? Wait, D is sum of , which for is . Let's use . updates: (), (). Final . Formula D gives . So D is definitively false).

    Answer: S = A[0] - M

    More CMI Data Science tests