I am trying to implement a splay tree. A part of my code is below. I have figured out that this statement makes currentnode an alias for root even though the previous line reserves a memory for currentnode (or at least I think so). What I need is a way to use the currentnode as something independent from root, but with initial value (to point to) its contents.
Thanks is advance.Code:myNode *currentnode = currentnode->left = currentnode->right currentnode->parent = new myNode; currentnode = root; while(true){ if(a < currentnode->value){ // we examine if it can be a left child if (currentnode->left != NULL){ currentnode = currentnode->left; } else{ myNode *added = new myNode(a, NULL, NULL, currentnode); currentnode->left = added; cout << "currentnode->left address before rotations: " << currentnode->left << endl; cout << "root->left address before rotations: " << root->left << endl; cout << "currentnode address before rotations: " << currentnode << endl; cout << "root address before rotations: " << root << endl; rotations(added); cout << "currentnode address after rotations: " << currentnode << endl; cout << "root after rotations: " << root << endl; currentnode = NULL; return true; }



LinkBack URL
About LinkBacks


