8.8 Lab: BT PDF

Title 8.8 Lab: BT
Course Data Abstraction and Structures
Institution De Anza College
Pages 6
File Size 172.4 KB
File Type PDF
Total Downloads 53
Total Views 138

Summary

This lab is one BST.

The following classes/files make up the assignment:

- BinaryNode.h is a header file for binary nodes (template, given)
- BinaryTree.h is a header file for the BinaryTree library (template, incomplete)
- BinarySearchTree.h is a header file f...


Description

8.8 Lab: BT getItem() > newNodePtr->getItem()) parent->setLeftPtr(newNodePtr); else parent->setRightPtr(newNodePtr); } return nodePtr; } //Implementation to find the smallest: recursive template BinaryNode* BinarySearchTree::_findSmallest(BinaryNode* nodePtr, ItemType & smallest) const { smallest = 1e9; //large value, not present in tree if(nodePtr) { _findSmallest(nodePtr->getLeftPtr(), smallest); if(nodePtr->getItem() < smallest) { smallest = nodePtr->getItem(); } } return nodePtr; }

//Implementation to find the largest: recursive template BinaryNode* BinarySearchTree::_findLargest(BinaryNode* nodePtr, ItemType & biggest) const { biggest = -1*1e9; if(nodePtr) { _findLargest(nodePtr->getRightPtr(), biggest); if(nodePtr->getItem() > biggest) { biggest = nodePtr->getItem(); } } return nodePtr; }

#endif...


Similar Free PDFs