EECS 4101/5101 Prof. Andy Mirzaian. Lists Move-to-Front Search Trees Binary Search Trees Multi-Way Search Trees B-trees Splay Trees 2-3-4 Trees Red-Black.

Slides:



Advertisements
Similar presentations
CSE 4101/5101 Prof. Andy Mirzaian Augmenting Data Structures.
Advertisements

CSE 4101/5101 Prof. Andy Mirzaian B-trees trees.
Chapter 12 Binary Search Trees
Comp 122, Spring 2004 Binary Search Trees. btrees - 2 Comp 122, Spring 2004 Binary Trees  Recursive definition 1.An empty tree is a binary tree 2.A node.
AVL Trees1 Part-F2 AVL Trees v z. AVL Trees2 AVL Tree Definition (§ 9.2) AVL trees are balanced. An AVL Tree is a binary search tree such that.
Chapter 4: Trees Part II - AVL Tree
EECS 4101/5101 Prof. Andy Mirzaian. Lists Move-to-Front Search Trees Binary Search Trees Multi-Way Search Trees B-trees Splay Trees Trees Red-Black.
Jan Binary Search Trees What is a search binary tree? Inorder search of a binary search tree Find Min & Max Predecessor and successor BST insertion.
Analysis of Algorithms CS 477/677 Binary Search Trees Instructor: George Bebis (Appendix B5.2, Chapter 12)
ALGORITHMS THIRD YEAR BANHA UNIVERSITY FACULTY OF COMPUTERS AND INFORMATIC Lecture six Dr. Hamdy M. Mousa.
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
Binary Trees, Binary Search Trees CMPS 2133 Spring 2008.
Binary Trees, Binary Search Trees COMP171 Fall 2006.
CS 171: Introduction to Computer Science II
Binary Search Trees CIS 606 Spring Search trees Data structures that support many dynamic-set operations. – Can be used as both a dictionary and.
More sorting algorithms: Heap sort & Radix sort. Heap Data Structure and Heap Sort (Chapter 7.6)
BST Data Structure A BST node contains: A BST contains
Lec 15 April 9 Topics: l binary Trees l expression trees Binary Search Trees (Chapter 5 of text)
Chapter 12 Trees. Copyright © 2005 Pearson Addison-Wesley. All rights reserved Chapter Objectives Define trees as data structures Define the terms.
04 Trees Part I CS 310 photo ©Oregon Scenics used with permissionOregon Scenics All figures labeled with “Figure X.Y” Copyright © 2006 Pearson Addison-Wesley.
C++ Programming: Program Design Including Data Structures, Third Edition Chapter 20: Binary Trees.
More Trees COL 106 Amit Kumar and Shweta Agrawal Most slides courtesy : Douglas Wilhelm Harder, MMath, UWaterloo
Binary Trees Chapter 6.
1 Search Trees - Motivation Assume you would like to store several (key, value) pairs in a data structure that would support the following operations efficiently.
Chapter Tow Search Trees BY HUSSEIN SALIM QASIM WESAM HRBI FADHEEL CS 6310 ADVANCE DATA STRUCTURE AND ALGORITHM DR. ELISE DE DONCKER 1.
Advanced Algorithms Analysis and Design Lecture 8 (Continue Lecture 7…..) Elementry Data Structures By Engr Huma Ayub Vine.
David Luebke 1 9/18/2015 CS 332: Algorithms Red-Black Trees.
12-CRS-0106 REVISED 8 FEB 2013 CSG2A3 ALGORITMA dan STRUKTUR DATA.
Chapter 12. Binary Search Trees. Search Trees Data structures that support many dynamic-set operations. Can be used both as a dictionary and as a priority.
1 Trees A tree is a data structure used to represent different kinds of data and help solve a number of algorithmic problems Game trees (i.e., chess ),
Binary Trees, Binary Search Trees RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
Sorting Fun1 Chapter 4: Sorting     29  9.
2IL50 Data Structures Fall 2015 Lecture 7: Binary Search Trees.
Binary SearchTrees [CLRS] – Chap 12. What is a binary tree ? A binary tree is a linked data structure in which each node is an object that contains following.
Preview  Graph  Tree Binary Tree Binary Search Tree Binary Search Tree Property Binary Search Tree functions  In-order walk  Pre-order walk  Post-order.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 9.
Lecture 9 Algorithm Analysis Arne Kutzner Hanyang University / Seoul Korea.
+ David Kauchak cs312 Review. + Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem,
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
Binary Tree. Some Terminologies Short review on binary tree Tree traversals Binary Search Tree (BST)‏ Questions.
1/14/20161 BST Operations Data Structures Ananda Gunawardena.
Red-Black Trees. Review: Binary Search Trees ● Binary Search Trees (BSTs) are an important data structure for dynamic sets ● In addition to satellite.
Binary Search Trees (BST)
Rooted Tree a b d ef i j g h c k root parent node (self) child descendent leaf (no children) e, i, k, g, h are leaves internal node (not a leaf) sibling.
1 Joe Meehean. A A B B D D I I C C E E X X A A B B D D I I C C E E X X  Terminology each circle is a node pointers are edges topmost node is the root.
CSE 2331/5331 Topic 8: Binary Search Tree Data structure Operations.
BINARY TREES Objectives Define trees as data structures Define the terms associated with trees Discuss tree traversal algorithms Discuss a binary.
Trees CSIT 402 Data Structures II 1. 2 Why Do We Need Trees? Lists, Stacks, and Queues are linear relationships Information often contains hierarchical.
CS6045: Advanced Algorithms Data Structures. Dynamic Sets Next few lectures will focus on data structures rather than straight algorithms In particular,
Chapter 11 Sorting Acknowledgement: These slides are adapted from slides provided with Data Structures and Algorithms in C++, Goodrich, Tamassia and Mount.
CSE 373 Data Structures Lecture 7
Binary Search Trees What is a binary search tree?
Trees Chapter 15.
Data Structures Review Session 2
CSE 373 Data Structures Lecture 7
Lecture 7 Algorithm Analysis
Binary Trees, Binary Search Trees
Chapter 22 : Binary Trees, AVL Trees, and Priority Queues
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Lecture 7 Algorithm Analysis
Chapter 12: Binary Search Trees
CS6045: Advanced Algorithms
Lecture 7 Algorithm Analysis
Binary Trees, Binary Search Trees
Trees.
Topic 6: Binary Search Tree Data structure Operations
Binary SearchTrees [CLRS] – Chap 12.
Binary Search Trees Comp 122, Spring 2004.
Chapter 12&13: Binary Search Trees (BSTs)
Binary Trees, Binary Search Trees
Presentation transcript:

EECS 4101/5101 Prof. Andy Mirzaian

Lists Move-to-Front Search Trees Binary Search Trees Multi-Way Search Trees B-trees Splay Trees Trees Red-Black Trees SELF ADJUSTING WORST-CASE EFFICIENT competitive competitive? Linear Lists Multi-Lists Hash Tables DICTIONARIES 2

TOPICS  Binary Trees  Binary Search Trees  Multi-way Search Trees 3

References: [CLRS] chapter 12 [CLRS] chapter 12 4

Binary Trees 5

Binary Trees: A Quick Review d d b b e e a a c c g g f f root[T] n (internal) nodes n-1 (internal) edges n+1 external nodes (nil) n+1 external edges (nil) Node x structure: key[x] p[x] parent left[x] left child right[x] right child external nodes (nil) 6

Binary Tree Traversals  Inorder(T): Inorder(L); r; Inorder(R).abcdefg  Preorder(T): r ; Preorder(L); Preorder(R).dbacegf  Postorder(T): Postorder(L); Postorder(R); r. acbfged  Levelorder(T): non-decreasing depth order dbeacgf (same depth left-to-right) r r LR T: graph BFS d d b b e e a a c c g g f f root[T] graph DFS 7

Traversals in O(n) time procedure Inorder(x) 1. if x = nil then return 2. Inorder(left[x]) 3. visit(x) 4. Inorder(right[x]) end procedure Inorder(x) 1. if x = nil then return 2. Inorder(left[x]) 3. visit(x) 4. Inorder(right[x]) end r r LR Running Time Analysis by Accounting: Line 1: n+1 external nodes (return), n (internal) nodes (continue). Line 3: Assume visit takes O(1) time. Lines 2 & 4: After recursive expansion: Each node x (internal or external) visited exactly once. O(1) time execution of lines 1 & 3 charged to node x. Total n + (n+1) nodes, each charged O(1) time. Total time = O(2n+1) = O(n). Running Time Analysis by Accounting: Line 1: n+1 external nodes (return), n (internal) nodes (continue). Line 3: Assume visit takes O(1) time. Lines 2 & 4: After recursive expansion: Each node x (internal or external) visited exactly once. O(1) time execution of lines 1 & 3 charged to node x. Total n + (n+1) nodes, each charged O(1) time. Total time = O(2n+1) = O(n).  Preorder and Postorder are similar and take O(n) time.  Exercise: Write a simple O(n) time algorithm for Levelorder. [Hint: use a queue.] 8

Running Time Analysis by Recurrence CLAIM: Time(T) = 2 |T| + 1. Proof: By induction on |T|. Basis (|T|=0): Time(T) = 1 = 2 |T| + 1. Induction Step (|T| > 0): Time(T) = Time(L) + Time(R) + 1 [by the recurrence] = (2|L|+1) + (2|R|+1) + 1 [by the Induction Hypothesis] = 2(|L| + |R| + 1) + 1 = 2 |T| + 1. CLAIM: Time(T) = 2 |T| + 1. Proof: By induction on |T|. Basis (|T|=0): Time(T) = 1 = 2 |T| + 1. Induction Step (|T| > 0): Time(T) = Time(L) + Time(R) + 1 [by the recurrence] = (2|L|+1) + (2|R|+1) + 1 [by the Induction Hypothesis] = 2(|L| + |R| + 1) + 1 = 2 |T| + 1. r r LR T: 9

Binary Search Trees 10

BST from Binary Search on Sorted Array E0 < K1 < E1 < K2 < E2 < K3 < E3 < K4 < E4 < K5 < E5 < K6 < E6 <  < Kn < En K1 E0 K2 E1 K3 E2 K4 E3 K5 E4 K6 E5E6 11

BST from Binary Search on Sorted Array E0 < K1 < E1 < K2 < E2 < K3 < E3 < K4 < E4 < K5 < E5 < K6 < E6 <  < Kn < En K1 E0 K2 E1 K3 E2 K4 E3 K5 E4 K6 E5E6 K1 E0 K2 E1E2 K4 E3 K5 E4 K6 E5E6 K3 12

BST from Binary Search on Sorted Array E0 < K1 < E1 < K2 < E2 < K3 < E3 < K4 < E4 < K5 < E5 < K6 < E6 <  < Kn < En K1 E0 K2 E1 K3 E2 K4 E3 K5 E4 K6 E5E6 K3 E0 K2 E1E2 K4 E3 K5 E4E5 E6 K1 K6 13

BST from Binary Search on Sorted Array E0 < K1 < E1 < K2 < E2 < K3 < E3 < K4 < E4 < K5 < E5 < K6 < E6 <  < Kn < En K1 E0 K2 E1 K3 E2 K4 E3 K5 E4 K6 E5E6 K3 E0 E6 K1 K6 E1 E2 E3 K5 E4E5 K2 K4 14

BST from Binary Search on Sorted Array E0 < K1 < E1 < K2 < E2 < K3 < E3 < K4 < E4 < K5 < E5 < K6 < E6 <  < Kn < En K1 E0 K2 E1 K3 E2 K4 E3 K5 E4 K6 E5E6 K3 E0 E6 K1 K6 E1 E2 E3 K2 K4 E4 E5 K5 SORTED ORDER  BST INORDER 15

BST Definition BST is a binary tree T with one distinct key per node such that:  Inorder node sequence of T encounters keys in sorted order.  Equivalent definition: For all nodes x & y in T:  If x is in the left subtree of y, then key[x] < key[y], and  If x is in the right subtree of y, then key[x] > key[y].  Wrong definition: For all nodes x & y in T:  If x is left child of y, then key[x] key[y] root[T] Not a BST: necessary but not sufficient 16

Path following routines  Search(K,x):access the (possibly external) node with key K in the BST rooted at x.  Insert(K,x):insert key K in the BST rooted at x. (No duplicates.)  Delete(K,x):delete key K from the BST rooted at x. Some auxiliary routines:  Minimum(x): find the minimum key node in the BST rooted at x.  Maximum(x): find the maximum key node in the BST rooted at x.  Predecessor(x,T): find the Inorder predecessor of node x in binary tree T.  Successor(x,T): find the Inorder successor of node x in binary tree T. Search  Dictionary: Insert Delete DeleteMin (or DeleteMax)  Priority Queue: Insert These operations take O(h) time. h = height of the tree.  log n   h < n. These operations take O(h) time. h = height of the tree.  log n   h < n. use parent pointers use parent pointers 17

Search path of 48 Search path of 33 Search path of 33 Examples E0 E2 E3 E7 E8 E10 E12 a f d eb c 32 E4 E5 48 E6 E1 22 g h j m E9 56 i E11 64 k E4’ E4” 18

Search procedure Search(K,x) 1.If x = nil then return nil 2.if K = key[x] then return x 3.if K key[x] then return Search(K, right[x]) end procedure Search(K,x) 1.If x = nil then return nil 2.if K = key[x] then return x 3.if K key[x] then return Search(K, right[x]) end Running Time: We spend O(1) time per node, going down along the search path of K. Total time = O(length of search path of K) = O(h). Running Time: We spend O(1) time per node, going down along the search path of K. Total time = O(length of search path of K) = O(h). LR x K 19

Minimum & Maximum procedure Minimum(x) 1.if x = nil then return nil 2. y  x 3.while left[y]  nil do y  left[y] 4. return y end procedure Minimum(x) 1.if x = nil then return nil 2. y  x 3.while left[y]  nil do y  left[y] 4. return y end Running Time of Minimum (resp., Maximum): We spend O(1) time per node along the leftmost (resp., rightmost) path down from x. Total time = O(h). Running Time of Minimum (resp., Maximum): We spend O(1) time per node along the leftmost (resp., rightmost) path down from x. Total time = O(h). x min Maximum is left-right symmetric. Follow rightmost path down from x. 20

Successor & Predecessor procedure Successor(x, T) 1. if right[x]  nil then return Minimum(right[x]) 2. y  x 3. while p[y]  nil and y = right[p[y]] do y  p[y] 4. return p[y] end procedure Successor(x, T) 1. if right[x]  nil then return Minimum(right[x]) 2. y  x 3. while p[y]  nil and y = right[p[y]] do y  p[y] 4. return p[y] end Predecessor is symmetric. Running Time: O(h). case 1: right[x]  nil. s is min of right subtree of x. x s x s case 2: right[x] = nil. x is max of left subtree of s. Find s = successor of x. 21

Non-recursive Inorder procedure Inorder(T) 1.x  Minimum(root[T]) 2.while x  nil do 3.visit (x) 4. x  Successor(x, T) 5. end-while end procedure Inorder(T) 1.x  Minimum(root[T]) 2.while x  nil do 3.visit (x) 4. x  Successor(x, T) 5. end-while end Running Time: Minimum & Successor are called O(n) times, each time taking O(h) time. Is the total O(nh) time? It’s actually O(n) time total: each of O(n) edges of the tree are traversed twice (once down, once up). Why? Also can do amortized analysis using stack with multipop analogy. See Exercise 8:  This linear-time non-recursive Inorder procedure uses parent pointers.  If parent pointers are not available, one could maintain a stack of the ancestral nodes of x. Fill in the details.  Write a linear-time non-recursive in-place Inorder procedure without parent pointers. (In-place means you cannot use any stack or equivalent; use just the given tree and O(1) additional scalar variables.) See Exercise 8:  This linear-time non-recursive Inorder procedure uses parent pointers.  If parent pointers are not available, one could maintain a stack of the ancestral nodes of x. Fill in the details.  Write a linear-time non-recursive in-place Inorder procedure without parent pointers. (In-place means you cannot use any stack or equivalent; use just the given tree and O(1) additional scalar variables.)

Insert procedure Insert(K,T) 1.AuxInsert(K, T, root[T], nil) end Running Time: O(length of search path of K) = O(h). procedure AuxInsert(K,T,x,y) (* y = parent of x *) 1a.if x = nil then do 1b. z  a new node 1c. key[z]  K; left[z]  right[z]  nil; p[z]  y 1d. if y = nil then root[T]  z 1e. else if K < key[y] 1f. then left[y]  z 1g. else right[y]  z 1h. return 1i. end-if 2.if K key[x] then AuxInsert(K, T, right[x], x) end procedure AuxInsert(K,T,x,y) (* y = parent of x *) 1a.if x = nil then do 1b. z  a new node 1c. key[z]  K; left[z]  right[z]  nil; p[z]  y 1d. if y = nil then root[T]  z 1e. else if K < key[y] 1f. then left[y]  z 1g. else right[y]  z 1h. return 1i. end-if 2.if K key[x] then AuxInsert(K, T, right[x], x) end root[T] y x y z K K 23

Delete Running Time: O(length of search path of z) = O(h). procedure Delete(K,T) 1. x  Search(K,T) 2. if x = nil then return 3. if left[x]=nil or right[x]=nil 4.then z  x 5. else z  Successor(x,T) 6. key[x]  key[z] 7. SpliceOut(z) end procedure Delete(K,T) 1. x  Search(K,T) 2. if x = nil then return 3. if left[x]=nil or right[x]=nil 4.then z  x 5. else z  Successor(x,T) 6. key[x]  key[z] 7. SpliceOut(z) end K K root[T] x SpliceOut(x) K K root[T] x SpliceOut(x) K K root[T] x K’ z SpliceOut(z) procedure SpliceOut(z) O(1) time (* Exercise *) remove node z and bypass link between p[z] and lone child of z (maybe nil too) end procedure SpliceOut(z) O(1) time (* Exercise *) remove node z and bypass link between p[z] and lone child of z (maybe nil too) end 24

BST Height h Search Minimum Predecessor Insert Maximum Successor Delete Search Minimum Predecessor Insert Maximum Successor Delete  All these path following routines take at most O(h) time.   log n   h < n.  h could be as bad as  (n) if the tree is extremely unbalanced.  To improve, we will study search trees that are efficient in the  worst-case sense: Red-Black trees, B-trees, trees.  amortized sense: Splay trees.  All these path following routines take at most O(h) time.   log n   h < n.  h could be as bad as  (n) if the tree is extremely unbalanced.  To improve, we will study search trees that are efficient in the  worst-case sense: Red-Black trees, B-trees, trees.  amortized sense: Splay trees. these are multi-way search trees 25

Multi-way Search Trees 26

Split: Multi-Way vs Binary  Sorted key sequence Inorder key sequence T T binary split: K K LR K K LR (  key in L) < K < (  key in R) 2-node ternary split: K1K1 K1K1 LR K2K2 K2K2 M (  key in L) < K 1 < (  key in M) < K 2 < (  key in R) K 1 K 2 LR M 3-node 27

Multi-Way Search Tree 1.Root is a d-node for some d  2. 2.K 1 < K 2 < … < K i < … < K d-1. 3.(every key in T i ) < K i < (every key in T i+1 ), for i = 1..d-1. (3 implies 2.) 4.Each subtree T i, i=1..d, is a multi-way search tree. 5.The empty tree is also a multi-way search tree. 1.Root is a d-node for some d  2. 2.K 1 < K 2 < … < K i < … < K d-1. 3.(every key in T i ) < K i < (every key in T i+1 ), for i = 1..d-1. (3 implies 2.) 4.Each subtree T i, i=1..d, is a multi-way search tree. 5.The empty tree is also a multi-way search tree. T1T1 T2T2 TiTi T i+1 TdTd K 1 K 2 … K i … K d-1 … … root x (a d-node) K i = Key i [x] c i = c i [x] c1c1 c2c2 cici c i+1 cdcd 28

Example V W B C D A A I L M O G U Q R S E F T T J K X Y Z P P N N H H n = # keys # internal nodes  [1..n] # external nodes = n+1 29

Exercises 30

1.[CLRS, Exercise , page 293] Suppose that we have numbers between 1 and 1000 in a binary search tree and want to search for the number 363. Which of the following sequences could not be the sequence of nodes examined? Explain. (a) 2, 252, 401, 398, 330, 344, 397, 363. (b) 924, 220, 911, 244, 898, 258, 362, 363. (c) 925, 202, 911, 240, 912, 245, 363. (d) 2, 399, 387, 219, 266, 382, 381, 278, 363. (e) 935, 278, 347, 621, 299, 392, 358, [CLRS, Exercise , page 293] Suppose the search path for a key K on a BST ends up in an external node. Let A be the set of keys to the left of the search path; B be the set of keys on the search path; and C be the set of keys to the right of the search path. Give a smallest counter-example to refute the claim that  a  A,  b  B,  c  C, we must have a  b  c. 3.[CLRS, Exercise , page 299] Is the Delete operation on BST “commutative” in the sense that deleting x and then y from the BST leaves the same tree as deleting y and then x? Argue why it is or give a counter-example. 4.[CLRS, Exercise , page 294] Give a proof by the potential function method for the following fact: No matter what node x we start at in an arbitrary height h BST T, R successive calls to Successor, as shown below for i  1..R do x  Successor(x,T) takes at most O(h+R) time. [Note: O(h  R) is obvious.] Carefully define the potential function. 5.Range-Search Reporting in BST: Let T be a given BST. We are also given a pair of key values a and b, a < b (not necessarily in T). We want to report every item x in T such that a  key[x]  b. Design an algorithm that solves the problem and takes O(h+R) time in the worst case, where h is the height of T and R is the number of reported items (i.e., the output size). Prove the correctness of your algorithm and the claimed time complexity. [Hint: there is a short and elegant recursive solution.] 31

6.Binary Tree Reconstruction: Which of the following pairs of traversal sequences uniquely determine the Binary Tree structure? Fully justify each case. (a) Preorder and Postorder. (b) Preorder and Inorder. (c) Levelorder and Inorder. 7.[CLRS, Problem 12-2, page 304] Radix Trees: Given two strings a = a 0 a 1 … a p and b = b 0 b 1 … b q, where each a i and each b j is in some ordered set of characters, we say that string a is lexicographically less than string b if either (i)  an integer j, where 0  j  min{p,q}, such that a i = b i  i=0,1,…,j-1, and a j < b j, or (ii) p < q and a i = b i for all i=0,1,…,p. For example, if a and b are bit strings, then < by rule (i) (j=3) and < by rule (ii). This is similar to the ordering used in English-language dictionaries. The radix tree data structure shown below stores the bit strings 1011, 10, 011, 100, and 0. When searching for a key a = a 0 a 1 … a p, we go left at a node of depth i if a i = 0 and right if a i = 1. Note that the tree uses some extra “empty” nodes (the dark ones). Let S be a set of distinct binary strings given in some arbitrary unsorted order, whose string lengths sum to n. (a) Show an O(n) time algorithm to construct a radix tree with O(n) nodes that stores the strings in S. (b) Show how to use the radix tree just constructed to sort S lexicographically in O(n) time. In the figure below, the output of the sort should be the sequence 0, 011,10,100,

8.Iterative Inorder: We gave a linear-time non-recursive Inorder procedure using parent pointers. (a) If parent pointers are not available, one could maintain a stack holding the ancestors of the current node. Write such a procedure and analyze its running time. (b) Write a linear-time non-recursive in-place Inorder procedure without parent pointers. (In-place means you cannot use any stack or equivalent; just the given tree and O(1) additional scalar variables.) [Hint: temporarily modify the tree links then put them back into their original form.] 9.BST construction lower bound: We are given a set S of n keys and want to algorithmically construct a BST that stores these keys. (a) Show that if the keys in S are given in sorted order, then there is an O(n) time solution. (b) Show that if the keys in S are given in arbitrary order, then any off-line algorithm that solves the problem must, in the worst-case, take at least  (n log n) time in the decision tree model of computation. [Note: there are algorithms that do not sort S as a first step!] 10.Split and Join on BST: These are cut and paste operations on dictionaries. The Split operation takes as input a dictionary (a set of keys) A and a key value K (not necessarily in A), and splits A into two disjoint dictionaries B = { x  A | key[x]  K } and C = { x  A | key[x] > K }. (Dictionary A is destroyed as a result of this operation.) The Join operation is essentially the reverse; it takes two input dictionaries A and B such that every key in A < every key in B, and replaces them with their union dictionary C = A  B. (A and B are destroyed as a result of this operation.) Design and analyze efficient Split and Join on binary search trees. [Note: there is a naïve slow solution for Split (similarly for Join) that deletes items from A one at a time and inserts them in B or C as appropriate. Can you do it more efficiently?] 11.Multi-way Search Tree Traversals: Given a multi-way search tree with n keys, give O(n) time algorithms to print its keys in Preorder, Postorder, Inorder, Levelorder. 12.Multi-way Search Tree Search: Given a multi-way search tree T and a key K, describe how to search for K in T. How does the worst-case running time of your algorithm depend on n (the number of keys in T), h (the height of T), and d (the largest size of any node; a d-node) in T? 33

END 34