CS163_Week6 - CS163: Data structures Week 6: Table...

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

View Full Document Right Arrow Icon
CS163: Data structures Week 6: Table abstractions (cont.) 6/2008
Background image of page 1

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

View Full DocumentRight Arrow Icon
dbtien – Data structures What will be discussed today? Table abstractions in terms of new data structures: Trees Requires data be organized in a hierarchical fashion
Background image of page 2
dbtien – Data structures Tree Introduction Remember when we learned about tables? We found that none of the methods for implementing tables was really adequate. With many applications, table operations end up not being as efficient as necessary. We found that hashing is good for retrieval, but doesn't help if our goal is also to obtain a sorted list of information.
Background image of page 3

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

View Full DocumentRight Arrow Icon
dbtien – Data structures Tree Introduction We found that the binary search also allows for fast retrieval, but is limited to array implementations versus linked list. Because of this, we need to move to more sophisticated implementations of tables, using binary search trees! These are "nonlinear" implementations of the ADT table.
Background image of page 4
dbtien – Data structures Tree Terminology Trees are used to represent the relationship between data items. All trees are hierarchical in nature which means there is a parent-child relationship between "nodes" in a tree. The lines between nodes are called directed edges. If there is a directed edge from node A to node B -- then A is the parent of B and B is a child of A.
Background image of page 5

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

View Full DocumentRight Arrow Icon
dbtien – Data structures Tree Terminology Children of the same parent are called siblings. Each node in a tree has at most one parent, starting at the top with the root node (which has no parent). Parent of n The node directly above node n in the tree Child of n The node directly below the node n in the tree
Background image of page 6
dbtien – Data structures Tree Terminology Root The only node in the tree with no parent Leaf A node with no children Siblings Nodes with a common parent Ancestor of n A node on the path from the root to n
Background image of page 7

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

View Full DocumentRight Arrow Icon
dbtien – Data structures Tree Terminology Descendant of n A node on a path from n to a leaf Empty tree A tree with no nodes Subtree of n A tree that consists of a child of n and the child's descendants Height The number of nodes on the longest path from root to a leaf
Background image of page 8
dbtien – Data structures Tree Terminology Binary Tree A tree in which each node has at most two children Full Binary Tree A binary tree of height h whose leaves are all at the level h and whose nodes all have two children; this is considered to be completely balanced
Background image of page 9

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

View Full DocumentRight Arrow Icon
dbtien – Data structures Binary Trees A binary tree is a tree where each node has no more than 2 children. If we traverse down a binary tree -- for every node -- there are either no children (making this node a leaf) or there are two children called the left and right subtrees (A subtree is a subset of a tree including some node in the tree along with all of its descendants).
Background image of page 10
dbtien – Data structures Binary Search Trees The nodes of a binary tree contain values. For a
Background image of page 11

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

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

This note was uploaded on 11/03/2010 for the course CS 16x taught by Professor Tang during the Spring '10 term at Aachen University of Applied Sciences.

Page1 / 44

CS163_Week6 - CS163: Data structures Week 6: Table...

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

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