Python Quiz -Programming 11th Week Quiz Solution

1
1404
Python Quiz -Programming 11th Week Quiz Solution
Python Quiz -Programming 11th Week Quiz Solution

Disclaimer for ReGyan

If you require any more information or you have any problem regarding Copyright or have any questions about our site’s disclaimer, please feel free to contact us by email at [email protected].

Disclaimers for ReGyan

All the information on this website is published in good faith and for general information and educational purpose only. ReGyan does not make any warranties about the completeness, reliability, and accuracy of this information. Any action you take upon the information you find on this website (regyan.com), is strictly at your own risk. will not be liable for any losses and/or damages in connection with the use of our website.

 


The solutions of the 11th-week quiz are given below:-

[1]  In general, any recursive procedure can be expressed as an equivalent non-recursive procedure.

  • (a): True
  • (b): False

Answer: (a) True

[2] Suppose we want to write an algorithm to compute f(n) where f(n) = f(n-1) + f(n-2) and f(0) = 0, f(1) = 1. Which one of the following is true about this algorithm –

  • (a): This recursive algorithm is more efficient than the best iterative algorithm.
  • (b): This recursive algorithm and the best iterative algorithm are equally efficient
  • (c): This recursive algorithm is less efficient than the best iterative algorithm
  • (d): Nothing can be said about the relative efficiency of this recursive algorithm and the best iterative algorithms

Answer: (c) This recursive algorithm is less efficient than the best iterative algorithm

[3] Suppose we want to write an algorithm to compute factorial(n) where n>=0 and f(0) = 1. Which one of the following is true about this algorithm –

  • (a): This recursive algorithm is more efficient than the best iterative algorithm.
  • (b): This recursive algorithm and the best iterative algorithm are equally efficient
  • (c): This recursive algorithm is less efficient than the best iterative algorithm
  • (d): Nothing can be said about relative efficiency of this recursive algorithm and the best iterative algorithms

Answer: (b) This recursive algorithm and the best iterative algorithm are equally efficient.

[4] We should always use a recursive algorithm instead of its equivalent iterative algorithm to solve a problem because a recursive algorithm is easier to implement than equivalent iterative algorithm.

  • (a): True
  • (b): False

Answer: (b) False

[5] Which of the following is not true about Tower of Hanoi puzzle –

  • (a): puzzle consists of three rods
  • (b): Disks in a rod are kept as a stack with largest disk at the top
  • (c): Only one disk can be moved at a time
  • (d): A disk can only be moved if it is the uppermost disk on a stack

Answer: (b) Disks in a rod are kept as a stack with largest disk at the top




[6] If there are two disks initially in Tower of Hanoi puzzle then number of disk movements required to solve the puzzle will be –

  • (a): 1
  • (b): 2
  • (c): 3
  • (d): 4

Answer: (c) 3

[7] If n is the number of disks in Tower of Hanoi puzzle and T(n) is the required number of disk movements to solve the puzzle then –

  • (a): T(n) = T(n-1) + 1
  • (b): T(n) = 2*T(n-1) + 1
  • (c): T(n) = 3*T(n-1) + 1
  • (d): T(n) = T(n-1) – 1

Answer: (b) T(n) = 2*T(n-1) + 1

Also, see:  Python Programming Quiz – 10th Week Quiz Solution

[8] To solve Tower of Hanoi puzzle, which one of the following is true –

  • (a): A recursive algorithm is more efficient than an iterative algorithm
  • (b): Any recursive algorithm and any iterative algorithm are equally efficient
  • (c): A recursive algorithm is less efficient than an iterative algorithm
  • (d): Nothing can be said about relative efficiency of recursive and iterative algorithms

Answer: (b) Any recursive algorithm and any iterative algorithm are equally efficient

[9] If there are four disks initially in Tower of Hanoi puzzle then number of disk movements required to solve the puzzle will be –

  • (a): 13
  • (b): 14
  • (c): 15
  • (d): 16

Answer: (c) 15

[10] Sorting problem is to search a key in the given sorted sequence.

  • (a): True
  • (b): False

Answer: (b) False




[11] An example of a sorting problem is to arrange a given integer-sequence in increasing order.

  • (a): True
  • (b): False

Answer: (a) True

Also See:- Some Tips to Release Anger in 5 days

[12] What is easy to do in a sorted list –

  • (a): Searching a key
  • (b): Rank query
  • (c): Quantile query
  • (d): All

Answer: (d) All

[13] There is only one algorithm to solve sorting problem.

  • (a): True
  • (b): False

Answer: (b) False

[14] An English dictionary can be termed as a sorted list of strings over English alphabet.

  • (a): True
  • (b): False

Answer: (a) True

[15] Why are local variable names beginning with an underscore discouraged in python –

  • (a): They are used to indicate the private variables of a class
  • (b): They confuse the interpreter
  • (c): They are used to indicate global variables
  • (d): They slow down execution




Answer: (a) They are used to indicate the private variables of a class

That’s all for the 11th-week solution for Python Quiz -Programming. if you have any questions, please comment down below, we will try to answer with in the first 24 hours. I hope you liked this content.

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here