Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

How do I fix my retrieve functions? #include BSTree.h template BSTree ::BSTreeNode::BSTreeNode ( const DataType &nodeDataItem, BSTreeNode *leftPtr, BSTreeNode *rightPtr ) { } template <

How do I fix my retrieve functions?

#include "BSTree.h"

template

BSTree::BSTreeNode::BSTreeNode ( const DataType &nodeDataItem, BSTreeNode *leftPtr, BSTreeNode *rightPtr )

{

}

template < typename DataType, class KeyType >

BSTree::BSTree ()

{

root = NULL;

}

template < typename DataType, class KeyType >

BSTree::BSTree ( const BSTree& other )

{

*this = other;

}

template < typename DataType, class KeyType >

BSTree& BSTree:: operator= ( const BSTree& other )

{

if (*this == &other)

return *this;

clear();

copyHelper(root, other.root);

return *this;

}

template < typename DataType, class KeyType >

BSTree::~BSTree ()

{

clear();

}

template < typename DataType, class KeyType >

void BSTree::insert ( const DataType& newDataItem )

{

KeyType key = newDataItem.getKey();

}

template < typename DataType, class KeyType >

bool BSTree::retrieve ( const KeyType& searchKey, DataType& searchDataItem ) const

{

return retrieve_sub(searchKey, searchDataItem, root);

}

template < typename DataType, class KeyType >

bool BSTree::remove ( const KeyType& deleteKey )

{

return removeHelper(root, deleteKey);

}

template < typename DataType, class KeyType >

void BSTree::writeKeys () const

{

writeKeysHelper(root);

cout << endl;

}

template < typename DataType, class KeyType >

void BSTree::clear ()

{

clearHelper(root);

}

template < typename DataType, class KeyType >

bool BSTree::isEmpty () const

{

return (root == NULL);

}

template < typename DataType, class KeyType >

int BSTree::getHeight () const

{

return getHeightHelper(root, 0);

}

template < typename DataType, class KeyType >

int BSTree::getCount () const

{

return getCountHelper(root);

}

template < typename DataType, class KeyType >

void BSTree::writeLessThan ( const KeyType& searchKey ) const

{

// variables

KeyType givenKey = searchKey;

bool keysAlreadyWritten = false;

// case: the tree is empty

if (root == NULL)

{

// report that tree is empty by printing whitespace

cout << endl;

}

// case: the tree has contents

else

{

// call the helper function

writeLessThan_sub(givenKey, root, NULL, keysAlreadyWritten);

// no keys printed yet

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Theory Icdt 99 7th International Conference Jerusalem Israel January 10 12 1999 Proceedings Lncs 1540

Authors: Catriel Beeri ,Peter Buneman

1st Edition

3540654526, 978-3540654520

More Books

Students also viewed these Databases questions