Week 1:Assignment 1
Due date: 2022-08-10, 23:59 IST.
Your last recorded submission was on 2022-07-29, 11:02 IST
NPTEL | Programming In Java| Week 1 : Assignment 1 Answers | July-2022
netaji gandi
Thursday, July 28, 2022
Note:
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)
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)
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:
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?
![]() |
| Delhi Metro Rail Map |
![]() |
| A Maze |
![]() |
| A tournament fixture Courtesy: http://www.squadtd.com/ |
![]() |
| Undirected Graph |
![]() |
| Directed Graph |
![]() |
| Vertex Labeled Graph |
![]() |
| Cyclic Graph |
![]() |
| Edge Labeled Graph |
![]() |
| Weighted Graph |
![]() |
| Direct Acyclic Graph(DAG) |
![]() |
| Disconnected Graph |
![]() |
| Mixed Graph |
![]() |
| Multigraph |

![]() |
| Fig. 1: An undirected graph |
![]() |
| Fig 2: A directed graph |
![]() |
![]() |
Smart India Hackathon (SIH) 2025: Complete Guide with Problem Statements, Timeline & Idea PPT Template Lets Code • September 8, 2025 I...