Notice: Due to an ongoing migration of our storage and publishing system, material requested since last month will not be uploaded for the time being, and new requests are paused. All existing notes remain available.
You're offline
Unit 2 MCQsBasic math operations (addition, subtraction, multiplication, division and exponentiation)
The pigeonhole principle states that if items are placed into containers with , then:
Not quite. Try another option.
Answer: At least one container holds more than one item
When there are more items than containers, at least one container must contain more than one item.
Question 20 of 60 · Pigeonhole principle · Easy
If 13 people are in a room, by the pigeonhole principle at least two share the same:
Not quite. Try another option.
Answer: Birth month
There are only 12 months, so among 13 people at least two must share the same birth month.
Question 21 of 60 · Fast modulo multiplication · Medium
Fast modulo multiplication (also called Russian peasant multiplication under a modulus) computes without overflow by repeatedly doubling and adding. What is the primary advantage of this technique over directly computing first?
Not quite. Try another option.
Answer: It avoids overflow when exceeds the data type's range
By adding to itself under the modulus using doubling, each intermediate value stays below , preventing the product from ever being formed in full and thus avoiding overflow.
Question 22 of 60 · Fast modulo multiplication · Medium
Using the doubling method to compute , the loop processes the bits of . What is the final result?
Not quite. Try another option.
Answer:
, and . The doubling method accumulates scaled by each set bit of , all reduced mod , yielding the same result.
Question 23 of 60 · Exponential squaring · Medium
Exponentiation by squaring computes in multiplications. Which recurrence correctly describes it for even ?
Not quite. Try another option.
Answer:
For even , , so only one recursive computation plus one squaring is needed, halving the exponent each step and giving logarithmic time.
Question 24 of 60 · Exponential squaring · Medium
How many multiplications does exponentiation by squaring perform (approximately) to compute ?
Not quite. Try another option.
Answer:
Since , the value is obtained by squaring 4 times: , requiring only 4 multiplications instead of 15.
Question 25 of 60 · N-th non-square number · Medium
The -th non-square (non-perfect-square) number is given by the formula . What is the th non-square number?
Not quite. Try another option.
Answer:
The non-square numbers are (skipping ). The 5th is , matching .
Question 26 of 60 · N-th non-square number · Medium
Using the formula , what is the th non-square number?
Not quite. Try another option.
Answer:
Compute . The non-squares are , so the 10th is .
Question 27 of 60 · Modular Exponentiation · Medium
What is using modular exponentiation?
Not quite. Try another option.
Answer:
Since (Fermat), .
Question 28 of 60 · Modular Exponentiation · Medium
In modular exponentiation computing , why is the result reduced modulo after every multiplication rather than only at the end?
Not quite. Try another option.
Answer: To keep intermediate values small and prevent overflow
Reducing after each multiplication keeps intermediate values bounded below , preventing overflow while preserving the correct final result due to modular arithmetic rules.
Question 29 of 60 · Modular Exponentiation · Medium
What is the time complexity of computing using fast modular exponentiation?
Not quite. Try another option.
Answer:
Fast modular exponentiation halves the exponent each step via squaring, performing about iterations, each with constant-time modular multiplication.
Question 30 of 60 · Modular multiplicative inverse · Medium
The modular multiplicative inverse of modulo exists if and only if which condition holds?
Not quite. Try another option.
Answer:
An inverse satisfying exists exactly when and are coprime, i.e., .
Question 31 of 60 · Modular multiplicative inverse · Medium
What is the modular multiplicative inverse of modulo ?
Not quite. Try another option.
Answer:
We need . Testing : , so the inverse is .
Question 32 of 60 · Modular multiplicative inverse · Medium
When is prime, Fermat's Little Theorem gives the modular inverse of as which expression?
Not quite. Try another option.
Answer:
Fermat's Little Theorem states , so , making the inverse when is prime and .
Question 33 of 60 · Sum of middle row and element in matrix · Medium
For an odd-sized matrix, the middle element lies at which index (0-based)?
Not quite. Try another option.
Answer: using integer division
For an odd , integer division gives the central row and column index. For example, in a matrix, the middle element is at .
Question 34 of 60 · Sum of middle row and element in matrix · Medium
Given the matrix , what is the sum of the middle row?
Not quite. Try another option.
Answer:
The middle row (index 1) is , and its sum is .
Question 35 of 60 · Checking if all rows of a matrix are circular rotations of each other · Medium
A common technique to check whether every row of a matrix is a circular rotation of the first row uses string concatenation. If the first row (as a string) is , a row is a circular rotation of it when:
Not quite. Try another option.
Answer: is a substring of
All circular rotations of appear as contiguous substrings of . So is a rotation of if and only if is a substring of the doubled string (and has equal length).
Question 36 of 60 · Checking if all rows of a matrix are circular rotations of each other · Medium
Consider a matrix with rows , , and . Are all rows circular rotations of the first row?
Not quite. Try another option.
Answer: Yes, each is a rotation of
Rotations of are , , and . All three rows appear as contiguous substrings of , so every row is a circular rotation.
Question 37 of 60 · Inclusion - Exclusion Principle · Medium
How many integers from to are divisible by or ?
Not quite. Try another option.
Answer:
By inclusion-exclusion: .
Question 38 of 60 · Inclusion - Exclusion Principle · Medium
For three finite sets, the inclusion-exclusion principle gives as:
Not quite. Try another option.
Answer:
Adding the individual sizes over-counts pairwise intersections, so they are subtracted, but this removes the triple intersection too many times, so it is added back once.
Question 39 of 60 · Pigeonhole principle · Medium
If people are in a room, the pigeonhole principle guarantees that at least how many share the same birth month?
Not quite. Try another option.
Answer:
With 12 months (pigeonholes) and 13 people (pigeons), at least one month must contain people, so at least two share a birth month.
Question 40 of 60 · Pigeonhole principle · Medium
What is the minimum number of items needed so that, when placed into boxes, at least one box contains at least items?
Not quite. Try another option.
Answer:
By the generalized pigeonhole principle, to force a box with at least items we need more than items, so the minimum is .
Question 41 of 60 · Fast modulo multiplication · Hard
You need to compute where can each be up to . Direct multiplication overflows 64-bit integers. Which technique correctly computes this without overflow using only integer arithmetic?
Not quite. Try another option.
Answer: Binary (Russian peasant) multiplication adding to a running result modulo while doubling
Binary multiplication decomposes into bits; for each set bit it adds the current doubled value of (mod ) to the result (mod ). Since each intermediate value stays below , it never overflows a 64-bit range when handled carefully, giving the correct product mod .
Question 42 of 60 · Exponential squaring · Hard
How many modular multiplications (including squarings) does exponentiation by squaring perform in the worst case to compute , where has bits?
Not quite. Try another option.
Answer: Approximately multiplications
For each of the bits there is one squaring; additionally each set bit triggers one multiply. In the worst case (all bits set) this yields about squarings plus multiplications, i.e. roughly operations.
Question 43 of 60 · N-th non-square number · Hard
The -th non-square (non-perfect-square) positive integer is given by the closed form . What is the -th non-square number?
Not quite. Try another option.
Answer:
Compute . Thus the answer is . Listing non-squares: confirms the -th is .
Question 44 of 60 · Modular Exponentiation · Hard
Using Fermat's little theorem, what is ?
Not quite. Try another option.
Answer:
By Fermat's little theorem . Since , we get .
Question 45 of 60 · Modular multiplicative inverse · Hard
The modular inverse of modulo exists if and only if which condition holds?
Not quite. Try another option.
Answer:
An inverse with exists exactly when and are coprime. If , then is always a multiple of and can never equal . Primality of is sufficient but not necessary.
Question 46 of 60 · Modular multiplicative inverse · Hard
Compute the modular multiplicative inverse of modulo .
Not quite. Try another option.
Answer:
We need . Testing : , so . Hence the inverse is .
Question 47 of 60 · Modular multiplicative inverse · Hard
To compute inverses of modulo a prime in time, the recurrence is used. This works because implies which congruence?
Not quite. Try another option.
Answer:
Since , the division identity gives . Multiplying by and rearranging yields the linear recurrence for computing all inverses in linear time.
Question 48 of 60 · Modular Exponentiation · Hard
To compute for prime using modular exponentiation, which exponent should be used?
Not quite. Try another option.
Answer:
By Fermat's little theorem , so . Therefore is the modular inverse of , computable quickly via exponentiation by squaring.
Question 49 of 60 · Inclusion - Exclusion Principle · Hard
How many integers in are divisible by at least one of , , or ?
Not quite. Try another option.
Answer:
By inclusion-exclusion: .
Question 50 of 60 · Inclusion - Exclusion Principle · Hard
How many integers in are divisible by none of , , or ?
Not quite. Try another option.
Answer:
Count divisible by at least one: . Therefore divisible by none is . These correspond to numbers coprime-ish to the set .
Question 51 of 60 · Pigeonhole principle · Hard
From any set of integers chosen from , the pigeonhole principle guarantees that at least one pair satisfies which relationship?
Not quite. Try another option.
Answer: One number divides the other
Write each number as with odd. There are only odd values in , so among numbers two share the same odd part . The one with the smaller power of then divides the other.
Question 52 of 60 · Pigeonhole principle · Hard
In any sequence of distinct real numbers, the Erdős–Szekeres theorem (a pigeonhole application) guarantees a monotonic subsequence of length at least:
Not quite. Try another option.
Answer:
Assign each element a pair (longest increasing run ending there, longest decreasing run ending there). If no monotonic subsequence reaches length , only distinct pairs exist, contradicting having elements. Hence a monotonic subsequence of length must exist.
Question 53 of 60 · Sum of middle row and element in matrix · Hard
For an matrix with odd , the sum of the middle row and middle column shares which element that must be counted only once to avoid double counting?
Not quite. Try another option.
Answer: The central element at index using integer division
The middle row is row and the middle column is column . They intersect precisely at the center , so if summing both, this element is added twice and must be subtracted once.
Question 54 of 60 · Sum of middle row and element in matrix · Hard
Given a matrix where element (0-indexed), what is the sum of the middle row?
Not quite. Try another option.
Answer:
The middle row is row . Its elements are . Their sum is .
Question 55 of 60 · Checking if all rows of a matrix are circular rotations of each other · Hard
To check whether all rows of an matrix are circular rotations of the first row, the standard efficient approach concatenates the first row with itself and then does what?
Not quite. Try another option.
Answer: Searches each subsequent row as a substring using KMP in per row
A row is a circular rotation of the first row iff it appears as a contiguous substring of the first row concatenated with itself. Using KMP, each check runs in , giving overall . Sorting or summing would falsely accept mere permutations.
Question 56 of 60 · Checking if all rows of a matrix are circular rotations of each other · Hard
Consider rows and . Why is a valid circular rotation of ?
Not quite. Try another option.
Answer: appears as a substring of
Doubling yields , which contains the contiguous block starting at index . Equal sums or being a permutation are necessary but not sufficient for a circular rotation.
Question 57 of 60 · Modular Exponentiation · Hard
When computing with a very large exponent given as a decimal string, and prime with , the exponent can first be reduced modulo which value?
Not quite. Try another option.
Answer:
By Fermat's little theorem , so exponents can be taken modulo : . This lets a huge string exponent be reduced digit by digit before exponentiation by squaring.
Question 58 of 60 · Exponential squaring · Hard
Exponentiation by squaring can be generalized to compute the -th power of an matrix. What is its time complexity for computing ?
Not quite. Try another option.
Answer:
Each matrix multiplication costs with the schoolbook algorithm, and exponentiation by squaring performs such multiplications. Hence the total is , widely used for linear recurrences like Fibonacci.
Question 59 of 60 · Pigeonhole principle · Hard
Given any integers, the pigeonhole principle guarantees a non-empty subset whose sum is divisible by . Which quantities serve as the pigeons and holes in the standard proof?
Not quite. Try another option.
Answer: Prefix sums modulo are the pigeons; the residue classes are the holes
Consider prefix sums ; that is values over residue classes mod . Two must share a residue, and the difference of those prefix sums is a contiguous subset sum divisible by .
Question 60 of 60 · N-th non-square number · Hard
Why does the formula for the -th non-square number add rather than simply ?
Not quite. Try another option.
Answer: To correctly account for perfect squares that fall within the range as grows, rounding to the nearest integer
The count of perfect squares up to a value shifts the offset. Rounding to the nearest integer via correctly counts how many squares have been skipped up to the -th non-square, whereas plain flooring miscounts near square boundaries.
That's unit 2
Answer a few questions and your score shows up here.
Nearly through. Did unit 2 of CSE329 save you a night before the exam?
LPU Notes is free. A student pays for the servers.
Did unit 2 of CSE329 save you a night before the exam?
Then you can help keep it free for the next batch. 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.