NPTEL Programming Data Structures And Algorithms Using Python ASSIGNMENT 2021

NPTEL Programming Data Structures And Algorithms Using Python

NPTEL Programming Data Structures And Algorithms Using Python This course is an introduction to programming and problem-solving in Python. This course helps students to understand the concepts of data structures and algorithms using python, without having any prior knowledge of programming concepts.

Programming Data Structures And Algorithms Using Python is a MOOC course offered by IIT Kharagpur on the NPTEL platform. This course helps the students to achieve problem-solving methods through a programming language. The course is developed by Prof. Madhavan Mukund studied at IIT Bombay (BTech) and Aarhus University (PhD).

  1. Who Can Join: All UG/PG students.
  2. Requirements/Prerequisites: Nil.
  3. INDUSTRY SUPPORT: All IT Industries

CRITERIA TO GET A CERTIFICATE

Average assignment score = 25% of the average of the best 6 assignments out of the total 8 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100 Final scores = Average assignment score + Exam score

Students will be eligible for CERTIFICATE ONLY IF AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If any of the 2 criteria are not met, the student will not get the certificate even if the Final score >= 40/100.

Programming Data Structures And Algorithms Using Python ASSIGNMENT WEEK 7 ANSWERS:-

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 as a sequence of letters without quotes and without any blank spaces between letters.

Answer:- eibjfacdgh

Q2. We want to add a function listmax() to the class Node that implements user defined lists such that listmax() computes the maximum value in a list where values are of type int.

An incomplete implementation of listmax() given below. You have to provide expressions to put in place of AAA, BBB and CCC.

Answer:- C

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?

Answer:- D

Q4. Inorder traversal of a binary tree has been defined in the lectures. A postorder traversal lists the vertices of a binary tree (not necessarily a search tree) as follows:

  • Print the left subtree in postorder.
  • Print the right subtree in postorder.
  • Print the root.

Suppose we have a binary tree with 10 nodes labelled a, b, c, d, e, f, g, h, i, j, with postorder traversal ehicbjfadg and inorder traversal ehbicgjafd. What is the left child of the root node? (Write your answer as a single letter, without quotes.)

Answer:- [b]

Programming Data Structures And Algorithms Using Python ASSIGNMENT WEEK 4 ANSWERS:-

Q1. Consider the following Python function.

def mystery(l):
    if l == []:
        return(l)
    else:
        return(mystery(l[1:])+l[:1])

What does mystery([22,34,18,57,92,45]) return?

Answer:- [45,92,57,18,34,22]

FOR PROGRAMMING ASSIGNMENT VISIT:- PROGRAMMING DS AND ALGO ASSIGNMENT

quizxp telegram
JOIN US FOR UPDATES

Q2. What is the value of pairs after the following assignment?

pairs = [ (x,y) for x in range(5,1,-1) for y in range(4,1,-1) if (x+y)%3 == 0 ]

Answer:- [(5,4),(4,2),(3,3),(2,4)]

Q3. Consider the following dictionary.

wickets = {"Tests":{"Ishant":[3,5,2,3],"Shami":[4,4,1,0],"Bumrah":[2,1,7,4]},"ODI":{"Ishant":[2,0],"Shami":[1,2]}}

Which of the following statements does not generate an error?

Answer:- C

Q4. Assume that hundreds has been initialized as an empty dictionary:

hundreds = {}

Answer:- C

Programming Data Structures And Algorithms Using Python ASSIGNMENT WEEK 2 ANSWERS:-

Q1. One of the following 10 statements generates an error. Which one? (Your answer should be a number between 1 and 10.)

x = ["slithy",[7,10,12],2,"tove",1]  # Statement 1
y = x[0:50]                          # Statement 2
z = y                                # Statement 3
w = x                                # Statement 4
x[0] = x[0][:5] + 'ery'              # Statement 5
y[2] = 4                             # Statement 6
z[4] = 42                            # Statement 7
w[0][:3] = 'fea'                     # Statement 8
x[1][0] = 5555                       # Statement 9
a = (x[4][1] == 1)                   # Statement 10

Answer:- 8

Q2. Consider the following lines of Python code.

b = [23,44,87,100]
a = b[1:]
d = b[2:]
c = b
d[0] = 97
c[2] = 77

Answer:- a[1] == 87, b[2] == 77, c[2] == 77, d[0] == 97

FOR PROGRAMMING ASSIGNMENT VISIT:- PROGRAMMING DS AND ALGO ASSIGNMENT

Q3. What is the value of endmsg after executing the following lines?

startmsg = "python"
endmsg = ""
for i in range(1,1+len(startmsg)):
  endmsg = startmsg[-i] + endmsg

Answer:-“p”

Q4. What is the value of mylist after the following lines are executed?

def mystery(l):
  l = l[1:]
  return()

mylist = [7,11,13]
mystery(mylist)

Answer:- [7, 11, 13]

FOR PROGRAMMING ASSIGNMENT VISIT:- PROGRAMMING DS AND ALGO ASSIGNMENT

quizxp telegram
JOIN US FOR UPDATES

Programming Data Structures And Algorithms Using Python ASSIGNMENT WEEK 1 ANSWERS:-

Q1. What is the value of g(728) for the function below?

def g(y):
    b = 0
    while y >= 3:
        (y,b) = (y/3,b+1)
    return(b)

Answer:- 5

quizxp telegram
JOIN US FOR UPDATES

Q2. What is f(90)-f(89), given the definition of f below?

def f(n):
    s = 0
    for i in range(2,n):
        if n%i == 0 and i%2 == 1:
            s = s+1
    return(s)

Answer:- 5

Q3. Consider the following function h. The function h(n) given above returns False for a positive number n if and only if:

def h(n):
    s = True
    for i in range(1,n+1):
        if i*i == n:
            s = False
    return(s)

Answer:- C – n is a perfect square.

Q4.Consider the following function fpp.

def foo(m):
    if m == 0:
      return(0)
    else:
      return(m+foo(m-1))

Answer:- D – The function terminates for nonĀ­negative n with f(n) = n(n+1)/2

quizxp telegram
JOIN US FOR UPDATES

Also Check:- INTERNSHIP OPPORTUNITIES