CSC 216 Lecture Notes - Lecture 25: Binary Tree, Parse Tree, Longest Path Problem

58 views5 pages
22 Nov 2016
School
Course
Professor

Document Summary

Tree: a directed, acyclic structure of linked nodes: directed: has one-way links between nodes, acyclic: no path wraps back around to the same node twice, binary tree: a tree where each node has at most two children. A tree can be defined as either: empty (null), or, a root node that contains: Note: the left and/or right subtree could be empty. Examples of trees in computer science are: folders/files on a computer, family genealogy, organizational charts, ai: decision trees, compilers: parse tree. A = (b + c) * d; A (cid:271)asi(cid:272) t(cid:396)ee (cid:374)ode o(cid:271)je(cid:272)t sto(cid:396)es data a(cid:374)d (cid:396)efe(cid:396)s to the (cid:374)odes to the (cid:862)left(cid:863) a(cid:374)d (cid:862)(cid:396)ight(cid:863) of itself. As you"(cid:448)e al(cid:396)eady (cid:271)ee(cid:374) told, (cid:373)ultiple (cid:374)odes (cid:272)a(cid:374) (cid:271)e li(cid:374)ked togethe(cid:396) i(cid:374)to a la(cid:396)ge(cid:396) t(cid:396)ee. Example code: inttreenode and inttree: inttreenode: // constructs a leaf node with the given data public inttreenode(int data) { this (data, null, null)

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents