Programming Data Structure And Algorithms Using Python Assignment 1 Answers 2022:- Hello students in this article we are going to share NPTEL Programming Data Structure And Algorithms Using Python Assignment 1 answers. All the Answers are provided below to help the students as a reference, You must submit your assignment with your own knowledge.
Programming Data Structure And Algorithms Using Python Assignment 1 Answers 2022 [July-Dec]
1. What does h(27993) return for the following function definition?
def h(x):
(d,n) = (1,0)
while d <= x:
(d,n) = (d*3,n+1)
return(n)
Answer:- 10
2. What is g(60) – g(48), given the definition of g below?
def g(n):
s=0
for i in range(2,n):
if n%i == 0:
s = s+1
return(s)
Answer:- 2
3. Consider the following function f.
def f(n):
s=0
for i in range(1,n+1):
if n//i == i and n%i == 0:
s = 1
return(s%2 == 1)
The function f(n) given above returns True for a positive number n if and only if:
a. n is an odd number.
b. n is a prime number.
c. n is a perfect square.
d. n is a composite number.
Answer:- c
👇For Week 02 Assignment Answers👇
4. Consider the following function foo.
def foo(m):
if m == 0:
return(0)
else:
return(m+foo(m-1))
Which of the following is correct?
a. The function always terminates with foo(n) = factorial of n
b. The function always terminates with foo(n) = n(n+1)/2
c. The function terminates for nonnegative n with foo(n) = factorial of n
d. The function terminates for nonnegative n with foo(n) = n(n+1)/2
Answer:- d
For More NPTEL Answers:- CLICK HERE
Join Our Telegram:- CLICK HERE
About Programming Data Structure And Algorithms Using Python
This course is an introduction to programming and problem solving in Python. It does not assume any prior knowledge of programming. Using some motivating examples, the course quickly builds up basic concepts such as conditionals, loops, functions, lists, strings and tuples. It goes on to cover searching and sorting algorithms, dynamic programming and backtracking, as well as topics such as exception handling and using files. As far as data structures are concerned, the course covers Python dictionaries as well as classes and objects for defining user defined datatypes such as linked lists and binary search trees.
COURSE LAYOUT
- Week 1
- Informal introduction to programmin, algorithms and data structures viagcd
- Downloading and installing Python
- gcd in Python: variables, operations, control flow – assignments, condition-als, loops, functions
- Week 2
- Python: types, expressions, strings, lists, tuples
- Python memory model: names, mutable and immutable values
- List operations: slices etc
- Binary search
- Inductive function denitions: numerical and structural induction
- Elementary inductive sorting: selection and insertion sort
- In-place sorting
- Week 3
- Basic algorithmic analysis: input size, asymptotic complexity, O() notation
- Arrays vs lists
- Merge sort
- Quicksort
- Stable sorting
- Week 4
- Dictionaries
- More on Python functions: optional arguments, default values
- Passing functions as arguments
- Higher order functions on lists: map, lter, list comprehension
- Week 5
- Exception handling
- Basic input/output
- Handling files
- String processing
- Week 6
- Backtracking: N Queens, recording all solutions
- Scope in Python: local, global, nonlocal names
- Nested functions
- Data structures: stack, queue
- Heaps
- Week 7
- Abstract datatypes
- Classes and objects in Python
- “Linked” lists: find, insert, delete
- Binary search trees: find, insert, delete
- Height-balanced binary search trees
- Week 8
- Effcient evaluation of recursive definitions: memoization
- Dynamic programming: examples
- Other programming languages: C and manual memory management
- Other programming paradigms: functional programming
CRITERIA TO GET A CERTIFICATE
Average assignment score = 25% of average of 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 score = Average assignment score + Exam score
YOU WILL BE ELIGIBLE FOR A CERTIFICATE ONLY IF AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If one of the 2 criteria is not met, you will not get the certificate even if the Final score >= 40/100.
Python