Explore topic-wise InterviewSolutions in .

This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.

1.

Let A={1,2,3} B={2,3,4} C={1,3,5} D={2,3}. Find the cardinality of sum of all the sets.(a) 6(b) 5(c) 4(d) 7This question was posed to me by my school teacher while I was bunking the class.The origin of the question is Number Theory topic in portion Number Theory of Data Structures & Algorithms II

Answer» CORRECT option is (b) 5

Best explanation: FIRST, include the cardinalities of all the sets. Then, exclude the cardinalities of EVEN intersections. Then include the cardinalities of ODD intersections. HENCE, 3+3+3+2-2-2-2-1-2-1+1+2+1+1-1=5.
2.

____________ is an arithmetic function that calculates the total number of positive integers less than or equal to some number n, that are relatively prime to n.(a) Euler’s phi function(b) Euler’s omega function(c) Cauchy’s totient function(d) Legrange’s functionI had been asked this question during an internship interview.The above asked question is from Number Theory topic in section Number Theory of Data Structures & Algorithms II

Answer»

The correct answer is (a) EULER’s PHI function

The BEST explanation: Euler’s phi function is an arithmetic function that calculates the TOTAL number of positive integers less than or equal to some number n, that are relatively PRIME to n. The inclusion-exclusion principle is used to obtain a formula for Euler’s phi function.

3.

Using the inclusion-exclusion principle, find the number of integers from a set of 1-100 that are not divisible by 2, 3 and 5.(a) 22(b) 25(c) 26(d) 33I got this question in unit test.My question is taken from Number Theory in portion Number Theory of Data Structures & Algorithms II

Answer»

The correct choice is (c) 26

Easiest explanation - Consider sample space S={1,…100}. Consider three subsets A, B, C that have ELEMENTS that are DIVISIBLE by 2, 3, 5 respectively. Find integers that are divisible by A and B, B and C, A and C. Then find the integers that are divisible by A, B, C. Applying the inclusion-exclusion principle, 100 − (50 + 33 + 20) + (16 + 10 + 6) − 3 = 26.

4.

Counting intersections can be done using the inclusion-exclusion principle only if it is combined with De Morgan’s laws of complementing.(a) true(b) falseThis question was posed to me in an online interview.The origin of the question is Number Theory topic in chapter Number Theory of Data Structures & Algorithms II

Answer»

The correct option is (a) true

For explanation: The APPLICATION of counting intersections can be fulfiled if and only if it is COMBINED with DE MORGAN laws to count the cardinality of intersection of sets.

5.

Which of the following statement is incorrect with respect to generalizing the solution using the inclusion-exclusion principle?(a) including cardinalities of sets(b) excluding cardinalities of pairwise intersections(c) excluding cardinalities of triple-wise intersections(d) excluding cardinalities of quadraple-wise intersectionsThe question was asked in an internship interview.This interesting question is from Number Theory in chapter Number Theory of Data Structures & Algorithms II

Answer»

The correct answer is (c) EXCLUDING cardinalities of triple-wise intersections

To EXPLAIN: According to inclusion-exclusion principle, an intersection is included if the intersecting ELEMENTS are odd and EXCLUDED, if the intersecting elements are even. HENCE triple-wise intersections should be included.

6.

With reference to the given Venn diagram, what is the formula for computing |AUBUC| (where |x, y| represents intersection of sets x and y)?(a) |A U B U C|=|A|+|B|+|C|-|A,B|-|A,C|-|B,C|+|A, B,C|(b) |A, B,C|=|A|+|B|+|C|-|A U B|-|A U C|-|B U C|+|A U B U C|(c) |A, B,C|=|A|+|B|+|C|+|A,B|-|A,C|+|B,C|+|A U B U C|(d) |A U B U C|=|A|+|B|+|C| + |A,B| + |A,C| + |B,C|+|A, B,C|I have been asked this question at a job interview.Query is from Number Theory in section Number Theory of Data Structures & Algorithms II

Answer»

Right answer is (a) |A U B U C|=|A|+|B|+|C|-|A,B|-|A,C|-|B,C|+|A, B,C|

Best explanation: The formula for COMPUTING the union of three SETS using inclusion-exclusion principle is|A U B U C|=|A|+|B|+|C|-|A,B|-|A,C|-|B,C|+|A, B,C|where |A,B|, |B,C|, |A,C|, |A,B,C| represents the intersection of the sets A and B, B and C, A and C, A, B and C respectively.

7.

According to inclusion-exclusion principle, a n-tuple wise intersection is included if n is even.(a) True(b) FalseThe question was asked in an interview.My doubt is from Number Theory in chapter Number Theory of Data Structures & Algorithms II

Answer»

The CORRECT option is (B) False

The best explanation: According to inclusion-exclusion PRINCIPLE, a N-tuple wise intersection is included if n is odd and excluded if n is even.

8.

Who invented the concept of inclusion-exclusion principle?(a) Abraham de Moivre(b) Daniel Silva(c) J.J. Sylvester(d) SieveThis question was posed to me in my homework.This question is from Number Theory topic in portion Number Theory of Data Structures & Algorithms II

Answer»

The CORRECT answer is (a) Abraham de Moivre

Best explanation: The concept of inclusion- exclusion principle was INITIALLY INVENTED by Abraham de Moivre in 1718 but it was published first by Daniel Silva in his PAPER in 1854.

9.

Which of the following is not an application of inclusion-exclusion principle?(a) Counting intersections(b) Graph coloring(c) Matching of bipartite graphs(d) Maximum flow problemI have been asked this question by my college director while I was bunking the class.This intriguing question originated from Number Theory in portion Number Theory of Data Structures & Algorithms II

Answer»

The correct option is (d) Maximum flow PROBLEM

The best I can explain: Counting intersections, Graph COLORING and Matching of bipartite graphs are all EXAMPLES of inclusion-exclusion principle whereas maximum flow problem is SOLVED USING Ford-Fulkerson algorithm.

10.

____________ is one of the most useful principles of enumeration in combinationatorics and discrete probability.(a) Inclusion-exclusion principle(b) Quick search algorithm(c) Euclid’s algorithm(d) Set theoryThe question was asked in an interview for job.The above asked question is from Number Theory topic in division Number Theory of Data Structures & Algorithms II

Answer»

Correct option is (a) Inclusion-exclusion principle

Explanation: Inclusion-exclusion principle SERVES as one of the most useful PRINCIPLES of enumeration in combinationatorics and discrete probability because it provides SIMPLE FORMULA for generalizing RESULTS.

11.

Which of the following is a correct representation of inclusion exclusion principle (|A,B| represents intersection of sets A,B)?(a) |A U B|=|A|+|B|-|A,B|(b) |A,B|=|A|+|B|-|A U B|(c) |A U B|=|A|+|B|+|A,B|(d) |A,B|=|A|+|B|+|A U B|The question was asked in final exam.Enquiry is from Number Theory topic in portion Number Theory of Data Structures & Algorithms II

Answer»

The correct option is (a) |A U B|=|A|+|B|-|A,B|

Explanation: The FORMULA for computing the union of two sets according to inclusion-exclusion principle is |A U B|=|A|+|B|-|A,B| where |A,B| REPRESENTS the INTERSECTION of the sets A and B.

12.

Which one of the following problem types does inclusion-exclusion principle belong to?(a) Numerical problems(b) Graph problems(c) String processing problems(d) Combinatorial problemsThis question was posed to me in my homework.My doubt stems from Number Theory in chapter Number Theory of Data Structures & Algorithms II

Answer»

The correct option is (d) Combinatorial problems

Easiest explanation - Inclusion-Exclusion principle is a kind of combinatorial problem. It is a COUNTING technique to obtain the NUMBER of elements present in SETS( two, THREE , etc.,).

13.

What will be the output of the code that generates permutations and also has the ability to handle duplicates, for the input str[]=”AA”?(a) AA(b) AA,AA(c) A,A(d) AThis question was addressed to me in an international level competition.I'm obligated to ask this question of Number Theory topic in portion Number Theory of Data Structures & Algorithms II

Answer»

Correct choice is (a) AA

Easy EXPLANATION - If a CODE is able to HANDLE duplicates then the two A’s are not CONSIDERED to be different elements DUE to which only one permutation will be formed. So the output will be AA only.

14.

Heap’s algorithm requires an auxiliary array to create permutations.(a) true(b) falseThe question was asked during an internship interview.This question is from Number Theory in chapter Number Theory of Data Structures & Algorithms II

Answer»

Correct OPTION is (b) false

Easy explanation - HEAP’s algorithm does not require any extra ARRAY for generating PERMUTATIONS. Thus it is ABLE to keep its space requirement to a very low level. This makes it preferable algorithm for generating permutations.

15.

What is the time complexity of Heap’s algorithm?(a) O(n log n)(b) O(n^2)(c) O(n*n!)(d) O(n!)This question was posed to me by my college professor while I was bunking the class.My question is taken from Number Theory in portion Number Theory of Data Structures & Algorithms II

Answer»

Right OPTION is (d) O(N!)

The explanation is: The recurrence RELATION for the HEAP’s algorithm is given by the expression T(n)=n * T(n-1). It is CALCULATED by using substitution method. It is found to be equal to O(n!).

16.

How many permutations will be formed from the array arr={1,2,3}?(a) 2(b) 4(c) 6(d) 8I got this question during a job interview.Question is taken from Number Theory in portion Number Theory of Data Structures & Algorithms II

Answer»

Correct OPTION is (c) 6

The best I can explain: No.of PERMUTATIONS for an ARRAY of size n will be GIVEN by the formula nPn. So for the given problem, we have 3P3=6 or 3!=6.

17.

What will be the lexicographical order of permutations formed from the array arr={1,2,3}?(a) {{2,1,3},{3,2,1},{3,1,2},{2,3,1},{1,2,3},{1,3,2}}(b) {{1,2,3},{1,3,2},{2,3,1},{2,1,3},{3,2,1},{3,1,2}}(c) {{1,2,3},{1,3,2},{2,1,3},{2,3,1},{3,1,2},{3,2,1}}(d) {{2,1,3},{3,1,2},{3,2,1},{2,3,1},{1,2,3},{1,3,2}}I got this question in an interview.Enquiry is from Number Theory topic in chapter Number Theory of Data Structures & Algorithms II

Answer»

The correct option is (c) {{1,2,3},{1,3,2},{2,1,3},{2,3,1},{3,1,2},{3,2,1}}

Explanation: The NUMBER of permutations for the problem will be 6 according to the FORMULA 3P3. When ORDERED in LEXICOGRAPHICAL manner these will be {{1,2,3},{1,3,2},{2,1,3},{2,3,1},{3,1,2},{3,2,1}}.

18.

What should be the return type of rand() function?(a) int(b) float(c) long(d) doubleI got this question in homework.I need to ask this question from Number Theory topic in portion Number Theory of Data Structures & Algorithms II

Answer»

The correct OPTION is (a) int

Easiest explanation - The return TYPE of RAND () is int. It can generate random NUMBERS from 0 to RAND_MAX.

19.

The dictionary ordering of elements is known as?(a) Lexicographical order(b) Colexicographical order(c) Well order(d) SortingThis question was posed to me by my college director while I was bunking the class.My question is based upon Number Theory in section Number Theory of Data Structures & Algorithms II

Answer»

Correct option is (a) LEXICOGRAPHICAL order

The best I can explain: Lexicographical order is also known as DICTIONARY order. It is a generalized method of the WAY words are alphabetically ORDERED in a dictionary.

20.

What is the purpose of using function srand()?(a) to set the seed of rand() function(b) to generate random numbers(c) to enable rand() function(d) to improve efficiency of rand()I got this question in an online interview.The query is from Number Theory in division Number Theory of Data Structures & Algorithms II

Answer»

Correct answer is (a) to SET the SEED of RAND() function

Easiest EXPLANATION - The function srand() sets the seed of rand(). It can be used to GENERATE a unique set of random numbers every time.

21.

What is pseudo random number generator?(a) an algorithm that generates random numbers with help of mathematical formula(b) an algorithm that generates random numbers according to user activity(c) an algorithm that generates random numbers according to time(d) an algorithm that generates random numbers with help of user inputI have been asked this question by my school teacher while I was bunking the class.This question is from Number Theory in portion Number Theory of Data Structures & Algorithms II

Answer»

The correct OPTION is (a) an algorithm that GENERATES random numbers with help of mathematical formula

The explanation is: A pseudo random NUMBER generator generates random numbers with the help of a mathematical formula. We can seed the random number generator with a different value EVERYTIME if we want unique random numbers to be generated.

22.

How many iterating statements are involved in the naïve method of matrix multiplication?(a) 1(b) 2(c) 3(d) 4I had been asked this question in examination.The above asked question is from Number Theory topic in chapter Number Theory of Data Structures & Algorithms II

Answer» CORRECT answer is (c) 3

To explain: In the naïve method of matrix multiplication the number of ITERATING statements involved are 3, because of the presence of rows and COLUMNS in a matrix. The element in each row of the FIRST matrix is MULTIPLIED with each element in the column of the second matrix.
23.

Strassen’s Matrix Algorithm was proposed by _____________(a) Volker Strassen(b) Andrew Strassen(c) Victor Jan(d) Virginia WilliamsThe question was posed to me in examination.My enquiry is from Number Theory in portion Number Theory of Data Structures & Algorithms II

Answer»

Right CHOICE is (a) Volker Strassen

Best explanation: Strassen’s MATRIX multiplication algorithm was first published by Volker Strassen in the year 1969 and proved that the n^3 general matrix multiplication algorithm wasn’t OPTIMAL.

24.

Strassen’s algorithm is quite numerically stable as the naïve method.(a) True(b) FalseThis question was addressed to me during an interview.This is a very interesting question from Number Theory in chapter Number Theory of Data Structures & Algorithms II

Answer»

Right answer is (b) False

Easiest explanation - Strassen’s ALGORITHM is too numerically UNSTABLE for some applications.The computed result C=AB satisfies the INEQUALITY with a unit ROUNDOFF error which corresponds to strong STABILITY inequality(obtained by replacing matrix norms with absolute values of the matrix elements).

25.

What is the formula to calculate the element present in second row, first column of the product matrix?(a) M1+M7(b) M1+M3(c) M2+M4 – M5 + M7(d) M2+M4The question was posed to me during an online interview.This key question is from Number Theory in portion Number Theory of Data Structures & Algorithms II

Answer»

The correct OPTION is (d) M2+M4

The EXPLANATION is: The element at second ROW, first column can be found by the formula M2 + M4, where M2 and M4 can be calculated by

M2= (A(2,1) + A(2,2)) B(1,1)

M4=A(2,2)(B(1,2) – B(1,1)).

26.

Who discussed techniques for reducing the memory requirements for Strassen’s algorithm?(a) Strassen(b) Lederman(c) Bailey(d) HighamI had been asked this question in examination.This interesting question is from Number Theory topic in division Number Theory of Data Structures & Algorithms II

Answer»

Right answer is (c) Bailey

Explanation: The submatrices formed at the LEVELS of recursion consume SPACE. Hence in ORDER to overcome that Bailey discussed TECHNIQUES for reducing the memory required.

27.

What is the recurrence relation used in Strassen’s algorithm?(a) 7T(n/2) + Theta(n^2)(b) 8T(n/2) + Theta(n^2)(c) 7T(n/2) + O(n^2)(d) 8T(n/2) + O(n^2)This question was addressed to me during an interview for a job.My enquiry is from Number Theory in division Number Theory of Data Structures & Algorithms II

Answer»

Right choice is (a) 7T(n/2) + Theta(n^2)

To explain: The recurrence RELATION used in STRASSEN’s algorithm is 7T(n/2) + Theta(n^2) since there are only 7 recursive MULTIPLICATIONS and Theta(n^2) scalar additions and subtractions involved for computing the product.

28.

Who demonstrated the difference in numerical stability?(a) Strassen(b) Bailey(c) Lederman(d) HighamThis question was addressed to me in a national level competition.I would like to ask this question from Number Theory in section Number Theory of Data Structures & Algorithms II

Answer»

The correct option is (d) Higham

Best explanation: The DIFFERENCE in the NUMERICAL stability was demonstrated by Higham. He overemphasized that STRASSEN’s algorithm is numericaly UNSTABLE for some APPLICATIONS.

29.

Running time of Strassen’s algorithm is better than the naïve Theta(n^3) method.(a) True(b) FalseI had been asked this question during an interview.Origin of the question is Number Theory topic in division Number Theory of Data Structures & Algorithms II

Answer»

Correct ANSWER is (a) True

To explain: Strassen’s ALGORITHM requires only 7 recursive multiplications when compared with the naïve THETA(n^3) method which reuires 9 recursive multiplications to compute the product.

30.

The number of scalar additions and subtractions used in Strassen’s matrix multiplication algorithm is ________(a) O(n^2.81)(b) Theta(n^2)(c) Theta(n)(d) O(n^3)This question was posed to me in semester exam.The origin of the question is Number Theory topic in portion Number Theory of Data Structures & Algorithms II

Answer»

Correct answer is (b) THETA(n^2)

EXPLANATION: Using Theta(n^2) scalar additions and subtractions, 14 matrices are computed each of which is n/2 X n/2. Then seven matrix products are computed RECURSIVELY.

31.

Strassen’s matrix multiplication algorithm follows ___________ technique.(a) Greedy technique(b) Dynamic Programming(c) Divide and Conquer(d) BacktrackingThe question was posed to me by my college professor while I was bunking the class.This interesting question is from Number Theory in division Number Theory of Data Structures & Algorithms II

Answer»

Right answer is (c) Divide and Conquer

Best explanation: Strassen’s matrix multiplication algorithm follows divide and conquer technique. In this algorithm the input matrices are divided into n/2 X n/2 sub matrices and then the RECURRENCE RELATION is applied.

32.

What is the running time of naïve matrix multiplication algorithm?(a) O(n^2.81)(b) O(n^4)(c) O(n)(d) O(n^3)I had been asked this question during an interview.I'd like to ask this question from Number Theory topic in portion Number Theory of Data Structures & Algorithms II

Answer»

Correct answer is (d) O(n^3)

The best explanation: The traditional matrix MULTIPLICATION algorithm takes O(n^3) TIME. The number of recursive MULTIPLICATIONS involved in this algorithm is 8.

33.

What is the running time of Strassen’s algorithm for matrix multiplication?(a) O(n^2.81)(b) O(n^3)(c) O(n^1.8)(d) O(n^2)I got this question during an interview.I want to ask this question from Number Theory in chapter Number Theory of Data Structures & Algorithms II

Answer»

Correct answer is (a) O(n^2.81)

The best EXPLANATION: Strassen’s matrix algorithm requires only 7 RECURSIVE multiplications of n/2 x n/2 matrix and THETA(n^2) SCALAR ADDITIONS and subtractions yielding the running time as O(n^2.81).

34.

Strassen’s algorithm is a/an_____________ algorithm.(a) Non- recursive(b) Recursive(c) Approximation(d) AccurateI got this question during an interview.The question is from Number Theory in chapter Number Theory of Data Structures & Algorithms II

Answer» CORRECT CHOICE is (b) Recursive

The EXPLANATION is: Strassen’s Algorithm for MATRIX multiplication is a recursive algorithm since the present output depends on previous outputs and INPUTS.
35.

What is the GCD of 20 and 12 using Euclid’s algorithm?(a) 8(b) 2(c) 4(d) 6This question was addressed to me in final exam.The doubt is from Number Theory in portion Number Theory of Data Structures & Algorithms II

Answer»

The CORRECT ANSWER is (c) 4

Explanation: GCD(m,n)=GCD(n, m MOD n)

GCD(20,12)=GCD( 12,8)

= GCD(8,4)

= GCD(4,0) = 4.

36.

What is the total running time of the binary GCD algorithm?(a) O(N)(b) O(N^2)(c) O(log N)(d) O(N log N)The question was asked during an online exam.Question is taken from Number Theory topic in chapter Number Theory of Data Structures & Algorithms II

Answer»

Right choice is (B) O(N^2)

For explanation: Binary GCD algorithm is a sub division of Euclidean algorithm with more FASTER operations. Its running TIME is given by O(N^2).

37.

What is the formula for Euclidean algorithm?(a) GCD (m,n) = GCD (n, m mod n)(b) LCM(m,n)=LCM(n, m mod n)(c) GCD(m,n,o,p) = GCD (m, m mod n, o, p mod o)(d) LCM (m,n,o,p) = LCM (m, m mod n, o, p mod o)The question was asked in unit test.I'm obligated to ask this question of Number Theory topic in chapter Number Theory of Data Structures & Algorithms II

Answer»

The correct option is (a) GCD (m,n) = GCD (n, m MOD n)

The best explanation: The FORMULA for computing GCD of two numbers using Euclidean ALGORITHM is given as GCD (m,n)= GCD (n, m mod n). It is used recursively until ZERO is obtained as a remainder.

38.

Euclidean algorithm does not require the calculation of prime factors.(a) True(b) FalseI had been asked this question during an internship interview.I'd like to ask this question from Number Theory in portion Number Theory of Data Structures & Algorithms II

Answer»

The correct choice is (a) True

The explanation is: EUCLID’s algorithm does not require the CALCULATION of prime factors. We derive the answer STRAIGHT away USING formula. And also, factorization is complex.

39.

What is the total running time of Euclid’s algorithm?(a) O(N)(b) O(N log M)(c) O(N log N)(d) O(log N +1)I have been asked this question in an interview.My enquiry is from Number Theory in section Number Theory of Data Structures & Algorithms II

Answer»

The correct CHOICE is (a) O(N)

The BEST explanation: The total running time of EUCLID’s algorithm according to Lame’s analysis is found to be O(N).

40.

If GCD of two numbers is 1, then the two numbers are said to be ________(a) Co-prime numbers(b) Prime numbers(c) Composite numbers(d) Rational numbersThis question was addressed to me in an interview for internship.My question is taken from Number Theory in section Number Theory of Data Structures & Algorithms II

Answer»

Right choice is (a) Co-prime numbers

The best I can EXPLAIN: If GCD of two numbers is 1, they are called as co-prime or relatively prime numbers. It does not MEAN that they are prime numbers. They don’t have any prime factors in COMMON.

41.

Which of the following is the correct mathematical application of Euclid’s algorithm?(a) Determination of prime numbers(b) Lagrange’s four square theorem(c) Cauchy-Euler theorem(d) Residue theoremI got this question in a job interview.This is a very interesting question from Number Theory in division Number Theory of Data Structures & Algorithms II

Answer»

The CORRECT choice is (b) Lagrange’s FOUR square theorem

Easy explanation - Lagrange’s four square theorem is ONE of the mathematical applications of Euclid’s algorithm and it is the basic tool for proving theorems in number THEORY. It can be generalized into other TYPES of numbers like the Gaussian integers.

42.

According to Gabriel lame, how many steps does Euclid’s algorithm require to solve a problem?(a) Less than five times the number of digits(b) More than five times the number of digits(c) Less than two times the number of digits(d) More than two times the number of digitsI got this question in unit test.My doubt stems from Number Theory in chapter Number Theory of Data Structures & Algorithms II

Answer»

Right option is (a) Less than five times the number of digits

Best explanation: The EUCLID’s algorithm requires less than five times the number of digits. It runs by DIVIDING two NUMBERS. It stops when a remainder ZERO is reached.

43.

The Euclid’s algorithm runs efficiently if the remainder of two numbers is divided by the minimum of two numbers until the remainder is zero.(a) True(b) FalseI had been asked this question by my college director while I was bunking the class.The query is from Number Theory topic in portion Number Theory of Data Structures & Algorithms II

Answer»

Correct choice is (a) True

For explanation: The Euclid’s algorithm runs EFFICIENTLY if the remainder of two NUMBERS is DIVIDED by the MINIMUM of two numbers until the remainder is zero. This improvement in efficiency was put forth by Gabriel Lame.

44.

Who invented Euclid’s algorithm?(a) Sieve(b) Euclid(c) Euclid-Sieve(d) Gabriel lameI have been asked this question during an online interview.I'd like to ask this question from Number Theory in section Number Theory of Data Structures & Algorithms II

Answer»

The correct choice is (b) Euclid

To EXPLAIN: Euclid invented Euclid’s ALGORITHM. Sieve PROVIDED an algorithm for finding prime numbers. Gabriel lame proved a theorem in Euclid’s algorithm.

45.

Which of the following is not an application of Euclid’s algorithm?(a) Simplification of fractions(b) Performing divisions in modular arithmetic(c) Solving quadratic equations(d) Solving diophantine equationsThe question was posed to me during an online interview.This interesting question is from Number Theory topic in division Number Theory of Data Structures & Algorithms II

Answer»

Correct choice is (C) SOLVING quadratic equations

Easy explanation - Solving quadratic equations is not an application of Euclid’s algorithm WHEREAS the rest of the OPTIONS are mathematical APPLICATIONS of Euclid’s algorithm.

46.

If 4 is the GCD of 16 and 12, What is the GCD of 12 and 4?(a) 12(b) 6(c) 4(d) 2The question was asked in a job interview.Query is from Number Theory in portion Number Theory of Data Structures & Algorithms II

Answer»

The correct choice is (C) 4

The BEST I can EXPLAIN: Euclid’s ALGORITHM states that the GCD of two NUMBERS does not change even if the bigger number is replaced by a difference of two numbers. So, GCD of 16 and 12 and 12 and (16-12)=4 is the same.

47.

Euclid’s algorithm is used for finding ___________(a) GCD of two numbers(b) GCD of more than three numbers(c) LCM of two numbers(d) LCM of more than two numbersI had been asked this question in a national level competition.This interesting question is from Number Theory topic in division Number Theory of Data Structures & Algorithms II

Answer»

The correct option is (a) GCD of TWO numbers

To explain: EUCLID’s algorithm is basically USED to find the GCD of two numbers. It cannot be DIRECTLY APPLIED to three or more numbers at a time.