-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTotal Notes.cpp
More file actions
232 lines (173 loc) · 3.58 KB
/
Total Notes.cpp
File metadata and controls
232 lines (173 loc) · 3.58 KB
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
// 7/18/17
// used this website http://www.cprogramming.com/tutorial/lesson18.html
// Binary Tree with a few values added to it.
struct node
{
int key_value;
node *left;
node *right;
};
void insert(int key, node *leaf) {
if (key < left->key_value) {
if (leaf->left != NULL) {
insert(key, leaf->left);
}
else {
leaf->left = new node;
leaf->left->key_value = key;
leaf->left->left = NULL;
leaf->left->right = NULL;
}
}
else if (key >= leaf->key_value) {
if (leaf->right != NULL) {
insert(key, leaf->left);
}
else {
leaf->right = new node;
leaf->right->key_value = key;
leaf->right-> left = NULL;
leaf->right-> right = NULL;
}
}
}
int main() {
BstNode* root = Null;
insert(root, 15);
insert(root, 10);
insert(root, 20);
}
//Double linked list
int main(int argc, char** argv) {
struct box {
int data;
box *prev;
box *next;
};
box* head;
box* tail;
box* n;
//First node
n = new node;
n->data = 1;
n->prev = NULL;
head = n;
tail = n;
//Second node
n = new node;
n->data = 2;
n->prev = tail;
tail->next = n;
tail->n;
//Third node
n = new node;
n->data = 3;
n->prev = tail;
tail->next = n;
tail->n;
//Last node needs to have Tail set to Null
tail->next = NULL;
return 0;
}
//Making a double list
//Method 1
int main() {
std::list<double> holder;
}
/* 7-20-17 Notes */
struct Node {
Node* next = NULL;
int data;
};
struct DNode() extends Node{
DNode* prev;
DNode* next;
int data;
};
DNode root = new DNode()
root = 0;
root->next = new DNode();
root->next->data = 10;
root->next->next = new DNode();
struct BNode() extends Node{
BNode* left = NULL;
BNode* right = NULL;
int data = 0;
};
BNode root = new BNode();
root->data = 5;
//root->left = NULL;
//root->right = NULL;
root->left->data = 3;
//root->left->left = NULL;
//root->left->right = NULL;
root->left->right->data = 4;
//root->left->right->left = NULL;
//root->left->right->right = NULL;
root->left->left->data = 1;
root->right->data = 6;
root->right->right->data = 11;
root->right->right->left->data = 7;
//Linked List Insert Function
Node* pushback(Node& input, Node& root) {
Node* itr = root;
while (itr->next != NULL) {
itr = itr->next;
}
itr->next = input;
//itr->next = new Node();
//manually put information from the user into the new node.
return itr->next;
}
Node* pushfront(Node& input, Node& root) {
Node* temp = input;
temp->next = root;
root = temp;
return root;
}
//HW comments
//Doubly linked list, its goona be push front and push back.
//Binary Tree, if oyu do push back, it should go to the next available spot. If you do push front it should almost create a new binary tree and the old binary tree is a left node.
//Take the structs and change them so that they're object oreiented in style. Have DNode extend Node. More complicated extends basic.
// Double linked List
Node* pushback(Node& input, Node& root) {
Node* itr = root;
while (itr->next != NULL) {
itr = itr->next;
}
itr->next = input;
input->prev = itr;
return itr->next;
}
Node* pushfront(Node& input, Node& root) {
Node* temp = input;
temp->next = root;
root->prev = temp;
root = temp;
return root;
}
//Binary Tree
BNode* pushback(BNode& input, BNode& root) {
BNode* itr = root;
while (itr != NULL) {
if (input->data > itr->data) {
itr = itr->right;
}
else {
itr = itr->left;
}
}
input = itr;
return itr;
}
BNode* pushfront(Node& input, BNode* root) {
BNode* temp = input;
temp->left = root;
BNode* itr = root;
while (itr->data != NULL) {
if (temp->left->right != NULL) {
while (temp->right != NULL) {
}
}
}
}