Sorry, I cut the deleteRandom() function off, here it is:
Code:template<class T> void BinSearchTree<T>::deleteRandom() { vector<int> myVector; Stack<BinSearchNode<T>*> pushToVector; BinSearchNode<T> *p = root; if(p != 0) { pushToVector.push(p); while(!pushToVector.empty()) { p = pushToVector.pop(); myVector.push_back(p->key); if(p->right != 0) pushToVector.push(p->right); if(p->left != 0) pushToVector.push(p->left); } } int elToDelete = rand()%myVector.size(); cout << myVector[(elToDelete-1)] << " deleted" << endl; int keySearch = myVector[(elToDelete-1)]; Queue<BinSearchNode<T>*> myQueue; BinSearchNode<T> *q = root; if(q != 0) { myQueue.enqueue(q); while(!myQueue.empty()) { q = myQueue.dequeue(); if(q->key == keySearch) { cout << "here!" << endl; deleteByCopying(q); //kaboom! } if(q->left != 0) myQueue.enqueue(q->left); if(q->right != 0) myQueue.enqueue(q->right); } } }