30 -39 - Announcements Lecture 30 Assignment 5 individual...

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

View Full Document Right Arrow Icon
1 Announcements Lecture 30 Assignment 5 – individual maintenance assignment; due this weekend Topics for today: – Special tree types – Heaps • Heapsort – hashtables Self Balancing BST Variants AVL tree • is-a BST in which for each node the difference in height between its two subtrees is at most 1 2-3-4 tree •a node has either 1 value and 2 children, 2 values and 3 children, or 3 values and 4 children •It has better balancing properties than a BST which can degenerate; insures O(log 2 n) operations Red-black tree •construction of 2-3-4 trees is complex, so we build an equivalent binary tree known as a red-black tree See Ch. 11 if you want more info. AVL Tree 70 90 60 99 80 75 50 78 2-3-4 Tree: Node Types A 2-node value < A value > A A B 3-node A < B value < A A < value < B value > B A B C 4-node A < B < C value < A A < value < B value > C B < value < C 2-3-4 Tree Example Example of Building a 2-3-4 Tree Insertion Sequence: 2, 15, 12, 4, 8, 10, 25, 35, 55, 11, 9, 5, 7 Insert 8
Background image of page 1

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

View Full DocumentRight Arrow Icon
2 Example of 2-3-4 Tree (Cont…) Example (Cont…) Insert 7 Some Other Types of Binary Trees Expression tree – Each node contains an operator or an operand – Used by most modern compilers Huffman tree – Represents Huffman codes for characters that might appear in a text file – Huffman code uses different numbers of bits to encode letters as opposed to ASCII or Unicode Huffman Trees A Huffman tree is a binary tree used to store a code that facilitates file compression A Huffman coding scheme can be implemented using a binary tree and a PriorityQueue A straight binary encoding of an alphabet assigns a unique binary number to each symbol in the alphabet – Ascii or Unicode for example The message “go eagles” requires 144 bits in Unicode but only 38 bits using Huffman coding Huffman Trees (continued) Huffman Trees (continued)
Background image of page 2
3 Tree Review A tree is a recursive, nonlinear data structure that is used to represent data that is organized as a hierarchy A binary tree is a collection of nodes with three components: a reference to a data object, a reference to a left subtree, and a reference to a right subtree A binary search tree is a tree in which the data stored in the left subtree of every node is less than the data stored in the root node, and the data stored in the right subtree is greater than the data stored in the root node The are many applications of binary trees in computing systems Heap A heap is-a binary tree with special shape and order properties: 1. It is a complete binary tree Each level of tree completely filled Except possibly bottom level (nodes in left most positions) 2. It satisfies a heap-order property Max heap : data in each node >= data in its children (default) Min heap : data in each node <= data in its children Is this a Heap?
Background image of page 3

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

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

This note was uploaded on 01/22/2012 for the course EE 422c taught by Professor Krasner during the Spring '11 term at University of Texas.

Page1 / 55

30 -39 - Announcements Lecture 30 Assignment 5 individual...

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

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