Old Question DSA Using Python (1)
Old Question DSA Using Python (1)
com/c/getpythoncode
Contact me at [email protected]
Telegram id - @AK4Gp
Uploaded by youtube.com/c/getpythoncode
Contact me at [email protected]
Telegram id - @AK4Gp
Your last recorded submission was on
All questions carry
2020-01-28, 21:09 IST
equalweightage.
Al Python
aline final submission will be
raded
code is assumed to be executed using
Python3. You may submit as many times as B
you
1) What is the value of f(4000) for the function
below/?
def f(x):
d
while x > 1:
(x,d)(x/5,d+1)
hon return(d)
ceturn()
6
for i in range(2,n):
if n%i == 0:
s S+i
return(s)
35
3) For what value of n would g(637,n) return 4? If there are multiple possibilities. write any one
def g(m,n):
res 0
uhile m n:
(res,m)-(res+1,m/n)
returnres)
35
3) For what value of n would g(637,n) return 4? If there are mutiple possiblities, write any one
def nys(m):
if m 1:
return(1
else:
return(mmys (n-1))
5
def mys(m):
f m 1:
return(1)
else:
return(m+my's (m-1))
x
[1,"abcd",, "efgh",[3,4]] * Statement 1
y x[®:6] #Statement
#Statement 3
wy # Statement
x[1] x[1][0:3] *d # Statement
y[2] = 4
#Statement
z[1][1:3] 'yzw' # Statement
# Statement 8
w[41[e] = 1000 #Statement 9
a (x[4][1] == 4) # Statement 10
25po-
2) Consider the following lines of Python code 25 po
u u[0:
Statement
z[e] e #Statement 8
w[4][e] 1000 # Statement 9
a-(x[4][1] - 4) # Statement 10
7
2) Consider the following lines of Python code
x
=[423, 'b',37, 'f*]
u x[1:]
u uf0:]
u[1] 5 3
x[2] 4 7
x2]-
x/2]
47 y[1) 37, w2]
==
37 ul1] 53
==
x[2] 4 7 . yl1] ==
37,w2]= 47. uf1==53
x{2]==47, y[1]== 53, w2]= 47, ul[1]= 53
O 37, u[1] 53
x2]== 47. y[1] =37, w[2]=
==
37, ul1) 53
x2 47. yl1)== 53, w2]
= == ==
first = "tarantula"
Second = ""
tarantula
What is the value of list1 after the following lines are executed?
4)
def mystery(l) :
1 1[0:5]
return()
for i in range(len (first) -1,-1,-1):
second first[i] + second
tarantula
4) What is the value bf list1 ater the following lines are executed?
def mystery(1) :
1 1[e:5]
return(
list1
[44,71,12,8, 23, 17, 16]
mystery(list1)
144.71.12.8.23.17.16]
2
You maysubmit any number of times before the due date The final submission will be considered for grading
Submit Answers
Course All questions cary equal weightage Al Python code is assumed to be executed
outline using Python3 You may submt as many times as you like within the deadine Your
final submission wll be graded
How does an Note
NPTEL online f the question asks about a value of type string. remember to endose your
course work? answer in single or double quotes
. the question asks about a value of type 1ist, remember to encdose your
Week 1: answer in square brackets and use commas to separate list items
Introduction
1Consider the fotlowing Python funcsion
Week 1 Quiz
Week 2: stery(1,v):
i f len(1) 0 :
Basics of
eturn (v)
Pythe n
else:
Week 2
What does-ystery([ 2, 14, 19,65,82,55],1) retuan?
Programming
Assignment
2.5 points
Week 3:
Lists, 2)Whatisthe value of triples ofter the following esignment?
inductive
for
function triples [ (x.y,)
in range (5,7) if 2*xy> 3°z
for x in
range(2,4)
]
for y in
range(2,5)
definitions,
sorting
oninecourses.nptel.acin/noc20_cs26/unit?unit = 968assessme. Type "hels", "copyright", "credits" or 1icense" for nore informat ion.
>> def m y s t e r y , v )
ii Apps Downioads Giraffe Academy ython for Web De. Development Guid if len(1) * 8:
return (v)
Course
Assignment not submitted Due date: 202002-26. 23:591ST.
Al questions carry equal weightage All Python code is assumed to be executed
else:
return (ystery(1[ i -1],1[-1]+v))
outline using Python3 You may submt as many times as you like within the deadine Your
final submission wl be graded »ystery( (22, 14,19,65,82,55), 1)
File "<stdin>", 1ine 1
How does an Note ystery ((22,14,19,65, 82, 55], 1)
NPTEL online .H the queeston asks about a value of type string. remember to endose your tndentat ionE rror: unexpected indent
course work? answer in singe or double quotes >> =ystery((22,14,19,65,82,55),1)
H the question asks about a value of type list. remember to encdose your 258
Week 1 answer in square brackets and use commas to separate list tems
Introduction
1)Consider the following Python functon
Week 1 Quiz
Week 2
What doesystery([22, 14, 19, 65,82,55].1) retun?
Programming
Assignment 258
2.5 points
Week 3:
Lists 2yWhat is the value of triples sfter the following *ssignnent?
inductive
function riples y.z) for x in range(2,4) for y in range(2,5 for
definitions. n range(5,7) if 2x'y >3
sorting
return (v)
Week TQuz else:
return (mystery (1[ : -1],i[-1]+v))
Week 2: def mystery(1,v):
Besics of if len(1) 0 : ystery([22, 14, 19,65,82, 55), 1)
FEle <stdin>", 1ine 1
return (v)
Python ystery([22, 14,19, 65,82,55),1)
else:
Week 4:
runs
(Test": ("Rahul": [90, 14,35],"xohli":[103,73,42],"Pujar
Sorting. :[53,15,133,8]), "o01:("Sharms":(37,99],"Kohli:[63,47]))
Tuples,
Dictionaries, Which of the folowing statements does not generate an eror?
Passing
Functions, Oruns["00r"]("Rahul"].append([74])
List Oruns["o01"]("Rahul"].extend([74])
Comprehension Oruns( "o0r"|["Rehul"]to]-74
Oruns[ "o01"]["Rahul"]-174]
2.5 points
Python 3.8.1 (tags/V3. 8.1:1b293b6, Dec 18 2019,, 22:39:24) [MSC v.1916 32 bit (Intel)] on win32
C O i onlinecourses.nptel.acin/noc20_cs26/unit?unit=96&assessme. Type "help", "copyright", "credits" or "1icense" for more infornat íon.
» d e f mystery(,v):
i Apps Downloads Girafe Academy yhon for Web De Development Guid if len(1) * 8:
return (v)
2.5 points else:
Programming return (mystery(1[ : -1],1f-11+v))
Assignment 3)Consider the folowing dictionary 25 points
Comprehension
runs["o1"]["Rahul"ito]-74 >»
(2, 4, 5), (3, 3, 5), (3, 4, 5), (3, 4, 6)1
runsTest: (Rauiiso,14,35),*konii":[3, 103,73,42],"Pujara":[53, 15,13,8)),"001":("s
h a r m a " : [ 3 7 , 9 9 ] ." K o h l i : [63,47])}
append([74])
raceback (most recent call last):
4JAs ume that actor has been initlalzed as an empty dictionary 2.5 points
Quiz File stdin>", 1ine 1, in <module>
Keytrror: "Rahul"
Week 4
>> runs[°00I](*Rahul").extend( [74])
Qutz actomm( Traceback (most recent
File "<stdin>", line 1, in <module>
cal1 last):
Week 4 Keytrror : 'Rahul
Which of the folowing generates an eTor ? >»» runs["c01*]["Rahul"][®]-74
Programming
Assignment
Traceback (most recent call last)
File "<stdin>", line 1, in <module>
O sctor["star ["Rey","Ridley"]
ars"] -
Keytrror: "Rahul'
SCHEENCAST(MTI
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019,
O g r d m i n g , Data structure
KeyError: 'Rahul"
Text O actor["Star Hars, Rey"] "Ridley" >
runs["ODI"][ "Rahul"]-[74]
Transcripts >>> actor {
actor[["star Wars", "Rey"]] "Ridley" >actor["Star Wars"] ["Rey", "Ridley"]
O actor[("Star ars", "Rey")] = "Ridley"
Books actor["Star Wars, Rey"] "Ridley"
>>
SeEECAsOwaT
NPTEL Programming.
DataStructuesAndAlgorithmsUsing Python Announcements About the Course Ask a Question Progress Mentor
Course outline
Week 6 Quiz
How does an NPTEL online
course work? Your last recorded submission was on 2020-03-10, 08:35 IST Due date: 2020-03-11, 23:59 IST.
All questions carry equal weightage. All Python code is assumed to be executed using Python3. You may submit as many times as you like within the deadline.
Week 1 Quiz I f the question asks about a value of type string. remember to enclose your answer in singte or doutble quotes.
If the question asks about a value of type list. remember to enciose your answer in square brackets and use commas to separate list items
Week 2: Basics of Python u? 2.5 point
1) Suppose u and v both denote sets in Python. Under what conditon can we guarantee that u-(v-u)
sts WIT ingeYAIC ulv != u'v. Wnat can we conclude about u and v? 2.5 point
2) Suppose u and v both denote sets in Python. and
Week 1: Introduction Your final submission ill be graded
Note
Week 1 Quiz .If the question asks about a value of type string. remember to enclose your answer in single or double quotes.
I f the question asks about a value of type list. remember to enclose your answer in square brackets and use commas to separate list items.
Week 2: Basics of Python
Suppose uand vboth denote setsin Python Unde hat condition can we guarantee that u-(v-u) -- u? 2.5 point
Week 3 Programming
The sets u and v should overlap
The set v should be a subset ofthe set u.
Assignment
The set u should be a subset ofthe set v.
Week 4: Sorting, Tuples, This is true for any u and v.
Dictionaries, Passing
Functions, List 3) Which ofthe following does not correspond to a min-heap on the list of values [19.97,83.45.72.55.31,28.31.29] 2.5 point-
Comprehension
O[19, 28, 72. 31, 29,83, 97, 55, 45, 31]
Week 4 Quiz O[19, 31, 28, 45, 31. 97, 29, 72, 55, 83]
O[19, 28, 29, 31, 31, 45, 55, 72, 83, 97
HPam MATIC
SSäEkASTO) MATIe [19, 28, 29, 31, 45. 83, 97, 55, 72. 31]
The set v should be a subset of the setu
Assignment
This is true for any u and v.
You may submit any number of times before the due date. The final submission will be considered for grading.
week 2 Quiz
1) Given the following permutation of a.b.c.d.e.f.g.h.ij, what is the previous permutation in lexicographic (dictionary) order? Write your answer without any blank
Week 2 Programming spaces between letters.
Assignment
fjadchbegi
Week 3: Lists, inductive
function definitions, sorting
Jadcaihet
Week 3 Programming 2.5 points
Assignment
2) Assume we have defined a class Node that implements user defined lists of numbers. Each object node of type Node has two attributes node. value 2.5 points
Week 4: and node.next with the usual interpretation. We want to add a function sum) to the class Node which will compute the sum of values in the list. An incomplete
Sorting. Tuples,
Dictionaries, Passing implementation of sum() given below. Wnat should be put in place of X*X and YYY?
Functions, List def sum(self):
Comprehension if self.value -= None:
return(e)
Week 4 Quiz
elif self.next None:t
return(Xx)
Week 4 Programming
else:
Assignment return(YY)
Week 5: Exception handling,
inputoutput, file handling, Replace *xX by 1 and YYY by 1 +selfnext.sum()
string processing O Replace XXX by 1 and YYY by self.value+ setf.next sum()
Replace XXX by self.value and YYY by 1 + self next sum()
49RP5jtammiag Replacexxx by self.value and YYY by selfvalue + setf.next sum()
SSs33ASTOMATI
course work?
Week 7 Quiz
Week 1:Introduction Your last recorded submission was on 2020-03-18, 13:37 IST Due date: 2020-03-18, 23:59 IST.
cary equal weightage. All Python code is assumed to be executed using Python3. You may submit
Week 1 Quiz All questions
Your final submission will be graded
as many times as you like within the deadline.
Week 3 Programming
Tjadcgiheb
2.5 point
Assignment
2) Assume we have defined a class Node that implements user defined lists of numbers. Each object node of type Node has two attributes node value 2.5 point
Week 4: and node.next with the usualinterpretationWe want to add a tunction sum0 to the class Node which will compute the sum of values in the list. An incomplete
Sorting, Tuples,
Dictionaries, Passing implementation of sum() given below. What should be put in place of XXX and YYY?
Functions, List
def sun(self) :
Comprehension if self. value None
return(e)
elif self.next -- None:
SCREENCAST MATI return(XXx)
Week 3 Programming
Tiadcaihet
Assignment 2.5 point
2) Assume we have defined a class Node that implements user defined lists of numbers. Each
object node of type Node has two attributes node.value 2.5 point
Week 4: and node.next with the usual interpretation. We want to add a function
Sorting, Tuples, sum() to the class Node which will compute the sum of values in the list. An incompletee
Dictionaries, Passing
Functions, List
implementation of sum) gven below What should be put in place of Xox and YYY?
def sum(self) :
Comprehension if self.value None:
Week 4 Quiz
return(e)
elif self.next -=
None
return(Xx)
Week 4 Programming9
else:
Assignment
return(YY)
Week 5: Exception handling,
inputoutput, file handling. ReplaceXXXX by 1 and YXby 1+sef.nextsumo
string processing Replace xxx by 1 and YYby seltvalue+sett.next.sumo
ReplaceXXX by seif.value andYYY by 1+self.nextsum)
Week 5 Programming Replace XXX by sef.value and YYY by setf.value+ sett.next.sum)
Assignment
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 2.5 point=
Week 6: Backtracking, scope,
mytree.foo() compute?
data structures; stacks,
queues and heaps
def foo(self) :
if self.isempty () :
s NASr (OMATIE return(0)
Replace XXX by self.value and YYY by 1 +setf.next.sum()
Week 5 Programming Replace XXX by self.value and YYY by self.value+ self.next.sum()
Assignment
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 2.5 poin
Week 6: Backtracking. scope,
mytree.foo() compute?
data structures; stacks,
queues and heaps
def foo(self) :
Week 6 Quiz if self.isempty () :
return(@)
elif self.isleaf() :
Week 7: Classes, objects and
user defined datatypes return(self.value)
else
Week 7 Quiz return(self.value + max(self. left.foo()
self.right.foo()))
Quiz: Week 7Quiz
Week 8: Dynamic The sum of the elements in the tree
programming, wrap-up The maximum sum across all root to leaf paths in he tree
The length ofthe longest root to leaf pah in Me tree
Week 8 Programming
Assignment
The number ofroot to leaf paths in thetree
4) The preorder traversal of a binary search tree with integer values produces the following sequence: 35, 23, 26, 46, 40, 39, 41, 52. Wnat is the value of 2.5 poi
Text Transcripts the right child of the root of the tree?
3CORDED wrA
39
SEREENCAST OMATIC
return(e0)
Week 7: Classes, objects and
elif self.isleaf () :
user defined datatypes return(self.value)
else:
Books 39
40
Download Videos 41
46
You may suumit any number of times before the due date. The final sutbmission will be considered tor grading.
Submit Answers
D E D WITA
SCREENCAST(OMATic
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 3 - Week 1 Quiz
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)
Course
outline Week 1 Quiz
The due date for submitting this assignment has passed.
How does an Due on 2020-09-30, 23:59 IST.
NPTEL online Score: 4/4=100%
course work?
Week 2 Quiz 10
1 point
Week 3: Lists,
inductive function 2) What is g(36) - g(35), given the definition of g below?
definitions,
sorting
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=22&assessment=104 1/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 3 - Week 1 Quiz
def g(n):
Week 3
s=0
Programming
Assignment for i in range(2,n):
if n%i == 0:
s = s+1
Week 4: Sorting,
Tuples, return(s)
Dictionaries,
Passing 5
Functions, List
Comprehension Yes, the answer is correct.
Score: 1
Accepted Answers:
Week 4 Quiz (Type: Numeric) 5
Week 4 1 point
Programming
3) Consider the following function f. 1 point
Assignment
def f(n):
Week 5: s=0
Exception
for i in range(1,n+1):
handling,
if n//i == i and n%i == 0:
input/output, file
s = 1
handling, string
return(s%2 == 1)
processing
Week 5 The function f(n) given above returns True for a positive number n if and only if:
Programming
n is an odd number.
Assignment
n is a prime number.
Week 6: n is a perfect square.
Backtracking, n is a composite number.
scope, data
structures; Yes, the answer is correct.
Score: 1
stacks, queues
Feedback:
and heaps
f(n) sets s to 1 if there is a number i such that i*i == n.
Accepted Answers:
Week 6 Quiz
n is a perfect square.
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=22&assessment=104 2/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 3 - Week 1 Quiz
Online
Programming
Test 1, 01 Dec
2020, 10:00-
12:00
Online
Programming
Test 2, 01 Dec
2020, 20:00-
22:00
Online
Programming
Test 1, 09 Mar
2021, 10:00-
12:00
Online
Programming
Test 2, 09 Mar
2021, 20:00-
22:00
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=22&assessment=104 3/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 5 - Week 2 Quiz
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)
Course
outline Week 2 Quiz
The due date for submitting this assignment has passed.
How does an Due on 2020-09-30, 23:59 IST.
NPTEL online Score: 10/10=100%
course work?
Week 2
Programming
Assignment
Week 3: Lists,
inductive function
definitions,
sorting
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=31&assessment=105 1/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 5 - Week 2 Quiz
x = ["slithy",[7,10,12],2,"tove",1] # Statement 1
Week 3
y = x[0:50] # Statement 2
Programming
Assignment z = y # Statement 3
w = x # Statement 4
x[0] = x[0][:5] + 'ery' # Statement 5
Week 4: Sorting,
Tuples, y[2] = 4 # Statement 6
Dictionaries, z[4] = 42 # Statement 7
Passing w[0][:3] = 'fea' # Statement 8
Functions, List x[1][0] = 5555 # Statement 9
Comprehension a = (x[4][1] == 1) # Statement 10
Week 4 Quiz 8
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=31&assessment=105 2/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 5 - Week 2 Quiz
Assignment 'python'
2.5 points
Online
Programming
Test 1, 09 Mar
2021, 10:00-
12:00
Online
Programming
Test 2, 09 Mar
2021, 20:00-
22:00
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=31&assessment=105 3/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 10 - Week 4 Quiz
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)
Course
outline Week 4 Quiz
The due date for submitting this assignment has passed.
How does an Due on 2020-10-14, 23:59 IST.
NPTEL online Score: 10/10=100%
course work?
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=53&assessment=108 1/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 10 - Week 4 Quiz
Accepted Answers:
Week 4: Sorting, (Type: Regex Match) [ ]*[[ ]*55[ ]*,[ ]*82[ ]*,[ ]*65[ ]*,[ ]*19[ ]*,[ ]*14[ ]*,[ ]*22[ ]*][ ]*
Tuples,
2.5 points
Dictionaries,
Passing 2) What is the value of pairs after the following assignment?
Functions, List
Comprehension pairs = [ (x,y) for x in range(4,1,-1) for y in range(5,1,-1) if (x+
y)%3 == 0 ]
Week 4 Quiz
[(4, 5), (4, 2), (3, 3), (2, 4)]
Quiz : Week 4
Quiz Yes, the answer is correct.
(assessment? Score: 2.5
name=108) Accepted Answers:
(Type: Regex Match) [ ]*[[ ]*\([ ]*4[ ]*,[ ]*5[ ]*\)[ ]*,[ ]*\([ ]*4[ ]*,[ ]*2[ ]*\)[ ]*,[ ]*\([ ]*3[ ]*,[ ]*3[ ]*\)[ ]*,[
Week 4 ]*\([ ]*2[ ]*,[ ]*4[ ]*\)[ ]*][ ]*
Programming
Assignment 2.5 points
4) Assume that hundreds has been initialized as an empty dictionary: 2.5 points
Week 6 Quiz
hundreds = {}
Week 7: Classes,
objects and user Which of the following generates an error?
defined
datatypes hundreds["Tendulkar, international"] = 100
hundreds["Tendulkar"] = {"international":100}
Week 7 Quiz
hundreds[("Tendulkar","international")] = 100
hundreds[["Tendulkar","international"]] = 100
Week 8: Dynamic
programming, Yes, the answer is correct.
wrap-up Score: 2.5
Feedback:
Week 8 Dictionary keys must be immutable values.
Programming Accepted Answers:
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=53&assessment=108 2/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 10 - Week 4 Quiz
Text Transcripts
Books
Download Videos
Online
Programming
Test - Sample
Online
Programming
Test 1, 01 Dec
2020, 10:00-
12:00
Online
Programming
Test 2, 01 Dec
2020, 20:00-
22:00
Online
Programming
Test 1, 09 Mar
2021, 10:00-
12:00
Online
Programming
Test 2, 09 Mar
2021, 20:00-
22:00
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=53&assessment=108 3/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 15 - Week 6 Quiz
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)
Course
outline Week 6 Quiz
The due date for submitting this assignment has passed.
How does an Due on 2020-10-28, 23:59 IST.
NPTEL online Score: 7.5/10=75%
course work?
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=73&assessment=111 1/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 15 - Week 6 Quiz
Accepted Answers:
Week 4: Sorting, This is true for any u and v.
Tuples,
2) Suppose u and v both denote sets in Python. What is the most general condition 2.5 points
Dictionaries,
that guarantees that u|v == u^v?
Passing
Functions, List
The sets u and v should be disjoint.
Comprehension
The set u should be a subset of the set v.
Week 4 Quiz The set v should be a subset of the set u.
This is true for any u and v.
Week 4
Yes, the answer is correct.
Programming Score: 2.5
Assignment Feedback:
u^v has all elements that are in exactly one of u or v. This is the same as u|v - u&v. Since u^v
Week 5: = u|v, we have u&v is empty, so u and v are disjoint.
Exception Accepted Answers:
handling, The sets u and v should be disjoint.
input/output, file
handling, string 3) Suppose we insert 19 into the min heap [17,25,42,67,38,89,54,98,89]. What is the resulting
processing heap?
[17,19,42,67,25,89,54,98,8
Week 5
Programming Yes, the answer is correct.
Assignment Score: 2.5
Accepted Answers:
Week 6: (Type: Regex Match) [ ]*[[ ]*17[ ]*,[ ]*19[ ]*,[ ]*42[ ]*,[ ]*67[ ]*,[ ]*25[ ]*,[ ]*89[ ]*,[ ]*54[ ]*,[ ]*98[ ]*,[
Backtracking, ]*89[ ]*,[ ]*38[ ]*][ ]*
scope, data
2.5 points
structures;
stacks, queues 4) Suppose we execute delete-min twice on the min-heap [13,29,24,67,52,89,45,98.79,58]. What
and heaps is the resulting heap?
Week 7: Classes, 13
objects and user / \
defined 29 24
datatypes / \ / \
67 52 89 45
Week 7 Quiz / \ /
98 79 58
Week 8: Dynamic
programming, After one delete-min, we have:
wrap-up
Week 8
Programming
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=73&assessment=111 2/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 15 - Week 6 Quiz
Assignment
24
/ \
Text Transcripts
29 45
/ \ / \
Books
67 52 89 58
/ \
Download Videos
98 79
Online
After the second delete-min, we have:
Programming
Test - Sample
29
/ \
Online
52 45
Programming
/ \ / \
Test 1, 01 Dec
2020, 10:00- 67 79 89 58
12:00 /
98
Online
Programming Accepted Answers:
(Type: Regex Match) [ ]*[29[ ]*,[ ]*52[ ]*,[ ]*45[ ]*,[ ]*67[ ]*,[ ]*79[ ]*,[ ]*89[ ]*,[ ]*58[ ]*,[ ]*98[ ]*][ ]*
Test 2, 01 Dec
2020, 20:00- 2.5 points
22:00
Online
Programming
Test 1, 09 Mar
2021, 10:00-
12:00
Online
Programming
Test 2, 09 Mar
2021, 20:00-
22:00
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=73&assessment=111 3/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 17 - Week 7 Quiz
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)
Course
outline Week 7 Quiz
The due date for submitting this assignment has passed.
How does an Due on 2020-11-04, 23:59 IST.
NPTEL online Score: 7.5/10=75%
course work?
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=82&assessment=112 1/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 17 - Week 7 Quiz
2.5 points
Week 4: Sorting,
Tuples, 2) We want to add a function length() to the class Node that implements user defined 2.5 points
Dictionaries, lists which will compute the length of a list. An incomplete implementation of length() given below.
Passing You have to provide expressions to put in place of XXX, YYY. and ZZZ.
Functions, List
Comprehension
def length(self):
Week 4 Quiz if self.value == None:
return(XXX)
Week 4 elif self.next == None:
Programming return(YYY)
Assignment else:
return(ZZZ)
Week 5:
Exception XXX: 0, YYY: 0, ZZZ: self.next.length()
handling,
XXX: 0, YYY: 0, ZZZ: 1 + self.next.length()
input/output, file
handling, string XXX: 0, YYY: 1, ZZZ: self.next.length()
processing XXX: 0, YYY: 1, ZZZ: 1 + self.next.length()
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=82&assessment=112 2/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 17 - Week 7 Quiz
Assignment 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:
Text Transcripts Print the root.
Print the left subtree in preorder.
Books Print the right subtree in preorder.
Online
Programming
Test 1, 09 Mar
2021, 10:00-
12:00
Online
Programming
Test 2, 09 Mar
2021, 20:00-
22:00
https://onlinecourses.nptel.ac.in/noc20_cs70/unit?unit=82&assessment=112 3/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 5 - Week 2 Quiz
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)
Course
outline Week 2 Quiz
The due date for submitting this assignment has passed.
How to access Due on 2019-08-21, 23:59 IST.
the portal
Week 3 '7'
Programming
https://onlinecourses.nptel.ac.in/noc19_cs40/unit?unit=20&assessment=89 1/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 5 - Week 2 Quiz
https://onlinecourses.nptel.ac.in/noc19_cs40/unit?unit=20&assessment=89 2/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 5 - Week 2 Quiz
[22,34,57]
Text Transcripts
Yes, the answer is correct.
Online Score: 2.5
Programming Accepted Answers:
Test - Sample (Type: Regex Match) \s*\[\s*22,\s*34,\s*57\s*]\s*
2.5 points
Online
Programming
Test 1, 26 Sep
2019, 09:30-
11:30
Online
Programming
Test 2, 26 Sep
2019, 20:00-
22:00
https://onlinecourses.nptel.ac.in/noc19_cs40/unit?unit=20&assessment=89 3/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 10 - Week 4 Quiz
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)
Course
outline Week 4 Quiz
The due date for submitting this assignment has passed.
How to access Due on 2019-08-28, 23:59 IST.
the portal
https://onlinecourses.nptel.ac.in/noc19_cs40/unit?unit=42&assessment=94 1/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 10 - Week 4 Quiz
2.5 points
Week 4
Programming 3) Consider the following dictionary. 2.5 points
Assignment
marks = {"Quizzes":{"Mahesh":[3,5,7,8],"Suresh":[9,4,8,8],"Um
Week 5: a":[9,9,7,6]},"Exams":{"Mahesh":[37],"Uma":[36]}}
Exception
handling, Which of the following statements does not generate an error?
input/output, file
handling, string marks["Exams"]["Suresh"][0:] = [44]
processing marks["Exams"]["Suresh"].append(44)
marks["Exams"]["Suresh"] = [44]
Week 5
marks["Exams"]["Suresh"].extend([44])
Programming
Assignment Yes, the answer is correct.
Score: 2.5
Week 6: Feedback:
Direct assignment to a new key adds a value. All other updates result in KeyError.
Backtracking,
scope, data Accepted Answers:
structures; marks["Exams"]["Suresh"] = [44]
stacks, queues 4) Assume that d has been initialized as an empty dictionary: 2.5 points
and heaps
d = {}
Week 6 Quiz
Which of the following generates an error?
Week 7:
Classes, objects d[12] = 5
and user defined d["1,2"] = 5
datatypes
d[(1,2)] = 5
d[[1,2]] = 5
Week 7 Quiz
Yes, the answer is correct.
Week 8: Score: 2.5
Dynamic Feedback:
Key must be an immutable value. List is not OK. Tuple, string and integer are OK.
programming,
wrap-up Accepted Answers:
d[[1,2]] = 5
Week 8
Programming
Assignment
Download
videos
https://onlinecourses.nptel.ac.in/noc19_cs40/unit?unit=42&assessment=94 2/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 10 - Week 4 Quiz
Text Transcripts
Online
Programming
Test - Sample
Online
Programming
Test 1, 26 Sep
2019, 09:30-
11:30
Online
Programming
Test 2, 26 Sep
2019, 20:00-
22:00
https://onlinecourses.nptel.ac.in/noc19_cs40/unit?unit=42&assessment=94 3/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 15 - Week 6 Quiz
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)
Course
outline Week 6 Quiz
The due date for submitting this assignment has passed.
How to access Due on 2019-09-11, 23:59 IST.
the portal
Week 2 1) Suppose u and v both denote sets in Python. Under what condition can we 2.5 points
Programming guarantee that u - (u - v) == v?
Assignment
The sets u and v should be disjoint.
Week 3: Lists, The set v should be a subset of the set u.
inductive The set u should be a subset of the set v.
function
This is true for any u and v.
definitions,
sorting Yes, the answer is correct.
Score: 2.5
Week 3 Feedback:
Programming From u you take away all elements that are not in v and you are left with u ∩ v. Since u ∩ v
Assignment = v, we have v is a subset of u.
Accepted Answers:
Week 4: Sorting, The set v should be a subset of the set u.
Tuples,
https://onlinecourses.nptel.ac.in/noc19_cs40/unit?unit=62&assessment=96 1/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 15 - Week 6 Quiz
Dictionaries, 2) Suppose u and v both denote sets in Python. Under what condition can we 2.5 points
Passing guarantee that u|v == u^v?
Functions, List
Comprehension The sets u and v should be disjoint.
The set u should be a subset of the set v.
Week 4 Quiz The set v should be a subset of the set u.
This is true for any u and v.
Week 4
Programming Yes, the answer is correct.
Assignment Score: 2.5
Feedback:
u^v has all elements that are in exactly one of u or v. This is the same as u|v - u&v. Since
Week 5:
u^v = u|v, we have u&v is empty, so u and v are disjoint.
Exception
handling, Accepted Answers:
input/output, file The sets u and v should be disjoint.
handling, string 3) Suppose we insert 97 into the max heap [98,67,89,38,42,54,89,17,25]. What is the resulting
processing
heap?
Week 5 [98,97,89,38,67,54,89,17,2
Programming
Assignment Yes, the answer is correct.
Score: 2.5
Accepted Answers:
Week 6: (Type: Regex Match) [ ]*[[ ]*98[ ]*,[ ]*97[ ]*,[ ]*89[ ]*,[ ]*38[ ]*,[ ]*67[ ]*,[ ]*54[ ]*,[ ]*89[ ]*,[ ]*17[ ]*,
Backtracking, [ ]*25[ ]*,[ ]*42[ ]*][ ]*
scope, data
structures; 2.5 points
stacks, queues
and heaps 4) Suppose we we apply delete_max() twice to the heap [100,97,93,38,67,54,93,17,25,42].
What is the resulting heap?
Week 6 Quiz [93,67,93,38,42,54,25,17]
Week 7 Quiz
Week 8:
Dynamic
programming,
wrap-up
Week 8
Programming
Assignment
Download
videos
https://onlinecourses.nptel.ac.in/noc19_cs40/unit?unit=62&assessment=96 2/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 15 - Week 6 Quiz
Text Transcripts
Online
Programming
Test - Sample
Online
Programming
Test 1, 26 Sep
2019, 09:30-
11:30
Online
Programming
Test 2, 26 Sep
2019, 20:00-
22:00
https://onlinecourses.nptel.ac.in/noc19_cs40/unit?unit=62&assessment=96 3/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 17 - Week 7 Quiz
(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)
Course
outline Week 7 Quiz
The due date for submitting this assignment has passed.
How to access Due on 2019-09-18, 23:59 IST.
the portal
Week 2 1) Given the following permutation of a,b,c,d,e,f,g,h,i,j, what is the next permutation in
Programming lexicographic (dictionary) order? Write your answer without any blank spaces between letters.
Assignment
eibjdhgfca
Week 3: Lists,
inductive [e,i,b,j,f,a,c,d,g,h]
function
definitions, No, the answer is incorrect.
Score: 0
sorting
Feedback:
The suffix to change is dhgfca. This becomes facdgh
Week 3
Accepted Answers:
Programming (Type: Regex Match) [ ]*eibjfacdgh[ ]*
Assignment (Type: Regex Match) [ ]*\'eibjfacdgh\'[ ]*
(Type: Regex Match) [ ]*\"eibjfacdgh\"[ ]*
Week 4: Sorting,
Tuples, 2.5 points
https://onlinecourses.nptel.ac.in/noc19_cs40/unit?unit=71&assessment=97 1/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 17 - Week 7 Quiz
Dictionaries, 2) We want to add a function listmax() to the class Node that implements user 2.5 points
Passing defined lists such that listmax() computes the maximum value in a list where values are of
Functions, List type int.
Comprehension
An incomplete implementation of listmax() given below. You have to provide expressions to
put in place of AAA, BBB and CCC.
Week 4 Quiz
Week 8:
Dynamic The number of nodes in mytree
programming, The largest value in mytree.
wrap-up
The length of the longest path from root to leaf in mytree.
https://onlinecourses.nptel.ac.in/noc19_cs40/unit?unit=71&assessment=97 2/3
3/14/2021 Programming, Data Structures And Algorithms Using Python - - Unit 17 - Week 7 Quiz
This does not compute the number of nodes in the tree. For that, we need to add 1 in the
Text Transcripts
inductive case, to account for the current node. So the else: expression would be return(1
+ self.left.foo() + self.right.foo())).
Online
Accepted Answers:
Programming
The number of leaves in mytree.
Test - Sample
4) Inorder traversal of a binary tree has been defined in the lectures. A postorder traversal lists
Online the vertices of a binary tree (not necessarily a search tree) as follows:
Programming Print the left subtree in postorder.
Test 1, 26 Sep Print the right subtree in postorder.
2019, 09:30- Print the root.
11:30
Suppose we have a binary tree with 10 nodes labelled a, b, c, d, e, f, g, h, i, j, with
Online postorder traversal ehicbjfadg and inorder traversal ehbicgjafd. What is the left child of the
Programming root node?
Test 2, 26 Sep
[b]
2019, 20:00-
22:00
Hint
2.5 points
https://onlinecourses.nptel.ac.in/noc19_cs40/unit?unit=71&assessment=97 3/3