Skip to content

Solutions

solutions

Modules:

Name Description
example
q01VertexOrder

Question 1

q02IsDagP

Question 2

q03TopologicalSort

Question 3

q04IsPathSumP

Question 4 [PY]

q05BinaryTreeBfs

Question 5

q06MergeBinaryTrees

Question 6 [PY]

q07ListBfsOrder

Question 7

q08BinaryTreeDepthStats

Question 8

q09FloodFill

Question 9 [PY]

q10ExistsPathP

Question 10

q11EvalBooleanBinaryTreeP

Question 11 [PY]

q12GetIslandPerimeter

Question 12 [PY]

q13FulfilProgramP

Question 13 [PY]

q14GetAllAncestors

Question 14

q15GetCheapestFlight

Question 15 [PY]

q16DungeonCrossingTimeMin

Question 16

Attributes:

Name Type Description
Bbt

Enumeration for constants in a Boolean Binary Tree.

Flight

Flight DataType.

Graph

Graph DataType.

meta

Details to be filled in by student before submission.

Bbt = Enum('Bbt', 'False,True,OR,AND') module-attribute

Enumeration for constants in a Boolean Binary Tree.

This is just a fancy way of assigning the following constants, without polluting the global namespace,

Bbt.False = 0    # constant
Bbt.True = 1     # constant
Bbt.OR = 2       # constant
Bbt.AND = 3      # constant

Flight = namedtuple('Flight', 's,d,p') module-attribute

Flight DataType.

Essentially a namedtuple with members accessible as attributes, i.e. F.s, F.d and F.p.

Parameters:

Name Type Description Default
s

Source City.

required
d

Destination City.

required
p

Cost Price of the flight.

required

Graph = namedtuple('Graph', 'V,E') module-attribute

Graph DataType.

Essentially a namedtuple with members accessible as attributes. So that G.V and G.E represent list of verts and adjacency respectively.

meta = NS(rollNo='', name='', group='', email='') module-attribute

Details to be filled in by student before submission.