32 while (NULL != tree) {
33 if (tree->
data == data) {
37 if (data < tree->data) {
60 while (data != node->
data) {
61 if (data < node->data) {
62 if (NULL == node->
left) {
70 if (NULL == node->
right) {
97 while (NULL != node->
left) {
110 while (NULL != node && node->
data != data) {
111 if (data < node->data) {
127 if (NULL != node->
left && NULL != node->
right) {
135 if (NULL != node->
left) {
138 if (NULL != node->
parent) {
148 if (NULL != node->
right) {
151 if (NULL != node->
parent) {
162 if (NULL != node->
parent) {
171 if (NULL != node->
left) {
173 }
else if (NULL != node->
right) {
187 struct element * previous = tree;
201 if (previous == node->
right) {
208 if ((NULL == node->
left || previous == node->
left)) {
216 if (NULL != node->
right) {
238 printf(
"%02d(%02d)", data, depth);
239 for (i=0; i<depth; i++) printf(
"-");
struct element * findInOrderSuccessor(struct element *tree)
static void(* cb)(const void *)
void insertElement(struct element **tree, int data)
int main(int argc, char *argv[])
struct element * newElement(int data)
void deleteElement(struct element **tree, int data)
struct element * findElement(struct element *tree, int data)
void printElement(int data, int depth)
void traverse(struct element *tree, void(*cb)(int, int))