NPTEL Programming, Data Structures And Algorithms Using Python Week 7 Assignment Answers 2025

NPTEL Programming, Data Structures And Algorithms Using Python Week 7 Assignment Answers 2025

1. 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 :- For Answers Click Here 

2. 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)
  • AAA: 0, BBB: self.value, CCC: min(self.value, self.next.listmin())
  • AAA: 0, BBB: self.value, CCC: min(self.value, self.next.value)
  • AAA: None, BBB: self.value, CCC: min(self.value, self.next.listmin())
  • AAA: None, BBB: self.value, CCC: min(self.value, self.next.value)
Answer :- 

3. 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())
  • The sum of the elements in the tree
  • The maximum sum across all root to leaf paths in the tree
  • The length of the longest root to leaf path in the tree
  • The number of root to leaf paths in the tree.
Answer :- 

4. 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?

  • 22
  • 28
  • 38
  • 52
Answer :- For Answers Click Here 
Scroll to Top