3-9 - Problem Solving with Computers-II CS 24 March 9, 2010...

Info iconThis preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
Problem Solving with Computers-II CS 24 March 9, 2010 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Announcements Lab section feedback Feedback from class Extra credit for Programming project Design and Implementation of GetBestDocument Deadlines Lab 9: Friday 5 pm Final Wed March 17, 8-11 am Final review Tuesday 3/16 6-8 HFH 1132 (Harry) Office hours Monday 3/15 5-7 pm (Saiph) Topics/format posted coming weekend 2
Background image of page 2
Recap C++ language details Constructor, copy constructor, destructor, templates C++ STL Tree and BST ADT Recursive implementations 3
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Lecture Plan Tree and BST ADT Iterative implementations Heap 4
Background image of page 4
5 Iterative InsertItem
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Iterative InsertItem void TreeType::InsertItem(ItemType item) { TreeNode* newNode; TreeNode* nodePtr; TreeNode* parentPtr; newNode = new TreeNode; newNode->info = item; newNode->left = NULL; newNode->right = NULL; FindNode(root, item, nodePtr, parentPtr); if (parentPtr == NULL) root = newNode; else if (item < parentPtr->info) parentPtr->left = newNode; else parentPtr->right = newNode; }
Background image of page 6
void FindNode(TreeNode* tree, ItemType item, { nodePtr = tree; parentPtr = NULL; bool found = false; { if (item < nodePtr->info) { parentPtr = nodePtr; nodePtr = nodePtr->left; } else if (item > nodePtr->info) { parentPtr = nodePtr; nodePtr = nodePtr->right; } else found = true; } } 7 FindNode
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 Finding the Insertion Point insert 13
Background image of page 8
9 Finding the Insertion Point insert 13
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10 Finding the Insertion Point insert 13
Background image of page 10
11 Finding the Insertion Point insert 13
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
12 Attaching the New Node insert 13
Background image of page 12
13 Iterative InsertItem void TreeType::InsertItem(ItemType item) { TreeNode* newNode; TreeNode* nodePtr; TreeNode* parentPtr; newNode = new TreeNode; newNode->info = item; newNode->left = NULL; newNode->right = NULL; FindNode(root, item, nodePtr, parentPtr); if (parentPtr == NULL)
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/26/2010 for the course CS cs24 taught by Professor Singh during the Winter '10 term at UCSB.

Page1 / 50

3-9 - Problem Solving with Computers-II CS 24 March 9, 2010...

This preview shows document pages 1 - 14. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online