Powered By Blogger

May 19, 2022

MFC-UNIT-1-5.The Basics of Counting

 

The Basics of Counting

1.        1

How many even 4 digit whole numbers are there?

a) 1358

b) 7250

c) 4500

d) 3600

 

Answer: c

Explanation: The thousands digit cannot be zero, so there are 9 choices. There are 10 possibilities for the hundreds digit and 10 possibilities for the tens digit. The units digit can be 0, 2, 4, 6 or 8, so there are 5 choices. By the basic counting principle, the number of even five digit whole numbers is 9 × 10 × 10 × 5 = 45,00.

C

2.        2

In a multiple-choice question paper of 15 questions, the answers can be A, B, C or D. The number of different ways of answering the question paper are ________

a) 65536 x 47

b) 194536 x 45

c) 23650 x 49

d) 11287435

 

Answer: a

Explanation: There are 415 = 65536 x 47 different ways of answering the exam paper of 15 MCQs.

A

3.        3

How many words with seven letters are there that start with a vowel and end with an A? Note that they don’t have to be real words and letters can be repeated.
a) 45087902
b) 64387659
c) 12765800
d) 59406880

Answer: d
Explanation: The first letter must be a vowel, so there are 5 choices. The second letter can be any one of 26, the third letter can be any one of 26, the fourth letter can be any one of 26 and fifth and sixth letters can be any of 26 choices. The last letter must be an A, so there is only 1 choice. By the basic counting principle, the number of ‘words’ is 5 × 26 × 26 × 26 × 26 × 26 × 1 = 59406880.

 

D

4.        4

A head boy, two deputy head boys, a head girl and 3 deputy head girls must be chosen out of a student council consisting of 14 girls and 16 boys. In how many ways can they are chosen?

a) 98072

b) 27384

c) 36428

d) 44389

 

Answer: b

Explanation: There are 16 × 15 × 14 + 14 × 13 × 12 × 11 = 27384 ways to choose from a student council.

B

5.        5

Amit must choose a seven-digit PIN number and each digit can be chosen from 0 to 9. How many different possible PIN numbers can Amit choose?
a) 10000000
b) 9900000
c) 67285000
d) 39654900

Answer: a
Explanation: By the basic counting principle, the total number of PIN numbers Amit can choose is 10 × 10 × 10 × 10 × 10 × 10 × 10 = 10,000000.

A

6.        6

The code for a safe is of the form PPPQQQQ where P is any number from 0 to 9 and Q represents the letters of the alphabet. How many codes are possible for each of the following cases? Note that the digits and letters of the alphabet can be repeated.

a) 874261140

b) 537856330

c) 549872700

d) 456976000

 

Answer: d

Explanation: 103 × 264 = 456976000 possible codes are formed for the safe with the alphanumeric digits.

D

7.        7

here are two different Geography books, five different Natural Sciences books, three different History books and four different Mathematics books on a shelf. In how many different ways can they be arranged if all the books of the same subjects stand together?

a) 353450

b) 638364

c) 829440

d) 768700

 

Answer: c

Explanation: There are four groups of books which can be arranged in 4! different ways. Among those books, two are Geography books, five are Natural Sciences books, three are History books and four are Mathematics books. Therefore, there are 4! × 2! × 5! × 3! × 4! = 829440 ways to arrange the books.

C

8.        8

For her English literature course, Ruchika has to choose one novel to study from a list of ten, one poem from a list of fifteen and one short story from a list of seven. How many different choices does Rachel have?
a) 34900
b) 26500
c) 12000
d) 10500

Answer: d
Explanation: By the Basic Counting Principle, the number of different choices is 10 × 15 × 7 = 10500.

 

D

9.        9

How many five-digit numbers can be made from the digits 1 to 7 if repetition is allowed?
a) 16807
b) 54629
c) 23467
d) 32354

Answer: a
Explanation: 75 = 16807 ways of making the numbers consisting of five digits if repetition is allowed.

 

A

1.    10

Neela has twelve different skirts, ten different tops, eight different pairs of shoes, three different necklaces and five different bracelets. In how many ways can Neela dress up?
a) 50057
b) 14400
c) 34870
d) 56732

Answer: b
Explanation: By the basic counting principle, the number of different ways = 12 × 10 × 8 × 3 × 5 = 14400. Note that shoes come in pairs. So she must choose one pair of shoes from ten pairs, not one shoe from twenty.

 

B

MFC-UNIT-1-4.Program Correctness

 

Program Correctness

1.        

Program verification, the proof of correctness of programs, uses the ______________.

A.      rules of inference

B.      rules of sum

C.      rule of multiplication

D.      rules of division

A

2.        

A program is said to be correct ____________________

A. if it produces the correct output for every possible input.

B. if it take input and produce output.

C. if it take zero input and produce no output.

D. if it produce output and withot input.

A

 

 

 

MFC-UNIT-1-3.Recursive Algorithms

 

Recursive Algorithms

1.        1

For a recursive algorithm _________

a.            a base case is necessary and is solved without recursion.

b.            a base case is not necessary

c.             doesnot solve a base case directly

d.            none of the mentioned

                Answer:a base case is not necessary

A

2.        2

1. Recursion is a method in which the solution of a problem depends on ____________

a) Larger instances of different problems

b) Larger instances of the same problem

c) Smaller instances of the same problem

d) Smaller instances of different problems

Answer: c

Explanation: In recursion, the solution of a problem depends on the solution of smaller instances of the same problem.

C

3.        3

Which of the following problems can’t be solved using recursion?

a) Factorial of a number

b) Nth fibonacci number

c) Length of a string

d) Problems without base case

 

Answer: d

Explanation: Problems without base case leads to infinite recursion call. In general, we will assume a base case to avoid infinite recursion call. Problems like finding Factorial of a number, Nth Fibonacci number and Length of a string can be solved using recursion.

D

4.        4

Recursion is similar to which of the following?

a) Switch Case

b) Loop

c) If-else

d) if elif else

 

Answer: b

Explanation: Recursion is similar to a loop.

B

5.        5

4. In recursion, the condition for which the function will stop calling itself is ____________

a) Best case

b) Worst case

c) Base case

d) There is no such condition

 

Answer: c

Explanation: For recursion to end at some point, there always has to be a condition for which the function will not call itself. This condition is known as base case.

C

6.        6

What is the output of the following code?

 

void my_recursive_function(int n)

{

    if(n == 0)

    return;

    printf("%d ",n);

    my_recursive_function(n-1);

}

int main()

{

    my_recursive_function(10);

    return 0;

}

 

a) 10

b) 1

c) 10 9 8 … 1 0

d) 10 9 8 … 1

 

Answer: d

Explanation: The program prints the numbers from 10 to 1.

 

7.        7

What is the output of the following code?

 

int cnt = 0;

void my_recursive_function(char *s, int i)

{

     if(s[i] == '\0')

        return;

     if(s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u')

     cnt++;

     my_recursive_function(s,i+1);

}

int main()

{

     my_recursive_function("thisisrecursion",0);

     printf("%d",cnt);

     return 0;

}

 

a) 6

b) 9

c) 5

d) 10

 

Answer: a

Explanation: The function counts the number of vowels in a string. In this case the number is vowels is 6.

A

8.        8

What will be the output of the following code?

 

int cnt=0;

void my_recursive_function(int n)

{

     if(n == 0)

     return;

     cnt++;

     my_recursive_function(n/10);

}

int main()

{

     my_recursive_function(123456789);

     printf("%d",cnt);

     return 0;

}

 

a) 123456789

b) 10

c) 0

d) 9

 

Answer: d

Explanation: The program prints the number of digits in the number 123456789, which is 9.

D

9.        9

Which of the following statements is true?

a) Recursion is always better than iteration

b) Recursion uses more memory compared to iteration

c) Recursion uses less memory compared to iteration

d) Iteration is always better and simpler than recursion

 

Answer: b

Explanation: Recursion uses more memory compared to iteration because every time the recursive function is called, the function call is stored in stack.

B

1.    10

What does the following recursive code do?

void my_recursive_function(int n)

{

     if(n == 0)

     return;

     my_recursive_function(n-1);

     printf("%d ",n);

}

int main()

{

     my_recursive_function(10);

     return 0;

}

a) Prints the numbers from 10 to 1
b) Prints the numbers from 10 to 0
c) Prints the numbers from 1 to 10
d) Prints the numbers from 0 to 10

Answer: c
Explanation: The above code prints the numbers from 1 to 10.

 

C

Featured Post

Data Analysis

    What is data analysis and its significance?   Data analysis is the process of collecting, transforming, and organizing data to dr...

Popular Posts