0% found this document useful (0 votes)
19 views4 pages

noc20-cs26_Week_04_Assignment_02

The document outlines a course on Programming, Data Structures, and Algorithms using Python, including weekly assignments and quizzes. It specifies programming tasks such as writing functions to analyze frequency in lists and to identify city pairs connected by one-hop flights. The document also includes details about submission deadlines and evaluation criteria for the assignments.

Uploaded by

chittoras
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views4 pages

noc20-cs26_Week_04_Assignment_02

The document outlines a course on Programming, Data Structures, and Algorithms using Python, including weekly assignments and quizzes. It specifies programming tasks such as writing functions to analyze frequency in lists and to identify city pairs connected by one-hop flights. The document also includes details about submission deadlines and evaluation criteria for the assignments.

Uploaded by

chittoras
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

02/07/2020 Programming, Data Structures And Algorithms Using Python - Course

(https://swayam.gov.in) (https://swayam.gov.in/nc_details/NPTEL)

reviewer4@nptel.iitm.ac.in 

NPTEL (https://swayam.gov.in/explorer?ncCode=NPTEL) » Programming, Data Structures And Algorithms

Using Python (course)

Announcements (announcements)

About the Course (https://swayam.gov.in/nd1_noc19_cs40/preview) Ask a Question (forum)

Progress (student/home) Mentor (student/mentor)

Week 4 Programming Assignment


Course Due on 2019-08-29, 23:59 IST
outline
Write two Python functions as specified below. Paste the text for both functions
together into the submission window. Your function will be called automatically
How to access with various inputs and should return values as specified. Do not write
the portal commands to read any input or print any output.
Week 1: You may define additional auxiliary functions as needed.
Introduction In all cases you may assume that the value passed to the function is of
the expected type, so your function does not have to check for malformed
Week 1 Quiz inputs.
For each function, there are normally some public test cases and some
Week 2: Basics
(hidden) private test cases.
of Python "Compile and run" will evaluate your submission against the public test
cases.
Week 2 Quiz
"Submit" will evaluate your submission against the hidden private test
cases. There are 10 private test cases, with equal weightage. You will get
feedback about which private test cases pass or fail, though you cannot
Week 2
Programming
see the actual test cases.
Assignment Ignore warnings about "Presentation errors".

Week 3: Lists,
inductive 1. Write a Python function frequency(l) that takes as input a list of integers
function and returns a pair of the form (minfreqlist,maxfreqlist) where
definitions, minfreqlist is a list of numbers with minimum frequency in l, sorted in
sorting ascending order
maxfreqlist is a list of numbers with maximum frequency in l, sorted
Week 3 in ascending
Programming For instance
Assignment
>>> frequency([13,12,11,13,14,13,7,11,13,14,12])

https://onlinecourses.nptel.ac.in/noc19_cs40/progassignment?name=93 1/4
02/07/2020 Programming, Data Structures And Algorithms Using Python - Course

([7], [13])
Week 4: Sorting,
Tuples,
>>> frequency([13,12,11,13,14,13,7,11,13,14,12,14,14])
Dictionaries,
Passing ([7], [13, 14])
Functions, List
Comprehension >>> frequency([13,12,11,13,14,13,7,11,13,14,12,14,14,7])
([7, 11, 12], [13, 14])
Week 4 Quiz

Week 4
Programming 2. An airline has assigned each city that it serves a unique numeric code. It
Assignment has collected information about all the direct flights it operates,
represented as a list of pairs of the form (i,j), where i is the code of the
Week 4 starting city and j is the code of the destination.
Programming
Assignment
It now wants to compute all pairs of cities connected by one intermediate
hop --- city i is connected to city j by one intermediate hop if there are
(/noc19_cs40/progassignment?
name=93) direct flights of the form (i,k) and (k,j) for some other city k. The airline is
only interested in one hop flights between different cities --- pairs of the
Week 5: form (i,i) are not useful.
Exception
handling, Write a Python function onehop(l) that takes as input a list of pairs
input/output, file representing direct flights, as described above, and returns a list of all
handling, string pairs (i,j), where i != j, such that i and j are connected by one hop. Note
processing that it may already be the case that there is a direct flight from i to j. So
long as there is an intermediate k with a flight from i to k and from k to j,
Week 5 the list returned by the function should include (i,j). The input list may be in
Programming any order. The pairs in the output list should be in lexicographic
Assignment (dictionary) order. Each pair should be listed exactly once.
For instance
Week 6:
Backtracking, >>> onehop([(2,3),(1,2)])
scope, data [(1, 3)]
structures;
stacks, queues
>>> onehop([(2,3),(1,2),(3,1),(1,3),(3,2),(2,4),(4,1)])
and heaps
[(1, 2), (1, 3), (1, 4), (2, 1), (3, 2), (3, 4), (4, 2), (4, 3)]

Week 6 Quiz
>>> onehop([(1,2),(3,4),(5,6)])
[]
Week 7:
Classes, objects
and user
defined
datatypes Sample Test Cases
Input Output
Week 7 Quiz
frequency([17322,271898,3
Week 8: Test 74,374,374,423432423,4234
Dynamic Case 32423,423432423,42343242 ([17322, 271898], [5325])
programming, 1 3,5325,5325,5325,5325,532
wrap-up 5])

Week 8 Test
frequency([17322,374,1732 ([374, 17322], [374, 1732
Programming Case
2,374,17322,374]) 2])
Assignment 2

https://onlinecourses.nptel.ac.in/noc19_cs40/progassignment?name=93 2/4
02/07/2020 Programming, Data Structures And Algorithms Using Python - Course

Test
Download
Case frequency([9842]) ([9842], [9842])
videos
3

Text Transcripts frequency([-17322,-27189


Test 8,-374,-374,-374,-4234324
([-271898, -17322], [-532
Online Case 23,-423432423,-423432423,
5])
Programming 4 -423432423,-5325,-5325,-5
Test - Sample 325,-5325,-5325])

Test
Online frequency([-17322,-374,-1 ([-17322, -374], [-17322,
Programming Case
7322,-374,-17322,-374]) -374])
Test 1, 26 Sep 5
2019, 09:30- Test
onehop([(1,3),(1,2),(2, [(1, 2), (1, 3), (2, 1),
11:30 Case
3),(2,1),(3,2),(3,1)]) (2, 3), (3, 1), (3, 2)]
6
Online
onehop([(1, 2), (1, 3),
Programming [(1, 2), (1, 3), (1, 4),
Test 2, 26 Sep (1, 4), (1, 5), (1, 6),
(1, 5), (1, 6), (1, 7),
2019, 20:00- (1, 7), (1, 8), (1, 9),
(1, 8), (1, 9), (2, 1),
22:00 (2, 1), (2, 3), (2, 4),
(2, 3), (2, 4), (2, 5),
(2, 5), (2, 6), (2, 7),
(2, 6), (2, 7), (2, 8),
(2, 8), (2, 9), (3, 1),
(2, 9), (3, 1), (3, 2),
(3, 2), (3, 4), (3, 5),
(3, 4), (3, 5), (3, 6),
(3, 6), (3, 7), (3, 8),
(3, 7), (3, 8), (3, 9),
(3, 9), (4, 1), (4, 2),
(4, 1), (4, 2), (4, 3),
(4, 3), (4, 5), (4, 6),
(4, 5), (4, 6), (4, 7),
(4, 7), (4, 8), (4, 9),
(4, 8), (4, 9), (5, 1),
Test (5, 1), (5, 2), (5, 3),
(5, 2), (5, 3), (5, 4),
Case (5, 4), (5, 6), (5, 7),
(5, 6), (5, 7), (5, 8),
7 (5, 8), (5, 9), (6, 1),
(5, 9), (6, 1), (6, 2),
(6, 2), (6, 3), (6, 4),
(6, 3), (6, 4), (6, 5),
(6, 5), (6, 7), (6, 8),
(6, 7), (6, 8), (6, 9),
(6, 9), (7, 1), (7, 2),
(7, 1), (7, 2), (7, 3),
(7, 3), (7, 4), (7, 5),
(7, 4), (7, 5), (7, 6),
(7, 6), (7, 8), (7, 9),
(7, 8), (7, 9), (8, 1),
(8, 1), (8, 2), (8, 3),
(8, 2), (8, 3), (8, 4),
(8, 4), (8, 5), (8, 6),
(8, 5), (8, 6), (8, 7),
(8, 7), (8, 9), (9, 1),
(8, 9), (9, 1), (9, 2),
(9, 2), (9, 3), (9, 4),
(9, 3), (9, 4), (9, 5),
(9, 5), (9, 6), (9, 7),
(9, 6), (9, 7), (9, 8)]
(9, 8)])

Test
onehop([(1,2),(2,3),(3, [(1, 3), (2, 4), (3, 5),
Case
4),(4,5),(5,1)]) (4, 1), (5, 2)]
8

[(1, 3), (2, 4), (3, 5),


Test onehop([(1,2),(2,3),(3,
(4, 1), (4, 6), (5, 2),
Case 4),(4,5),(5,1),(5,6),(6,
(5, 7), (6, 8), (7, 9),
9 7),(7,8),(8,9),(9,5)])
(8, 5), (9, 1), (9, 6)]

Test
onehop([(1,2),(2,1),(3,
Case []
4),(4,3)])
10

https://onlinecourses.nptel.ac.in/noc19_cs40/progassignment?name=93 3/4
02/07/2020 Programming, Data Structures And Algorithms Using Python - Course

Test
frequency([1,2,3,4,5,5,4,
Case ([1], [5])
3,2,3,4,5,5,4,5])
11
Test
frequency([4,4,4,1,1,2,2,
Case ([1, 3], [2, 4])
2,3,3])
12
Test
Case frequency([1,1,1,1,1]) ([1], [1])
13
Test
Case onehop([(1,2),(2,1)]) []
14
Test
Case onehop([(1,2)]) []
15
Test
onehop([(1,3),(1,2),(2, [(1, 2), (1, 3), (2, 1),
Case
3),(2,1),(3,2),(3,1)]) (2, 3), (3, 1), (3, 2)]
16

The due date for submitting this assignment has passed.


As per our records you have not submitted this assignment.

https://onlinecourses.nptel.ac.in/noc19_cs40/progassignment?name=93 4/4

You might also like