Digital Search Trees & Binary Tries

Slides:



Advertisements
Similar presentations
Router/Classifier/Firewall Tables Set of rules—(F,A)  F is a filter Source and destination addresses. Port number and protocol. Time of day.  A is an.
Advertisements

Binary Tries (continued) split(k). Similar to split algorithm for unbalanced binary search trees. Construct S and B on way down the trie. Follow with a.
TREES Chapter 6. Trees - Introduction  All previous data organizations we've studied are linear—each element can have only one predecessor and successor.
Binary Search Trees Definition Of Binary Search Tree A binary tree. Each node has a (key, value) pair. For every node x, all keys in the left subtree.
Binary Trees, Binary Search Trees CMPS 2133 Spring 2008.
Binary Trees, Binary Search Trees COMP171 Fall 2006.
1 Suffix Trees and Suffix Arrays Modern Information Retrieval by R. Baeza-Yates and B. Ribeiro-Neto Addison-Wesley, (Chapter 8)
Digital Search Trees & Binary Tries Analog of radix sort to searching. Keys are binary bit strings.  Fixed length – 0110, 0010, 1010,  Variable.
IP Address Lookup for Internet Routers Using Balanced Binary Search with Prefix Vector Author: Hyesook Lim, Hyeong-gee Kim, Changhoon Publisher: IEEE TRANSACTIONS.
Higher Order Tries Key = Social Security Number.   9 decimal digits. 10-way trie (order 10 trie) Height
Trees, Binary Trees, and Binary Search Trees COMP171.
Binary Search Trees1 Part-F1 Binary Search Trees   
Binary Search Trees Dictionary Operations:  IsEmpty()  Search(key)  Insert(key, value)  Delete(key)
Digital Search Trees & Binary Tries Analog of radix sort to searching. Keys are binary bit strings.  Fixed length – 0110, 0010, 1010,  Variable.
Lec 15 April 9 Topics: l binary Trees l expression trees Binary Search Trees (Chapter 5 of text)
Patricia P ractical A lgorithm T o R etrieve I nformation C oded I n A lphanumeric. Compressed binary trie. All nodes are of the same data type (binary.
Binomial Heaps. Min Binomial Heap Collection of min trees
Data Structures & Algorithms Radix Search Richard Newman based on slides by S. Sahni and book by R. Sedgewick.
Address Lookup in IP Routers. 2 Routing Table Lookup Routing Decision Forwarding Decision Forwarding Decision Routing Table Routing Table Routing Table.
Binary Search Trees CSE, POSTECH. Search Trees Search trees are ideal for implementing dictionaries – Similar or better performance than skip lists and.
Binary Trees Chapter 6.
§6 B+ Trees 【 Definition 】 A B+ tree of order M is a tree with the following structural properties: (1) The root is either a leaf or has between 2 and.
Data Structures Arrays both single and multiple dimensions Stacks Queues Trees Linked Lists.
CHAPTER 71 TREE. Binary Tree A binary tree T is a finite set of one or more nodes such that: (a) T is empty or (b) There is a specially designated node.
Chapter 19: Binary Trees. Objectives In this chapter, you will: – Learn about binary trees – Explore various binary tree traversal algorithms – Organize.
Lecture 10 Trees –Definiton of trees –Uses of trees –Operations on a tree.
Binary Trees, Binary Search Trees RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
B + -Trees Same structure as B-trees. Dictionary pairs are in leaves only. Leaves form a doubly-linked list. Remaining nodes have following structure:
Binary Search Tree 황승원 Fall 2011 CSE, POSTECH 2 2 Search Trees Search trees are ideal for implementing dictionaries – Similar or better performance than.
Trees  Linear access time of linked lists is prohibitive Does there exist any simple data structure for which the running time of most operations (search,
1 Searching Searching in a sorted linked list takes linear time in the worst and average case. Searching in a sorted array takes logarithmic time in the.
2-3 Trees Extended tree.  Tree in which all empty subtrees are replaced by new nodes that are called external nodes.  Original nodes are called internal.
Higher Order Tries Key = Social Security Number.   9 decimal digits. 10-way trie (order 10 trie) Height
Segment Trees Basic data structure in computational geometry. Computational geometry.  Computations with geometric objects.  Points in 1-, 2-, 3-, d-space.
Topics Definition and Application of Binary Trees Binary Search Tree Operations.
Chapter 7 Trees_Part3 1 SEARCH TREE. Search Trees 2  Two standard search trees:  Binary Search Trees (non-balanced) All items in left sub-tree are less.
Tree Traversals, TreeSort 20 February Expression Tree Leaves are operands Interior nodes are operators A binary tree to represent (A - B) + C.
Binary Search Trees (BSTs) 18 February Binary Search Tree (BST) An important special kind of binary tree is the BST Each node stores some information.
Binary Tree. Some Terminologies Short review on binary tree Tree traversals Binary Search Tree (BST)‏ Questions.
Generic Trees—Trie, Compressed Trie, Suffix Trie (with Analysi
Heap Chapter 9 Objectives Define and implement heap structures
File Organization and Processing Week 3
Red Black Trees Colored Nodes Definition Binary search tree.
Higher Order Tries Key = Social Security Number.
IP Routers – internal view
Binary search tree. Removing a node
Mark Redekopp David Kempe
Splay Trees Binary search trees.
Chapter 10 Search Trees 10.1 Binary Search Trees Search Trees
Binary Search Tree Chapter 10.
Chapter 10.1 Binary Search Trees
B-Trees Disk Storage What is a multiway tree? What is a B-tree?
Splay Trees Binary search trees.
Patricia Practical Algorithm To Retrieve Information Coded In Alphanumeric. Compressed binary trie. All nodes are of the same data type (binary tries use.
Binary Trees, Binary Search Trees
(edited by Nadia Al-Ghreimil)
COP3530- Data Structures B Trees
Binary Tries (continued)
Search Sorted Array: Binary Search Linked List: Linear Search
Random inserting into a B+ Tree
Digital Search Trees & Binary Tries
B-Trees Disk Storage What is a multiway tree? What is a B-tree?
Higher Order Tries Key = Social Security Number.
B-Trees Disk Storage What is a multiway tree? What is a B-tree?
Binary Trees, Binary Search Trees
Basic Data Structures - Trees
2-3 Trees Extended tree. Tree in which all empty subtrees are replaced by new nodes that are called external nodes. Original nodes are called internal.
Binary Trees, Binary Search Trees
Data Structures Using C++ 2E
Chapter 11 Trees © 2011 Pearson Addison-Wesley. All rights reserved.
Presentation transcript:

Digital Search Trees & Binary Tries Analog of radix sort to searching. Keys are binary bit strings. Fixed length – 0110, 0010, 1010, 1011. Variable length – 01, 00, 101, 1011. Application – IP routing, packet classification, firewalls. IPv4 – 32 bit IP address; |key| <= 32. IPv6 – 128 bit IP address; |key| <= 128. Will discuss IP application in detail later. IPv4 (v6) the keys in the search structure are up to 32 bits (128) long. Application of variable length binary keysHuffman codes/tree.

Digital Search Tree Assume fixed number of bits. Not empty => Root contains one dictionary pair (any pair). All remaining pairs whose key begins with a 0 are in the left subtree. All remaining pairs whose key begins with a 1 are in the right subtree. Left and right subtrees are digital search trees on remaining bits. So, on level I branching is done on bit I of the key.

Example Start with an empty digital search tree and insert a pair whose key is 0110. 0110 Now, insert a pair whose key is 0010. 0110 0010

Example Now, insert a pair whose key is 1001. 0110 0010 1001 0110 0010

Example Now, insert a pair whose key is 1011. 1001 0110 0010 1011 1001

Example Now, insert a pair whose key is 0000. 1001 0110 0010 1011 0000

Search/Insert/Delete 1001 0110 0010 1011 0000 Delete from nonleaf => replace with key in subtree leaf. Note can’t delete as in binary search tree as that would change levels of nodes and mess up relationship between level and branching bit. Complexity of each operation is O(#bits in a key). #key comparisons = O(height). Expensive when keys are very long.

Binary Trie Information Retrieval. At most one key comparison per operation. Fixed length keys. Branch nodes. Left and right child pointers. No data field(s). Element nodes. No child pointers. Data field to hold dictionary pair. Huffman trees have same structure but for variable length keys that satisfy the prefix property (no key is a proper prefix of another)

Example At most one key comparison for a search. 1 1100 0001 0011 1000 1001 1 Every branch node has >=2 keys/pairs in its subtree. At most one key comparison for a search.

Variable Key Length Left and right child fields. Left and right pair fields. Left pair is pair whose key terminates at root of left subtree or the single pair that might otherwise be in the left subtree. Right pair is pair whose key terminates at root of right subtree or the single pair that might otherwise be in the right subtree. Field is null otherwise.

Example At most one key comparison for a search. null 1 00 01100 10 null 1 00 01100 10 11111 0000 001 1000 101 1 Alternative is to store only length k keys at level k. Then, 0000, for example, would be stored one level down from shown figure. Longest prefix matching. 00100 001100 At most one key comparison for a search.

Fixed Length Insert Insert 0111. Zero compares. 1 1 1100 0111 0001 0011 1100 1000 1001 1 0111 1 Insert 0111. Zero compares.

Fixed Length Insert 0001 0011 1100 1000 1001 1 0111 1 Insert 1101.

Fixed Length Insert 1100 0001 0011 1000 1001 1 0111 1 Insert 1101.

Fixed Length Insert Insert 1101. One compare. 0001 0011 1000 1001 1 1 0111 1 1 1100 1101 Insert 1101. One compare.

Fixed Length Delete Delete 0111. 1 0001 0011 1000 1001 0111 1100 1101 1 0001 0011 1000 1001 0111 1100 1101 Sibling is branch node. Delete 0111.

Fixed Length Delete Delete 0111. One compare. 1 0001 0011 1000 1001 1 0001 0011 1000 1001 1100 1101 Delete 0111. One compare.

Fixed Length Delete Delete 1100. 1 0001 0011 1000 1001 1100 1101 1 0001 0011 1000 1001 1100 1101 Sibling is element node. Delete 1100.

Fixed Length Delete 1 1 1 0001 0011 1 1 1000 1001 1101 Delete 1100.

Fixed Length Delete 1101 1 1 1 0001 0011 1 1000 1001 Delete 1100.

Fixed Length Delete 1101 1 1 1 0001 0011 1 1000 1001 Delete 1100.

Fixed Length Delete Delete 1100. One compare. 1 1 1101 1 0001 0011 1 1 1 1101 1 0001 0011 1 1000 1001 Delete 1100. One compare.

Fixed Length Join(S,m,B) Convert 3-way join to 2-way join Insert m into B to get B’. S empty => B’ is answer; done. S is element node => insert S element into B’; done; B’ is element node => insert B’ element into S; done; If you get to this step, the roots of S and B’ are branch nodes.

Fixed Length Join(S,m,B) S has empty right subtree. a S b c B’ c J(S,B’) J(a,b) + = J(X,Y) ajoin X and Y, all keys in X < all in Y.

Fixed Length Join(S,m,B) S has nonempty right subtree. Left subtree of B’ must be empty, because all keys in B’ > all keys in S. a S b c B’ a J(S,B’) J(b,c) + = Complexity = O(height).