CEILING FUNCTION
BATCH 28
January 28,2023
Team Members:
21B01A0511-B.GLORY-CSE
21B01A0409-B.MADHAVI-ECE
22B01A0443-K.SWETHA KUMARI-ECE
21B01A01O5-B.POOJITHA-CIVIL
21B01A0111-M.PRASANNA-CIVIL
22B05A0101-B.SUJITHA-CIVIL
Problem Statement
▶ Advanced Ceiling Manufacturers (ACM) is analyzing the
properties of its new series of Incredibly Collapse-Proof
Ceilings (ICPCs),An ICPC consists of n layers of material, each
with a different value of collapse resistance.The analysis, ACM
wants to run will take the collapse-resistance values of the
layers, store them in a binary searchtree, and check whether
the shape of this tree in any way correlates with the quality of
the wholeconstruction.
▶ The rules for inserting a value v are:If the tree is empty, make
v the root of the tree.If the tree is not empty, compare v with
the root of the tree, If v is smaller, insert v into the leftsubtree
of the root, otherwise insert v into the right subtree.
▶ if two prototypes induce the same tree shape,ACM will analyze
them together,our task is to determine how many different tree
shapes they induce,Display the number of different tree shapes.
Input
The first line of the input contains two integers n (1 n 50), which
is the number of ceiling prototypes to analyze, and k (1 k 20),
which is the number of layers in each of the prototypes which are
the collapse-resistance values of the layers in a ceiling prototype,
ordered from top to bottom.
Output
Display the number of different tree shapes
Figure 1: Binary search tree
Approach
code creates a binary search tree (BST) data structure, which
is a type of tree where the left child node of a parent node has
a value that is less than the parent’s value, and the right child
node has a value that is greater than the parent’s value. code
also defines a method to check if two BSTs are similar, which
means that they have the same structure and the values in the
same positions. code takes input from the user for the number
of BSTs to be created and the values for each BST, then
creates the BSTs and checks if they are similar to any
previously created BSTs. a BST is unique (i.e. it is not similar
to any previously created BSTs), it is added to a list of unique
BSTs. Finally, the code outputs the number of unique BSTs.
Learnings
▶ Working on Visual Studio Code
▶ We learnt how to use GitLab to make projects.
▶ We learnt how to use Latex from scratch and make
presentation of it.
Challenges Faced
▶ Ensuring that the isSimilar method correctly determines if two
BSTs are similar, as it currently only compares the left and
right subtrees, but does not take into account the value of the
root node.
▶ Handling cases where the input is not valid or in the expected
format.
▶ The implementation doesn’t handle duplicate values in the
BSTs.
STATISTICS
▶ The Python code has overall 52 lines.
▶ The code has 4 methods.
They are:
▶ insert
▶ isSimilar
▶ insertNode
▶ isSimilarBST
Code
Code