Programming Data Structure And Algorithms Using Python Assignment 7

                     

Course Name: Programming Data Structure And Algorithms Using Python

Link of Course: Click Here

These are the solutions of Programming Data Structure And Algorithms Using Python Assignment 7


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

Answer:

'fjadcbeghi'

These are the solutions of Programming Data Structure And Algorithms Using Python Assignment 7


Q2) We want to add a function length() to the class Node that implements user defined lists which will compute the length of a list. An incomplete implementation of length() given below. You have to provide expressions to put in place of XXX, YYY. and ZZZ.
XXX : 0, YYY : 0, ZZZ : self.next.length()
XXX : 0, YYY : 0, ZZZ : 1+ self.next.length()
XXX : 0, YYY : 1, ZZZ : self.next.length()
XXX : 0, YYY : 1, ZZZ : 1+ self.next.length()

Answer: XXX : 0, YYY : 1, ZZZ : 1+ self.next.length()


These are the solutions of Programming Data Structure And Algorithms Using Python Assignment 7


Q3) 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?
The number of nodes in mytree.
The largest value in mytree.
The length of the longest path from root to leaf in mytree.
The number of paths in mytree.

Answer: The length of the longest path from root to leaf in mytree.


These are the solutions of Programming Data Structure And Algorithms Using Python Assignment 7


4) Inorder traversal of a binary tree has been defined in the lectures. A preorder traversal lists the vertices of a binary tree (not necessarily a search tree) as follows :
• Print the root.
• Print the left subtree in preorder.
• Print the right subtree in preorder.
Suppose we have a binary tree with 10 nodes labelled a, b, c, d, e, f, g, h, i, j, with preorder traversal gbhecidajf and inorder traversal ehbicgjafd. What is the right child of the root node?

Answer:

'd'

These are the solutions of Programming Data Structure And Algorithms Using Python Assignment 7

All weeks solution of Programming Data Structure And Algorithms Using Python: https://progies.in/answers/nptel/programming-data-structure-and-algorithms-using-python

More NPTEL Solutions: https://progies.in/answers/nptel


* The material and content uploaded on this website are for general information and reference purposes only. Please do it by your own first.


These are the solutions of Programming Data Structure And Algorithms Using Python Assignment 7