ahh of course pass by reference, thank you
if(head == NULL)
NodePtr temp = new IntNode(value, NULL);
head = temp;
else
NodePtr temp = new IntNode(value);
temp->link = head;
head = temp;
counter++;
if(head == NULL)
NodePtr temp = new IntNode(value, NULL);
head = temp;
else
NodePtr p = head;
while(p->link != NULL)
p = p->link;
p->link = new IntNode(value)
counter++;
if(head == NULL)
return;
else
for(NodePtr p = head; p != NULL; p = p->link){
if(p->link->data == value)
NodePtr temp = p->link;
p->link = temp->link;
delete temp;
if(node == NULL)
return;
else if(node->key == key)
remove_root(node);
else if(node->key < key)
remove(node->left, key);
else
remove(node->right, key)
if(node == NULL)
return;
else if(node->key == key)
remove_root(node);
else if(node->key < key)
remove(node->left, key);
else
remove(node->right, key);
NodePtr temp;
if(root->is_leaf())
delete root;
root = NULL;
else if(root->left == NULL)
temp = root->right;
delete root;
root = temp;
else if(root->right == NULL)
temp = root->left;
delete root;
root = temp;
else
NodePtr new_root = remove_min(root->right);
new_root->left = root->left;
new_root->right = root->right;
delete root;
root = new_root;
if(node->left == NULL)
NodePtr oldNode = node;
node = node->right;
return oldNode;
else
return remove_min(node->left);
capacity = capacity * 2;
int* newArray = new int[capacity];
for(int i = 0; i < count; ++i)
newArray[i] = array[i]
delete []array;
return newArray;
if(node == NULL)
return 0;
return(sizeHelp(node->left) + sizeHelp(node->right) + 1)
nodeptr,indent,prefix;
if(root == NULL)
return;
char letter = ' ';
if(root->is_leaf())
letter = root->letter;
cout << string(indent, ' ') << prefix << "(" << letter << " [" << root->frequency << "]";
if(root->is_leaf()) {
cout << ")" << endl;
else
cout << endl;
print_tree(root->left, indent + INDENT_SIZE, "0");
print_tree(root->right, indent + INDENT_SIZE, "1");
cout << string(indent, ' ') << ")" << endl;
if (aStack.empty()) {
topPtr = NULL;
else
topPtr = new CharStackFrame;
topPtr->data = (aStack.topPtr)->data;
newFramePtr = topPtr;
for (CharStackFramePtr originalPtr = (aStack.topPtr)->link;
originalPtr != NULL;
originalPtr = originalPtr->link)
newFramePtr->link = new CharStackFrame;
newFramePtr = newFramePtr->link;
newFramePtr->data = originalPtr->data;
newFramePtr->link = NULL;
while (!empty())
pop( );
return (topPtr == NULL);
CharStackFramePtr newFrame;
newFrame = new CharStackFrame;
newFrame->data = the_symbol;
newFrame->link = topPtr;
topPtr = newFrame;
if (empty())
throw EmptyStackException();
char result = topPtr->data;
CharStackFramePtr temp_ptr;
temp_ptr = topPtr;
topPtr = topPtr->link;
delete temp_ptr;
return result;
if (empty())
throw EmptyStackException();
return topPtr->data;
for (CharStackFramePtr iter = aStack.topPtr; iter != NULL; iter = iter->link) {
outs << (iter->data);
outs << endl;
return outs;
Last edited on