2-23 - Problem Solving with Computers-II CS 24 1 Recap...

This preview shows pages 1–17. Sign up to view the full content.

Problem Solving with Computers-II CS 24 February 23, 2010 1

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

View Full Document
Recap Recursion General structure of recursive solutions Why do recursive solutions terminate? How do recursive programs manage the stack? Tail recursion When to use recursion? 2
Lecture Plan Tree ADT Binary Search Tree (BST) ADT Feedback on Lab sections Wednesday’s lab section Ontology ADT Course feedback Programming project Teams Second midterm 3

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

View Full Document
4 Owner Jake Manager Chef Brad Carol Waitress Waiter Cook Helper Joyce Chris Max Len Jake’s Pizza Shop UNIQUE PATH BETWEEN NODES
5 Owner Jake Manager Chef Brad Carol Waitress Waiter Cook Helper Joyce Chris Max Len Nomenclature ROOT NODE LEAF NODE LEVEL 0 LEVEL 1 LEVEL 2 PARENT, CHILD, ANCESTOR, DESCENDANT SUBTREE

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

View Full Document
6 Trees Level: Distance of a node from root Height: The maximum level
7 Trees Why is this not a tree ?

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

View Full Document
8 A node can have at most two children. The two children of a node are called the left child and the right child, if they exist. Binary Tree
9 A Binary Tree Q V T K S A E L

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

View Full Document
10 How Many Leaf Nodes? Q V T K S A E L
11 How Many Descendants of Q? Q V T K S A E L

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

View Full Document
12 How Many Ancestors of K? Q V T K S A E L
13 Trees How many different binary trees can be made from 2 nodes? 4 nodes? 6 nodes?

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

View Full Document
14 Implementing a Binary Tree with Pointers and Dynamic Data Q V T K S A E L
15 Structure of a Tree Node Possible to add a parent pointer

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

View Full Document
16 A special kind of binary tree in which: 1. Each node contains a distinct data value, 2. The key values in the tree can be compared using “greater than” and “less than”, and 3. The key value of each node in the tree is less than every key value in its right subtree , and greater than every key value in its left subtree.
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 / 39

2-23 - Problem Solving with Computers-II CS 24 1 Recap...

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

View Full Document
Ask a homework question - tutors are online