Computer Science 101

Data Abstraction

Gregory M. Kapfhammer


flickr photo by "Cowboy" Ben Alman shared under a Creative Commons (BY-NC-ND) license

Color Scheme

Key Concept

Corresponding Diagram

In-Class Discussion

In-Class Activity

Details in the Textbook

Linear data structures

Hierarchical data structures

Trees are like linked lists but ...

... they have "parent child" relationships!

Benefits of using trees?

Drawbacks of using trees?

Tree Type

A tree is a set of nodes

It stores data elements hierarchically

It contains a root node

It contains internal/external node(s)

The nodes have a parent-child relationship

What does this look like in memory?


flickr photo shared by Derek Severson under a Creative Commons ( BY-NC-ND ) license

Tree Type

A node can have an ... ancestor

... sibling

... descendant

A tree can contain a ... subtree

... a path of nodes

Any questions about trees?


flickr photo shared by Derek Severson under a Creative Commons ( BY-NC-ND ) license

Ordered trees

Un-ordered trees

Trade-offs of ordering?

Depth of a node = number of ancestors

Tree height = depth of "deepest" node

Binary trees

General trees

Tree traversal

Any questions about trees?

We will investigate these issues in assignments!