Programming, Data Structures And Algorithms Using Python - Week 7 Quiz | NPTEL | [Jan 2023]

Programming, Data Structures And Algorithms Using Python - Week 7 Quiz | NPTEL Jan 2023 | Answer with Explanation

Programming, Data Structures And Algorithms Using Python - Week 7 Quiz | NPTEL Jan 2023 | Answer with Explanation

Given the following permutation of a,b,c,d,e,f,g,h,i,j, what is the previous permutation in lexicographic (dictionary) order? Write your answer without any blank spaces between letters.

ghadbicefj

Answer

ghadbfjiec

We want to add a function listmin() to the class Node that implements user defined lists such that listmin() computes the minimum value in a list of values of type int.
An incomplete implementation of listmin() given below. You have to provide expressions to put in place of AAA, BBB and CCC.

   def listmin(self):
        if self.value == None:
            return(AAA)
        elif self.next == None:
            return(BBB)
        else:
            return(CCC)
  
a. AAA: 0, BBB: self.value, CCC: min(self.value, self.next.listmin())
b. AAA: 0, BBB: self.value, CCC: min(self.value, self.next.value)
c. AAA: None, BBB: self.value, CCC: min(self.value, self.next.listmin())
d. AAA: None, BBB: self.value, CCC: min(self.value, self.next.value)
Answer

c. AAA: None, BBB: self.value, CCC: min(self.value, self.next.listmin())

Suppose we add this function foo() to the class Tree that implements search trees. For a name mytree with a value of type Tree, what would mytree.foo() compute?

def foo(self):
        if self.isempty():
            return(0)
        elif self.isleaf():
            return(1)
        else:
            return(self.left.foo() + self.right.foo())
a. The sum of the elements in the tree
b. The maximum sum across all root to leaf paths in the tree
c. The length of the longest root to leaf path in the tree
d. The number of root to leaf paths in the tree.
Answer

d. The number of root to leaf paths in the tree.

The postorder traversal of a binary search tree with integer values produces the following sequence: 22, 38, 28, 49, 48, 58, 61, 52, 45. What is the value of the left child of the root of the tree?

a. 22
b. 28
c. 38
d. 52
Answer

b. 28

Disclaimer:
"This page contains multiple choice questions (MCQs) related to Programming, Data Structures And Algorithms Using Python. The answers to these questions are provided for educational and informational purposes only.These answers are provided only for the purpose to help students to take references. This website does not claim any surety of 100% correct answers. So, this website urges you to complete your assignment yourself."

Programming, Data Structures And Algorithms Using Python,NPTEL, Week 7 Quiz [Jan 2023],noc23_cs15

Post a Comment

0 Comments