DrawTree

DrawTree - Drawing Tree on Memory/Disk Drawing In Memory...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

View Full DocumentRight Arrow Icon

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

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

Unformatted text preview: Drawing Tree on Memory/Disk Drawing In Memory Given the following class skeletons, draw the insertion of: Tracker 1 Dan 2 Gary 3 Brian 4 Jason 5 Zhang 6 class UCSDStudent { char * name; int num; } template <class Whatever> class TNode { Whatever * data; TNode<Whatever> *left, *right; } template <class Whatever> class Tree { TNode<Whatever> * root; } Command: i Tracker 1 root Tree right left 1 num Tracker name data Command: i Dan 2 root Tree right left 1 num Tracker name data right left 2 num Dan name data Command: i Gary 3 root Tree right left 1 num Tracker name data right left 2 num Dan name data right left 3 num Gary name data Command: i Brian 4 root Tree right left 1 num Tracker name data right left 2 num Dan name data right left 3 num Gary name data right left 4 num Brian name data Command: i Jason 5 root Tree right left 1 num Tracker name data right left 2 num Dan name data right left 3 num Gary name data right left 4 num Brian name data right left 5 num Jason name data This insertion knocks Tracker out of balance. Tracker needs to be removed and reinserted Command: i Jason 5 (con’t) root Tree right left 2 num Dan name data right left 3 num Gary name data right left 4 num Brian name data right left 5 num Jason name data right left 1 num Tracker name data On removal of Tracker, Dan becomes the new root. Reinsertion proceeds, following the right pointers down to Jason’s null reference, where Tracker is finally reinserted. Command: i Zhang 6 root Tree right left 2 num Dan name data right left 3 num Gary name...
View Full Document

This note was uploaded on 04/13/2008 for the course CSE 12 taught by Professor Gary during the Spring '08 term at UCSD.

Page1 / 23

DrawTree - Drawing Tree on Memory/Disk Drawing In Memory...

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

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