-
Notifications
You must be signed in to change notification settings - Fork 0
/
declrns.h
131 lines (87 loc) · 4.24 KB
/
declrns.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#ifndef DECLRNS_H_INCLUDED
#define DECLRNS_H_INCLUDED
//declrns.h: Contains all structure declarations and date-time input-output functions.
typedef enum balancefactor_tag { LH, EH, RH } BalanceFactor_type;
typedef enum boolean_tag {FALSE, TRUE } Boolean_type;
typedef struct date
{
int day, mnt, yr;
}date;
typedef struct time
{
int hrs, mins;
}time;
typedef struct sensor
{
int ID; //sensor_ID
char sensor_type[15];
char sensor_station;
time interval;
BalanceFactor_type bf;
struct sensor *left;
struct sensor *right;
}sensor_node;
typedef struct central_repo
{
int ID; //sensor ID
date dt;
time tm;
float data; //Any data like wind speed, humidity, Final AQI, etc.
BalanceFactor_type bf;
struct central_repo *left;
struct central_repo *right;
}record;
typedef struct AQI_sensor //previous structure adapted for AQI - has an array for interval as AQI sensor type records multiple quantities, no need of sensor_type as it is "AQI" implied
{
int ID;
char sensor_station;
struct time interval[6]; //6 quantities: PM10, PM 2.5, nitrogen dioxide, sulphur dioxide, carbon monoxide, ground level ozone
BalanceFactor_type bf;
struct AQI_sensor *left;
struct AQI_sensor *right;
}AQI_node;
//Additional date-time functions:
time ip_time(time t);
date ip_date(date d);
void op_time(time t);
void op_date(date d);
//sensor.h: Functions related to sensor database. Contains answers to Qn 1(Sensor part), Qn2, Qn3 and Qn5.
sensor_node *RotateLeft(sensor_node *p);
sensor_node *RotateRight(sensor_node *p);
sensor_node *RightBalance (sensor_node *root, Boolean_type *taller);
sensor_node *LeftBalance (sensor_node *root, Boolean_type *taller);
sensor_node *Insert(sensor_node *root, sensor_node *newnode, Boolean_type *taller); //Insert new node starting at root
sensor_node *GetNode(); //get a new node with data for BT
sensor_node* create_sensor_node(sensor_node *root, Boolean_type *taller); //makes a BST and returns the root
int TreeSearch_stn(sensor_node *x, char stn, char* type); //Search - assume that station, like ID is stored in order.
sensor_node* Install_new_Sensor(sensor_node *root, Boolean_type *taller); //makes a BST and returns the root
void print_snsr(sensor_node* p);
void Inorder(sensor_node *root, int l_ID, int u_ID); //Traversal
void sensors_in_between(sensor_node* root);
int repo_Inorder(record* repo_root, int ID, int curr_mnt); //Traversal
void Delete(sensor_node **p, sensor_node *root, Boolean_type *taller); //call xBalance when x side is taller.
int sn_Inorder(sensor_node* sn_root, sensor_node* sn_node, record* repo_root, int curr_mnt, Boolean_type* taller); //Traversal
sensor_node* idle_delete(sensor_node* sn_root, record* repo_root, Boolean_type* taller);
//repo.h: Functions related to central repository. Contains answers to Qn 1(Repository part) and Qn4.
record *repo_RotateLeft(record *p);
record *repo_RotateRight(record *p);
record *repo_RightBalance (record *root, Boolean_type *taller);
record *repo_LeftBalance (record *root, Boolean_type *taller);
record *repo_Insert(record *root, record *newnode, Boolean_type *taller); //Insert new node starting at root
record *repo_GetNode(); //get a new node with data for BT
record* add_central_repo(record *root, Boolean_type *taller); //makes a BST and returns the root
void print_record(record* nptr);
sensor_node* SnSearch(sensor_node *x, int ID); //Search
void RepoSearch(record *x, sensor_node* sn_root, date d, char* type); //Search
void retrieve_info(record* repo_root, sensor_node* sn_root);
//AQI.h: Functions related to both AQI sensor database and AQI repository. Contains answers to Qn 6.
AQI_node *AQI_RotateLeft(AQI_node *p);
AQI_node *AQI_RotateRight(AQI_node *p);
AQI_node *AQI_RightBalance (AQI_node *root, Boolean_type *taller);
AQI_node *AQI_LeftBalance (AQI_node *root, Boolean_type *taller);
AQI_node *AQI_Insert(AQI_node *root, AQI_node *newnode, Boolean_type *taller); //Insert new node starting at root
AQI_node *AQI_GetNode(); //get a new node with data for BT
AQI_node* create_AQI_node(AQI_node *root, Boolean_type *taller); //makes a BST and returns the root
void max_AQI(record *root, float* max, int* max_mnt); //Traversal
int hazardous_dates(record *root); //Traversal
#endif // DECLRNS_H_INCLUDED