Trouble with error: Segmentation fault: 11

When I test my code on input file, I found that when the clock time larger than 8130, my program will be crushed, don't know why, I have already doubling the array size in minHeap. Plz help me , rly important to me.
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

#include<iostream>
#include<vector>
#include<string>
#include<sstream>
#include<fstream>
#include"minheap.h"
#include"rbtree.h"
using namespace std;

RBtree rbt;
minHeap heap;
tree mark=NULL;
job running_job=NULL;
int cur_time = 0;
int running_time = 0;
fstream output("output_file.txt", fstream::out | ios_base::trunc);



void out(tree t) {
    output << "(" << t->key << "," << t->execute_time << "," << t->total_time << ")";
}
void out(job j) {
    output << "(" << j->jobID << "," << j->execute_time << "," << j->total_time << ")";
}

/*As a time counter to track global time and then execute commands.*/
void Run() {
    if (heap.Empty())
        return;
    
    if (running_job == NULL) {
        running_job = heap.jobs[ROOT];
    }
    if (mark == NULL || mark->key != running_job->jobID)
        mark = rbt.search(running_job->jobID);
    running_job->execute_time++;
    mark->execute_time++;
    running_time++;
    
    if (running_job->execute_time == running_job->total_time) {
        running_time = 0;
        running_job = NULL;
        rbt.delnode(mark);
        heap.Pop();
    }
    else if(running_time==5){
        running_time = 0;
        heap.ShiftDown(ROOT);
        running_job = heap.jobs[ROOT];
    }
}

void InsertJob(int jobID, int total_time) {
    heap.InsertHeap(jobID, total_time);
    rbt.insert(jobID, total_time);
    if (running_time == 0) {
        running_job = heap.jobs[ROOT];
    }
}

void PrintJob(int jobID) {
    tree res = rbt.search(jobID);
    if (res == NULL) out(empty_node());
    else out(res);
    output << "\n";
}

void PrintJob(int low, int high) {

    vector<tree> res;
    int tot = 0;
    for (int i = low; i <= high; ++i){
        if (rbt.search(i) != NULL){
            tot++;
            res.push_back(rbt.search(i));
        }
    }
    for (int i = 0; i < res.size(); ++i){
        out(res[i]);
        if (i == res.size()-1) break;
        output << ",";
    }

    if (!tot)
        out(empty_node());
    output << "\n";   
}


void NextJob(int jobID) {
    tree res = rbt.upper_bound(jobID);
    out(res);
    output << "\n";
}

void PreviousJob(int jobID) {
    tree res = rbt.lower_bound(jobID);
    out(res);
    output << "\n";
}

bool in(string s,string p) {
    return s.find(p) != -1;
}

void run2present(int run_time) {
    while (cur_time < run_time)
        Run(), cur_time++;
}

/*Read input file, recognize commands and callback proper functions.*/
void LoadJobs(const string &path) {
    string s;
    ifstream input(path);
    int jobID, low, high, total_time, run_time;
    while (getline(input, s)) {
        if (in(s, "Insert")) {
            sscanf(s.c_str(), "%d: Insert(%d,%d)", &run_time, &jobID, &total_time);
            run2present(run_time);
            InsertJob(jobID, total_time);
        }
        else if (in(s, "PreviousJob")) {
            sscanf(s.c_str(), "%d: PreviousJob(%d)", &run_time, &jobID);
            run2present(run_time);
            PreviousJob(jobID);
        }
        else if (in(s, "NextJob")) {
            sscanf(s.c_str(), "%d: NextJob(%d)", &run_time, &jobID);
            run2present(run_time);
            NextJob(jobID);
        }
        else if (in(s, "PrintJob")) {
                if (in(s, ",")) {
                    sscanf(s.c_str(), "%d: PrintJob(%d,%d)", &run_time, &low, &high);
                    run2present(run_time);
                    PrintJob(low, high);
            }
            else {
                sscanf(s.c_str(), "%d: PrintJob(%d)", &run_time, &jobID);
                run2present(run_time);
                PrintJob(jobID);
            }
        }
    }
}

int main(int argc, char* argv[]){
    LoadJobs(argv[1]);
    output.close();
    return 0;
}

Last edited on
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
#pragma once
#define ROOT 1

#include <vector>
using namespace std;
typedef struct Job* job,j;
struct Job {
	int jobID;
	int execute_time;
	int total_time;
};
class minHeap {
public:
	vector<job> jobs;
	int len;
	int size;
	const static int multiple = 2;
	minHeap() {
		len = 0;
		size = 0;
		for (int i = 0; i < 10; i++) {
			jobs.push_back(new j);
			jobs[i]->jobID = jobs[i]->execute_time = jobs[i]->total_time = 0;
			++size;
		}
	}
	void ShiftDown(int); //Adjust minHeap after deleting new element.
	void ShiftUp(int);  //Adjust minHeap after inserting new element.
	void InsertHeap(int, int); //Insert new job element into minHeap
	int Parent(int);  //Find the parent of a element in minHeap.
	int LeftChild(int); //Find the left child of a element in minHeap.
	int RightChild(int);  //Find the right child of a element in minHeap.
	bool Empty();
	job Pop();  //Delete root element.
	void swap(int,int);  //Swap two elements.
	job top();  //Return root element.
	job empty_job() {return jobs[0];}
	// void check_size();
private:
	int _v(int);
};
job minHeap::top() {
	return jobs[ROOT];
}
void minHeap::InsertHeap(int jobID, int total_time) {
	job jo = new j;
	jo->jobID = jobID;
	jo->total_time = total_time;
	jo->execute_time = 0;
	++len;
	if (len == size){
		size *= multiple;
		for (int i = size/2; i < size; ++i){
			jobs.push_back(new j);
			jobs[i]->jobID = jobs[i]->execute_time = jobs[i]->total_time = 0;
		}
	}
	jobs[len] = jo;
	ShiftUp(len);
}
job minHeap::Pop() {
	job j = jobs[ROOT];
	swap(ROOT, len);
	jobs[len]->jobID = jobs[len]->execute_time = jobs[len]->total_time = 0;
	len--;
	ShiftDown(ROOT);
	return j;
}
void minHeap::swap(int a, int b) {
	job t = jobs[a];
	jobs[a] = jobs[b];
	jobs[b] = t;
}
int minHeap::_v(int index) {
	return jobs[index]->execute_time;
}
void minHeap::ShiftUp(int index) {
	while (_v(index) < _v(Parent(index)) && index > 1) {
		swap(index, Parent(index));
		index = Parent(index);
	}
}
void minHeap::ShiftDown(int index) {
	while (index < len) {
		int v = _v(index);
		int location = index;
		if (LeftChild(index) <= len) {
			if (_v(LeftChild(index)) <= _v(location)) {
				if (_v(LeftChild(index)) == _v(location)) {
					if (jobs[LeftChild(index)]->jobID < jobs[location]->jobID) {
						v = _v(LeftChild(index));
						location = LeftChild(index);
					}
				}
				else {
					v = _v(LeftChild(index));
					location = LeftChild(index);
				}
			}
		}

		if (RightChild(index) <= len) {
			if (_v(RightChild(index)) < _v(location)) {
				if (_v(RightChild(index)) == _v(location)) {
					if (jobs[RightChild(index)]->jobID < jobs[location]->jobID) {
						v = _v(RightChild(index));
						location = RightChild(index);
					}
				}
				else {
					v = _v(RightChild(index));
					location = RightChild(index);
				}
			}
		}

		if (location == index)break;
		swap(index, location);
		index = location;
	}
}

int minHeap::Parent(int index) {
	return index / 2;
}
int minHeap::LeftChild(int index) {
	return index * 2;
}

int minHeap::RightChild(int index) {
	return index * 2 + 1;
}
bool minHeap::Empty() {
	return len == 0;
}


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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
#include<iostream>
#include<limits>
using namespace std;
typedef struct node* tree;
struct node{
	int key; // jobID
	int total_time;
	int execute_time;
	tree parent;
	char color;
	tree left;
	tree right;
};
class RBtree {
	tree root;
	tree q;
public:
	RBtree() {
		q = NULL;
		root = NULL;
	}
	void insert(int,int); //Insert new job element into RBtree
	void insertfix(tree); //Rebalance RBtree after inserting new element.
	void leftrotate(tree); //LL rotation operation, a RBT rebalance strategy.
	void rightrotate(tree); //RR rotation operation, a RBT rebalance strategy.
	void del(int key); 
	void delnode(tree); 
	void delfix(tree, tree); 
	tree search(int); 
	tree upper_bound(int); 
	tree lower_bound(int); 
	// void inorder();
	// void levelOrder();
};

tree empty_node() {
	tree t = new node;
	t->key = 0;
	t->execute_time = 0;
	t->total_time = 0;
	return t;
}

void RBtree::insert(int key,int total_time){
	int i = 0;
	tree p, q;
	tree t = new node;
	t->key = key;
	t->total_time = total_time;
	t->execute_time = 0;
	t->left = NULL;
	t->right = NULL;
	t->color = 'r';
	p = root;
	q = NULL;
	if (root == NULL){
		root = t;
		t->parent = NULL;
	}
	else{
		while (p != NULL){
			q = p;
			if (p->key<t->key)
				p = p->right;
			else
				p = p->left;
		}
		t->parent = q;
		if (q->key<t->key)
			q->right = t;
		else
			q->left = t;
	}
	insertfix(t);
}

void RBtree::del(int key) {
	tree p;
	p = root;
	int found = 0;
	while (p != NULL && found == 0) {
		if (p->key == key)
			found = 1;
		if (found == 0) {
			if (p->key < key) p = p->right;
			else
				p = p->left;
		}
	}
	if (p != NULL) delnode(p);
}

void RBtree::delnode(tree pt) {
	tree child, parent;
    char color;
    if ( (pt->left!=NULL) && (pt->right!=NULL) ) {
        tree replace = pt;
        replace = replace->right;
        while (replace->left != NULL)
            replace = replace->left;
        if (pt->parent!=NULL) {
            if (pt->parent->left == pt)
                pt->parent->left = replace;
            else
                pt->parent->right = replace;
        } else {
            root = replace;
        }
        child = replace->right;
        parent = replace->parent;
        color = replace->color;
        if (parent == pt) {
            parent = replace;
        } else {
            if (child!=NULL)
                child->parent = parent;
            parent->left = child;
            replace->right = pt->right;
            pt->right->parent = replace;
        }
        replace->parent = pt->parent;
        replace->color = pt->color;
        replace->left = pt->left;
        pt->left->parent = replace;
        if (color == 'b')
            delfix(child, parent);
        pt = NULL;
        return ;
    }
    if (pt->left !=NULL) {
        child = pt->left;
    } else {
        child = pt->right;
    }
    parent = pt->parent;
    color = pt->color;
    if (child!=NULL)
        child->parent = parent;
    if (parent!=NULL) {
        if (parent->left == pt)
            parent->left = child;
        else
            parent->right = child;
    } else {
        root = child;
    }
    if (color == 'b')
        delfix(child, parent);
    pt = NULL;
}

void RBtree:: insertfix (tree t){
	tree parent_pt = NULL;
	tree grand_parent_pt = NULL;

	while ((t != root) && (t->color != 'b') && (t->parent->color == 'r')){

		parent_pt = t->parent;
		grand_parent_pt = t->parent->parent;

		if (parent_pt == grand_parent_pt->left){
			tree uncle_pt = grand_parent_pt->right;

			if (uncle_pt != NULL && uncle_pt->color == 'r'){
				grand_parent_pt->color = 'r';
				parent_pt->color = 'b';
				uncle_pt->color = 'b';
				t = grand_parent_pt;
			}

			else{
				if (t == parent_pt->right){
					leftrotate(parent_pt);
					t = parent_pt;
					parent_pt = t->parent;
				}
				rightrotate(grand_parent_pt);
				char temp;
				temp = grand_parent_pt->color;
				grand_parent_pt->color = parent_pt->color;
				parent_pt->color = temp;
				t = parent_pt;
			}
		}
		else{
			tree uncle_pt = grand_parent_pt->left;
			if ((uncle_pt != NULL) && (uncle_pt->color == 'r')){
				grand_parent_pt->color = 'r';
				parent_pt->color = 'b';
				uncle_pt->color = 'b';
				t = grand_parent_pt;
			}
			else{
				if(t == parent_pt->left){
					rightrotate(parent_pt);
					t = parent_pt;
					parent_pt = t->parent;
				}
				leftrotate(grand_parent_pt);
				char temp;
				temp = grand_parent_pt->color;
				grand_parent_pt->color = parent_pt->color;
				parent_pt->color = temp;
				t = parent_pt;
			}
		}
	}
	root->color = 'b';
}

void RBtree::delfix(tree node, tree parent){
	tree other;
	while ((node == NULL || node->color == 'b')&& (node != root)){
		if (parent->left == node){
			other = parent->right;
			if ( other-> color == 'r'){
				other ->color = 'b';
				parent->color = 'r';
				leftrotate(parent);
				other = parent->right;
			}
			if ((other->left == NULL || other->left->color =='b')&&
				  (other->right == NULL || other->right->color == 'b')){
				other -> color = 'r';
				node = parent;
				parent = node->parent;
			}
			else{
				if (other->right == NULL || other->right->color == 'b'){
					other->right->color = 'b';
					other->color = 'r';
					rightrotate(other);
					other = parent->right;
				}
				other->color = parent->color;
				parent->color = 'b';
				other->right->color = 'b';
				leftrotate(parent);
				node = root;
				break;
			}
		}
		else{
			other = parent->left;
			if (other->color == 'r'){
				other->color = 'b';
				parent->color= 'r';
				rightrotate(parent);
				other = parent->left;
			}
			if ((other->left == NULL || other->left->color =='b')&&
				  (other->right == NULL || other->right->color == 'b')){
				other->color = 'r';
				node = parent;
				parent = node->parent;
			}
			else{
				if (other->left == NULL || other->left->color == 'b'){
					other->right->color = 'b';
					other -> color = 'r';
					leftrotate(other);
					other = parent->left;
				}
				other->color = parent->color;
				parent->color = 'b';
				other->left->color = 'b';
				rightrotate(parent);
				node = root;
				break;
			}
		}
	}
	if(node != NULL) node->color = 'b';
}

void RBtree::leftrotate(tree pt){
	if (pt->right == NULL)
		return;
	else{
		tree pt_right = pt->right;
 
	    pt->right = pt_right->left;
	 
	    if (pt->right != NULL)
	        pt->right->parent = pt;
	 
	    pt_right->parent = pt->parent;
	 
	    if (pt->parent == NULL)
	        root = pt_right;
	 
	    else if (pt == pt->parent->left)
	        pt->parent->left = pt_right;
	 
	    else
	        pt->parent->right = pt_right;
	 
	    pt_right->left = pt;
	    pt->parent = pt_right;
	}
}

void RBtree::rightrotate(tree pt){
	if (pt->left == NULL)
		return;
	else{
		tree pt_left = pt->left;
 
	    pt->left = pt_left->right;
	 
	    if (pt->left != NULL)
	        pt->left->parent = pt;
	 
	    pt_left->parent = pt->parent;
	 
	    if (pt->parent == NULL)
	        root = pt_left;
	 
	    else if (pt == pt->parent->left)
	        pt->parent->left = pt_left;
	 
	    else
	        pt->parent->right = pt_left;
	 
	    pt_left->right = pt;
	    pt->parent = pt_left;
	}
}

tree RBtree::search(int key){
	tree p = root;
	int found = 0;
	while (p != NULL && found == 0){
		if (p->key ==key)
			found = 1;
		if (found == 0){
			if (p->key<key) p = p->right;
			else
				p = p->left;
		}
	}
	if (p == NULL) return NULL;
		// return empty_node();
	return p;
}
tree RBtree::upper_bound(int key) {
	tree p = root;
	tree res=empty_node();
	int distance = numeric_limits<int>::max();
	while (p != NULL) {
		if (p->key > key) {
			if (p->key - key < distance) {
				res = p;
				distance = p->key - key;
			}
			p = p->left;
		}
		else {
			p = p->right;
		}
	}
	return res;

}
tree RBtree::lower_bound(int key) {
	tree p = root;
	tree res = empty_node();
	int distance = numeric_limits<int>::max();
	while (p!=NULL) {
		if (p->key < key) {
			if (key - p->key< distance) {
				res = p;
				distance = key - p->key;
			}
			p = p->right;
		}
		else {
			p = p->left;
		}
	}
	return res;
}
Input.txt

0: Insert(16385,138)
4: Insert(19059,179)
32: Insert(5296,133)
130: Insert(13764,126)
220: Insert(15569,153)
283: Insert(4480,60)
304: Insert(13257,109)
325: Insert(10492,169)
402: Insert(15269,83)
466: Insert(3207,140)
480: Insert(18289,91)
495: Insert(5131,88)
563: Insert(4219,63)
571: Insert(19833,130)
605: Insert(802,142)
669: Insert(12593,198)
749: Insert(1428,128)
845: Insert(13213,185)
917: Insert(9390,91)
1004: Insert(18442,125)
1076: Insert(13320,32)
1101: Insert(13188,141)
1159: Insert(4172,197)
1235: Insert(2609,13)
1245: Insert(2116,48)
1293: Insert(19770,108)
1326: Insert(11644,180)
1372: Insert(12639,41)
1399: Insert(898,59)
1429: Insert(15864,191)
1507: Insert(18872,169)
1544: Insert(945,183)
1638: Insert(17218,24)
1656: Insert(4727,24)
1662: Insert(10554,149)
1714: Insert(16455,142)
1807: Insert(5738,175)
1819: Insert(7775,188)
1897: Insert(13316,63)
1900: Insert(4233,71)
1994: Insert(15063,56)
2084: Insert(4701,192)
2179: Insert(4560,141)
2197: Insert(9380,61)
2260: Insert(5727,177)
2347: Insert(2419,78)
2354: Insert(15444,159)
2398: Insert(8146,111)
2444: Insert(15397,110)
2448: Insert(17929,190)
2450: Insert(14673,57)
2510: Insert(16280,43)
2599: Insert(2808,201)
2648: Insert(9601,159)
2729: Insert(9113,63)
2816: Insert(12744,106)
2894: Insert(13001,129)
2955: Insert(19848,157)
3037: Insert(13402,168)
3057: Insert(15911,49)
3145: Insert(13575,68)
3158: Insert(265,98)
3216: Insert(18219,173)
3218: Insert(7625,35)
3242: Insert(5144,183)
3266: Insert(13275,39)
3346: Insert(18354,144)
3426: Insert(3032,97)
3502: Insert(11478,18)
3516: Insert(8251,185)
3548: Insert(8784,208)
3624: Insert(16596,132)
3706: Insert(8515,150)
3778: Insert(8436,174)
3791: Insert(17354,185)
3886: Insert(15348,103)
3947: Insert(16043,64)
3981: Insert(2714,71)
3990: Insert(10005,94)
4000: Insert(7690,183)
4035: Insert(9847,29)
4055: Insert(12220,142)
4144: Insert(8005,169)
4224: Insert(16837,52)
4297: Insert(16605,134)
4304: Insert(8433,167)
4306: Insert(2256,150)
4359: Insert(15345,151)
4377: Insert(6617,11)
4386: Insert(14734,200)
4483: Insert(2392,173)
4527: Insert(16222,60)
4606: Insert(15529,177)
4670: Insert(2279,58)
4769: Insert(13323,111)
4846: Insert(2230,23)
4871: Insert(9636,22)
4966: Insert(19214,199)
4990: Insert(19739,62)
4997: Insert(17160,24)
5066: Insert(13175,49)
5118: Insert(5793,36)
5213: Insert(7009,79)
5271: Insert(13917,169)
5336: Insert(10993,204)
5338: Insert(11092,30)
5402: Insert(11583,136)
5424: Insert(7922,124)
5470: Insert(10452,52)
5535: Insert(17271,38)
5592: Insert(13374,116)
5650: Insert(17303,175)
5673: Insert(14667,45)
5749: Insert(10213,55)
5771: Insert(15414,91)
5808: Insert(18850,193)
5812: Insert(13563,71)
5897: Insert(5032,20)
5973: Insert(16204,85)
6033: Insert(14929,100)
6082: Insert(2546,190)
6119: Insert(13387,124)
6211: Insert(15637,174)
6269: Insert(443,91)
6275: Insert(16860,91)
6298: Insert(17662,56)
6375: Insert(8729,24)
6429: Insert(16465,123)
6512: Insert(13109,182)
6529: Insert(10176,73)
6558: Insert(15091,78)
6653: Insert(566,139)
6747: Insert(17241,109)
6837: Insert(12556,52)
6885: Insert(6773,204)
6928: Insert(6200,133)
6972: Insert(15478,107)
7005: Insert(15074,119)
7018: Insert(776,50)
7093: Insert(6634,140)
7188: Insert(6147,180)
7284: Insert(15792,155)
7362: Insert(8016,48)
7410: Insert(11071,158)
7420: Insert(9130,173)
7505: Insert(8125,89)
7508: Insert(1294,145)
7573: Insert(12261,26)
7607: Insert(9696,46)
7642: Insert(2195,111)
7645: Insert(15424,170)
7727: Insert(924,72)
7754: Insert(15222,201)
7823: Insert(15655,82)
7896: Insert(643,161)
7934: Insert(8081,197)
7942: Insert(16776,202)
7948: Insert(5349,179)
7976: Insert(1209,184)
8061: Insert(12860,30)
8087: Insert(5298,110)
8138: Insert(604,148)
8185: Insert(11685,41)
8223: Insert(7794,105)
8252: Insert(11875,134)
8265: Insert(6212,66)
8346: Insert(8242,129)
8440: Insert(18024,105)
8457: Insert(4873,115)
8548: Insert(19591,130)
8630: Insert(8499,206)
8716: Insert(4165,145)
8814: Insert(7532,89)
8881: Insert(19923,165)
8936: Insert(4678,75)
8973: Insert(16610,133)
8993: Insert(10455,181)
9078: Insert(12795,126)
9088: Insert(338,81)
9171: Insert(5696,158)
9234: Insert(5552,129)
9316: Insert(3140,104)
9395: Insert(18960,189)
9469: Insert(7142,148)
9564: Insert(15337,69)
9606: Insert(1459,178)
9645: Insert(294,207)
9661: Insert(6166,115)
9686: Insert(14127,77)
9704: Insert(17809,205)
9764: Insert(941,134)
9791: Insert(2987,41)
9831: Insert(9216,207)
9857: Insert(6872,42)
9880: Insert(2484,78)
9927: Insert(6002,75)
10023: Insert(5274,35)
10038: Insert(6140,197)
10114: Insert(8925,76)
10121: Insert(3745,149)
10187: Insert(18350,131)
10273: Insert(9977,47)
10350: Insert(4582,13)
10374: Insert(3128,41)
10423: Insert(16627,18)
10433: Insert(8468,45)
10451: Insert(4834,53)
10518: Insert(2579,44)
10535: Insert(2326,175)
10553: Insert(3601,196)
10567: Insert(1798,68)
10622: Insert(19561,166)
10706: Insert(1519,49)
10742: Insert(10097,126)
10762: Insert(3520,159)
10766: Insert(12228,40)
10826: Insert(15855,65)
10877: Insert(11942,115)
10939: Insert(896,191)
11004: Insert(6109,101)
11061: Insert(5622,125)
11150: Insert(16309,59)
11184: Insert(19291,187)
11214: Insert(12627,163)
11227: Insert(19490,73)
11300: Insert(16005,208)
11303: Insert(18948,62)
11321: Insert(1192,201)
11323: Insert(2145,53)
11344: Insert(1354,119)
11368: Insert(1499,149)
11450: Insert(15128,144)
11463: Insert(19559,204)
11548: Insert(16073,173)
11564: Insert(6370,111)
11639: Insert(2999,60)
11686: Insert(12923,72)
11732: Insert(11720,155)
11782: Insert(5226,189)
11798: Insert(1862,26)
11832: Insert(4780,169)
11931: Insert(4564,123)
11945: Insert(9357,41)
11986: Insert(6930,57)
12061: Insert(13313,69)
12064: Insert(15405,66)
12070: Insert(8564,56)
12138: Insert(8297,203)
12145: Insert(15821,182)
12170: Insert(1618,110)
12236: Insert(1208,42)
12327: Insert(6969,98)
12328: Insert(1665,57)
12405: Insert(14149,144)
12493: Insert(4997,134)
12497: Insert(5959,29)
12534: Insert(14556,27)
12559: Insert(16474,73)
12595: Insert(12699,193)
12654: Insert(1129,10)
12709: Insert(6750,60)
12765: Insert(10017,93)
12834: Insert(15086,125)
12905: Insert(12769,51)
12917: Insert(7898,21)
13012: Insert(5998,28)
13089: Insert(16398,43)
13142: Insert(14166,67)
13190: Insert(16393,187)
13263: Insert(4385,174)
13288: Insert(11425,36)
13350: Insert(7184,144)
13399: Insert(11451,139)
13403: Insert(11095,196)
13492: Insert(5579,65)
13537: Insert(17520,96)
13563: Insert(1196,30)
13632: Insert(18416,148)
13694: Insert(19594,136)
13744: Insert(19942,198)
13749: Insert(3851,172)
Updated: I found an error which is in the delfix function :

1
2
3
4
5
6
7
8
9
10
11
12
13
else{
				if (other->right == NULL || other->right->color == 'b'){
					other->right->color = 'b';
					other->color = 'r';
					rightrotate(other);
					other = parent->right;
				}
				other->color = parent->color;
				parent->color = 'b';
				other->right->color = 'b';
				leftrotate(parent);
				node = root;
				break;


where other->right-> color should be other->left->color, But then the error shows up again and changes to the bus error 10.
Topic archived. No new replies allowed.