@@ -3,9 +3,44 @@ The project implements a way to keep track of all the buildings under constructi
3
3
Data structures used here include Min Heap and Red Black Trees
4
4
Language of Implementation - C++
5
5
6
+
6
7
The source code has 3 classes which provide the required abstraction.
7
8
8
9
1 ) Class construct
9
10
10
11
This is the top level class which set the order for construction functionality. Methods belonging to the class are
11
12
-> void print(int buildingNum); Print the building triplet
13
+ -> void print(int buildingNum1, int buildingNum2); Prints the building triplet information for given range of buildingNums
14
+ ->void insert(int buildingNum, int time); Inserts buildingNums and the total time into the Min heap and Red Black tree
15
+ ->construct(); Constructor that initializes the counter and creates objects of class heap and class rbt
16
+ ->void syncTime(int time); Synchronizes time between global time and counter
17
+ ->int dispatch(int); Send building for construction
18
+ ->int ifbuild(); Checks if any building is left to build
19
+
20
+ 2 ) Class heap
21
+ This class facilitates the Min Heap data structure
22
+ -> heapnode* insert(int, int, int, rbtnode* ); insert a new node into the heap
23
+ -> struct heapnode* removeMin(); remove the item from the top of the heap ie minimum executed time
24
+ -> void swapbuilding(struct heapnode* a, struct heapnode* b); swap two nodes of the heap
25
+ ->void heapify(); regain heap property
26
+ ->void updateMin(int exec_time); Updates the root node and re arranges the heap structure
27
+ ->heap(int); constructor declaration
28
+ -> void execute(int); function to execute building construction
29
+
30
+ 3 ) Class rbt
31
+ This class is responsible for all features of a red black tree data structure
32
+ ->rbtnode* insert(const int&n); insert new node into the tree
33
+ ->rbtnode* findnode(int bnum); finds a node in the tree based on building number
34
+ ->void inorder(int, int); find a range of building numbers
35
+ ->void deletenode(rbtnode* ); delete a node from tree
36
+ ->void fixviolation(rbtnode* ); fix violation caused due to delete
37
+ ->void rightrotate(rbtnode* p); rotate right after delete
38
+ ->void leftrotate(rbtnode* p); rotate left after delete
39
+
40
+
41
+ Structure -
42
+
43
+ Min Heap and the Red Black Tree is connected to each other by pointers pointing in each direction on both ends of the same element
44
+ Time complexity of search is O(logn) as Red Black Tree is a self balancing tree
45
+ Time complexity of print command is executed in O(logn) and the print range command is executed in O(log(n)+S)
46
+
0 commit comments