Announcements. Lilian s office hours rescheduled: Fri 2-4pm HW2 out tomorrow, due Thursday, 7/7. CSE373: Data Structures & Algorithms
|
|
- Coleen Boyd
- 5 years ago
- Views:
Transcription
1 Announcements Lilian s office ours resceduled: Fri 2-4pm HW2 out tomorrow, due Tursday, 7/7 CSE373: Data Structures & Algoritms
2 Deletion in BST Wy migt deletion be arder tan insertion? CSE373: Data Structures & Algoritms
3 Deletion Removing an item disrupts te tree structure Basic idea: find te node to be removed, ten fix te tree so tat it is still a binary searc tree Tree cases: Node as no cildren (leaf) Node as one cild Node as two cildren CSE373: Data Structures & Algoritms
4 Deletion Te Leaf Case delete(7) CSE373: Data Structures & Algoritms
5 Deletion Te One Cild Case delete(5) CSE373: Data Structures & Algoritms
6 Deletion Te Two Cild Case delete(5) Wat can we replace 5 wit? CSE373: Data Structures & Algoritms
7 Deletion Te Two Cild Case Idea: Replace te deleted node wit a value guaranteed to be between te two cild subtrees Options: successor from rigt subtree: findmin(node.rigt) predecessor from left subtree: findmax(node.left) Tese are te easy cases of predecessor/successor Now delete te original node containing successor or predecessor Leaf or one cild case easy cases of delete! CSE373: Data Structures & Algoritms
8 Lazy Deletion Lazy deletion can work well for a BST Simpler Can do real deletions later as a batc Some inserts can just undelete a tree node But Can waste space and slow down find operations Make some operations more complicated: How would you cange findmin and findmax? CSE373: Data Structures & Algoritms
9 BuildTree for BST Let s consider buildtree Insert all, starting from an empty tree Insert keys, 2, 3, 4, 5, 6, 7, 8, 9 into an empty BST If inserted in given order, wat is te tree? Wat big-o runtime for tis kind of sorted input? Is inserting in te reverse order any better? O(n 2 ) Can we do better? 2 3 CSE373: Data Structures & Algoritms
10 BuildTree for BST Insert keys, 2, 3, 4, 5, 6, 7, 8, 9 into an empty BST Wat we if could someow re-arrange tem median first, ten left median, rigt median, etc. 5, 3, 7, 2,, 4, 8, 6, 9 5 Wat tree does tat give us? 3 7 Wat big-o runtime? O(n log n), awesome! 9 CSE373: Data Structures & Algoritms
11 Unbalanced BST Balancing a tree at build time is insufficient, as sequences of operations can eventually transform tat carefully balanced tree into te dreaded list At tat point, everyting is O(n) and nobody is appy find insert delete 2 3 CSE373: Data Structures & Algoritms
12 Balanced BST Observation BST: te sallower te better! For a BST wit n nodes inserted in arbitrary order Average eigt is O(log n) see text for proof Worst case eigt is O(n) Simple cases, suc as inserting in key order, lead to te worst-case scenario Solution: Require a Balance Condition tat. Ensures dept is always O(log n) strong enoug! 2. Is efficient to maintain not too strong! CSE373: Data Structures & Algoritms
13 Potential Balance Conditions. Left and rigt subtrees of te root ave equal number of nodes Too weak! Heigt mismatc example: 2. Left and rigt subtrees of te root ave equal eigt Too weak! Double cain example: CSE373: Data Structures & Algoritms
14 Potential Balance Conditions 3. Left and rigt subtrees of every node ave equal number of nodes Too strong! Only perfect trees (2 n nodes) 4. Left and rigt subtrees of every node ave equal eigt Too strong! Only perfect trees (2 n nodes) CSE373: Data Structures & Algoritms
15 Te AVL Balance Condition Left and rigt subtrees of every node ave eigts differing by at most Definition: balance(node) = eigt(node.left) eigt(node.rigt) AVL property: for every node x, balance(x) Ensures small dept Will prove tis by sowing tat an AVL tree of eigt must ave a number of nodes exponential in Efficient to maintain Using single and double rotations CSE373: Data Structures & Algoritms
16 CSE373: Data Structures & Algoritms Lecture 5: AVL Trees Hunter Zan Tanks to Kevin Quinn CSE373: and Data Structures Dan Grossman & Algoritms for slide materials
17 Te AVL Tree Data Structure Structural properties. Binary tree property 2. Balance property: balance of every node is between - and 8 Result: 5 Worst-case dept is O(log n) Ordering property Same as for BST Definition: balance(node) = eigt(node.left) eigt(node.rigt) 5 CSE373: Data Structures & Algoritms
18 An AVL tree? 6 Heigt = 3 Balance = - 4 Heigt = Balance = 8 Heigt = 2 Balance = - Heigt = 0 Balance = 0 7 Heigt = 0 Balance = Heigt = Balance = 0 Heigt = 0 Balance = 0 Heigt = 0 Balance = 0 CSE373: Data Structures & Algoritms
19 An AVL tree? Heigt = 2 Balance = -2 Heigt = 3 Balance = Heigt = Balance = 6 Heigt = 0 Balance = 0 Heigt = 4 Balance = 2 7 Heigt = 0 Balance = 0 8 Heigt = Balance = 0 Heigt = 0 Balance = 0 2 Heigt = 0 Balance = 0 No! CSE373: Data Structures & Algoritms
20 Te sallowness bound Let S() = te minimum number of nodes in an AVL tree of eigt If we can prove tat S() grows exponentially in, ten a tree wit n nodes as a logaritmic eigt Step : Define S() inductively using AVL property S(-)=0, S(0)=, S()=2 For, S() = +S(-)+S(-2) Step 2: Bound S() Using everybody s favorite: Induction! -2 - CSE373: Data Structures & Algoritms
21 Fibonacci Numbers Sequence of numbers were eac number is te sum of te preceding two numbers: 0,,, 2, 3, 5, 8, F(0) = 0 F() = F(n+) = F(n-) + F(n) Grows exponentially CSE373: Data Structures & Algoritms
22 S() and F() S() F() S() F(+3) S() appears to be equal to F(+3) - CSE373: Data Structures & Algoritms
23 Te proof Remember: ) S(-)=0, S(0)=, S()=2 2) For, S() = +S(-)+S(-2) F( + ) = F( - ) + F() Let P() be S() == F(+3)-. We will prove tis for all >= 0 Base cases: S(0) = F(0 + 3) = 2 = S() = 2 F( + 3) = 3 = 2 Inductive Hypotesis: Assume P(k) for an arbitrary k >. P(k): S(k) == F(k+3)- Inductive Step: S(k+) = S(k-) + S(k) + = [F((k-) + 3) ] + [F(k+3) ] + I.H. = F((k-) + 3) + F(k + 3) simplify = F((k+) + 3) def of F P(k)! P(k+) Conclusion: We ave proven by induction tat P() olds for all >= 0. Te minimum number of nodes in an AVL tree grows exponentially wit respect to te eigt! Terefore, te eigt grows logaritmically w.r.t. te number of nodes in an AVL tree! O(log n )!! CSE373: Data Structures & Algoritms
24 Good news Proof means tat if we ave an AVL tree, ten find is O(log n) Recall logaritms of different bases > differ by only a constant factor But as we insert and delete elements, we need to:. Track balance 2. Detect imbalance 3. Restore balance Is tis AVL tree balanced? How about after insert(30)? CSE373: Data Structures & Algoritms
25 An AVL Tree 0 key 3 value 0 3 eigt cildren Track eigt at all times! CSE373: Data Structures & Algoritms
26 AVL find: Same as BST find AVL tree operations AVL insert: First BST insert, ten ceck balance and potentially fix te AVL tree Four different imbalance cases AVL delete: Te easy way is lazy deletion Oterwise, do te deletion and ten ave several imbalance cases (we will likely skip tis but post slides for tose interested) CSE373: Data Structures & Algoritms
27 Insert: detect potential imbalance. Insert te new node as in a BST (a new leaf) 2. For eac node on te pat from te root to te new leaf, te insertion may (or may not) ave canged te node s eigt 3. So after recursive insertion in a subtree, detect eigt imbalance and perform a rotation to restore balance at tat node Type of rotation will depend on te location of te imbalance (if any) Facts tat an implementation can ignore: Tere must be a deepest element tat is imbalanced after te insert (all descendants still balanced) After rebalancing tis deepest node, every node is balanced So at most one node needs to be rebalanced CSE373: Data Structures & Algoritms
28 Case #: Example Insert(6) Insert(3) Insert() Tird insertion violates balance property appens to be at te root Wat is te only way to fix tis? CSE373: Data Structures & Algoritms
29 Fix: Apply Single Rotation Single rotation: Te basic operation we ll use to rebalance Move cild of unbalanced node into parent position Parent becomes te oter cild (always okay in a BST!) Oter subtrees move in only way BST allows (next slide) AVL Property violated ere Intuition: 3 must become root New parent eigt is now te old parent s eigt before insert 0 CSE373: Data Structures & Algoritms
30 Te example generalized Node imbalanced due to insertion somewere in left-left grandcild tat causes an increasing eigt of 4 possible imbalance causes (oter tree coming) First we did te insertion, wic would make a imbalanced + b a +2 a +2 b + Z +3 Z X Y X Y CSE373: Data Structures & Algoritms
31 Te general left-left case Node imbalanced due to insertion somewere in left-left grandcild of 4 possible imbalance causes (oter tree coming) So we rotate at a,using BST facts: X < b < Y < a < Z a +2 b + X Y +3 b + Z X Y +2 + a Z A single rotation restores balance at te node To same eigt as before insertion, so ancestors now balanced CSE373: Data Structures & Algoritms
32 Anoter example: insert(6) CSE373: Data Structures & Algoritms
33 Anoter example: insert(6) CSE373: Data Structures & Algoritms
34 Te general rigt-rigt case Mirror image to left-left case, so you rotate te oter way Exact same concept, but need different code X a b + + a b +2 + Z Y Z X Y CSE373: Data Structures & Algoritms
35 Two cases to go Unfortunately, single rotations are not enoug for insertions in te left-rigt subtree or te rigt-left subtree Simple example: insert(), insert(6), insert(3) First wrong idea: single rotation like we did for left-left CSE373: Data Structures & Algoritms
36 Two cases to go Unfortunately, single rotations are not enoug for insertions in te left-rigt subtree or te rigt-left subtree Simple example: insert(), insert(6), insert(3) Second wrong idea: single rotation on te cild of te unbalanced node CSE373: Data Structures & Algoritms
37 Sometimes two wrongs make a rigt First idea violated te BST property Second idea didn t fix balance But if we do bot single rotations, starting wit te second, it works! (And not just for tis example.) Double rotation:. Rotate problematic cild and grandcild 2. Ten rotate between self and new cild Intuition: 3 must become root CSE373: Data Structures & Algoritms
38 Te general rigt-left case X +3 a X U +3 a U + c V +2 c b - V +2 b - Z + X + a Rotation : b.left = c.rigt c.rigt = b a.rigt = c Rotation 2: U a.rigt = c.left c.left = a root = c c +2 - V b + Z Z CSE373: Data Structures & Algoritms
39 Comments Like in te left-left and rigt-rigt cases, te eigt of te subtree after rebalancing is te same as before te insert So no ancestor in te tree will need rebalancing Does not ave to be implemented as two rotations; can just do: X +3 a U + c V b - +2 Z X + a U c +2 b - V + Z Easier to remember tan you may tink: ) Move c to grandparent s position 2) Put a, b, X, U, V, and Z in te only legal positions for a BST CSE373: Data Structures & Algoritms
40 Te last case: left-rigt X Mirror image of rigt-left Again, no new concepts, only new code to write +2 b U +3 c a + V - Z X + b U c +2 - V a + Z CSE373: Data Structures & Algoritms
41 Insert, summarized Insert as in a BST Ceck back up pat for imbalance, wic will be of 4 cases: Node s left-left grandcild is too tall (left-left single rotation) Node s left-rigt grandcild is too tall (left-rigt double rotation) Node s rigt-left grandcild is too tall (rigt-left double rotation) Node s rigt-rigt grandcild is too tall (rigt-rigt double rotation) Only one case occurs because tree was balanced before insert After te appropriate single or double rotation, te smallestunbalanced subtree as te same eigt as before te insertion So all ancestors are now balanced CSE373: Data Structures & Algoritms
42 Now efficiency Worst-case complexity of find: O(log n) Tree is balanced Worst-case complexity of insert: O(log n) Tree starts balanced A rotation is O() and tere s an O(log n) pat to root (Same complexity even witout one-rotation-is-enoug fact) Tree ends balanced Worst-case complexity of buildtree: O(n log n) Takes some more rotation action to andle delete CSE373: Data Structures & Algoritms
43 Pros and Cons of AVL Trees Arguments for AVL trees:. All operations logaritmic worst-case because trees are always balanced 2. Heigt balancing adds no more tan a constant factor to te speed of insert and delete Arguments against AVL trees:. Difficult to program & debug [but done once in a library!] 2. More space for eigt field 3. Asymptotically faster but rebalancing takes a little time 4. Most large searces are done in database-like systems on disk and use oter structures (e.g., B-trees, a data structure in te text) 5. If amortized (later, I promise) logaritmic time is enoug, use splay trees (also in text) CSE373: Data Structures & Algoritms
CSE 332: Data Structures & Parallelism Lecture 8: AVL Trees. Ruth Anderson Winter 2019
CSE 2: Data Structures & Parallelism Lecture 8: AVL Trees Rut Anderson Winter 29 Today Dictionaries AVL Trees /25/29 2 Te AVL Balance Condition: Left and rigt subtrees of every node ave eigts differing
More informationWrap up Amortized Analysis; AVL Trees. Riley Porter Winter CSE373: Data Structures & Algorithms
CSE 373: Data Structures & Wrap up Amortized Analysis; AVL Trees Riley Porter Course Logistics Symposium offered by CSE department today HW2 released, Big- O, Heaps (lecture slides ave pseudocode tat will
More informationCE 221 Data Structures and Algorithms
CE Data Structures and Algoritms Capter 4: Trees (AVL Trees) Text: Read Weiss, 4.4 Izmir University of Economics AVL Trees An AVL (Adelson-Velskii and Landis) tree is a binary searc tree wit a balance
More informationCS 234. Module 6. October 16, CS 234 Module 6 ADT Dictionary 1 / 33
CS 234 Module 6 October 16, 2018 CS 234 Module 6 ADT Dictionary 1 / 33 Idea for an ADT Te ADT Dictionary stores pairs (key, element), were keys are distinct and elements can be any data. Notes: Tis is
More informationBinary Search Tree - Best Time. AVL Trees. Binary Search Tree - Worst Time. Balanced and unbalanced BST
AL Trees CSE Data Structures Unit Reading: Section 4.4 Binary Searc Tree - Best Time All BST operations are O(d), were d is tree dept minimum d is d = log for a binary tree N wit N nodes at is te best
More informationAVL Trees Outline and Required Reading: AVL Trees ( 11.2) CSE 2011, Winter 2017 Instructor: N. Vlajic
1 AVL Trees Outline and Required Reading: AVL Trees ( 11.2) CSE 2011, Winter 2017 Instructor: N. Vlajic AVL Trees 2 Binary Searc Trees better tan linear dictionaries; owever, te worst case performance
More informationCS 234. Module 6. October 25, CS 234 Module 6 ADT Dictionary 1 / 22
CS 234 Module 6 October 25, 2016 CS 234 Module 6 ADT Dictionary 1 / 22 Case study Problem: Find a way to store student records for a course, wit unique IDs for eac student, were records can be accessed,
More informationeach node in the tree, the difference in height of its two subtrees is at the most p. AVL tree is a BST that is height-balanced-1-tree.
Data Structures CSC212 1 AVL Trees A binary tree is a eigt-balanced-p-tree if for eac node in te tree, te difference in eigt of its two subtrees is at te most p. AVL tree is a BST tat is eigt-balanced-tree.
More information1 Copyright 2012 by Pearson Education, Inc. All Rights Reserved.
CHAPTER 20 AVL Trees Objectives To know wat an AVL tree is ( 20.1). To understand ow to rebalance a tree using te LL rotation, LR rotation, RR rotation, and RL rotation ( 20.2). To know ow to design te
More informationData Structures and Programming Spring 2014, Midterm Exam.
Data Structures and Programming Spring 2014, Midterm Exam. 1. (10 pts) Order te following functions 2.2 n, log(n 10 ), 2 2012, 25n log(n), 1.1 n, 2n 5.5, 4 log(n), 2 10, n 1.02, 5n 5, 76n, 8n 5 + 5n 2
More informationCSE373: Data Structures & Algorithms Lecture 4: Dictionaries; Binary Search Trees. Kevin Quinn Fall 2015
CSE373: Data Structures & Algorithms Lecture 4: Dictionaries; Binary Search Trees Kevin Quinn Fall 2015 Where we are Studying the absolutely essential ADTs of computer science and classic data structures
More informationWhen a BST becomes badly unbalanced, the search behavior can degenerate to that of a sorted linked list, O(N).
Balanced Binary Trees Binary searc trees provide O(log N) searc times provided tat te nodes are distributed in a reasonably balanced manner. Unfortunately, tat is not always te case and performing a sequence
More informationLecture 7. Binary Search Trees / AVL Trees
Lecture 7. Binary Searc Trees / AVL Trees T. H. Cormen, C. E. Leiserson and R. L. Rivest Introduction to Algoritms, 3rd Edition, MIT Press, 2009 Sungkyunkwan University Hyunseung Coo coo@skku.edu Copyrigt
More informationAdvanced Tree. Structures. AVL Tree. Outline. AVL Tree Recall, Binary Search Tree (BST) is a special case of. Splay Tree (Ch 13.2.
ttp://1...0/csd/ Data tructure Capter 1 Advanced Tree tructures Dr. atrick Can cool of Computer cience and Engineering out Cina Universit of Tecnolog AVL Tree Recall, Binar earc Tree (BT) is a special
More informationWhere we are. CSE373: Data Structures & Algorithms Lecture 4: Dictionaries; Binary Search Trees. The Dictionary (a.k.a. Map) ADT
Where we are Studying the absolutely essential DTs of computer science and classic data structures for implementing them SE: Data Structures & lgorithms Lecture : Dictionaries; inary Search Trees Dan rossman
More informationTREES. General Binary Trees The Search Tree ADT Binary Search Trees AVL Trees Threaded trees Splay Trees B-Trees. UNIT -II
UNIT -II TREES General Binary Trees Te Searc Tree DT Binary Searc Trees VL Trees Treaded trees Splay Trees B-Trees. 2MRKS Q& 1. Define Tree tree is a data structure, wic represents ierarcical relationsip
More informationDesign Patterns for Data Structures. Chapter 10. Balanced Trees
Capter 10 Balanced Trees Capter 10 Four eigt-balanced trees: Red-Black binary tree Faster tan AVL for insertion and removal Adelsen-Velskii Landis (AVL) binary tree Faster tan red-black for lookup B-tree
More informationCSE373: Data Structures & Algorithms Lecture 6: Binary Search Trees. Linda Shapiro Spring 2016
CSE373: Data Structures & lgorithms Lecture 6: Binary Search Trees Linda Shapiro Spring 2016 nnouncements HW2 due start of class Wednesday pril 13 on paper. Spring 2016 CSE373: Data Structures & lgorithms
More informationAlgorithms. AVL Tree
Algorithms AVL Tree Balanced binary tree The disadvantage of a binary search tree is that its height can be as large as N-1 This means that the time needed to perform insertion and deletion and many other
More informationCSE 332: Data Structures & Parallelism Lecture 7: Dictionaries; Binary Search Trees. Ruth Anderson Winter 2019
CSE 332: Data Structures & Parallelism Lecture 7: Dictionaries; Binary Search Trees Ruth Anderson Winter 2019 Today Dictionaries Trees 1/23/2019 2 Where we are Studying the absolutely essential ADTs of
More informationDesign Patterns for Data Structures. Chapter 10. Balanced Trees
Capter 10 Balanced Trees Capter 10 Four eigt-balanced trees: Red-Black binary tree Faster tan AVL for insertion and removal Adelsen-Velskii Landis (AVL) binary tree Faster tan red-black for lookup B-tree
More information15-122: Principles of Imperative Computation, Summer 2011 Assignment 6: Trees and Secret Codes
15-122: Principles of Imperative Computation, Summer 2011 Assignment 6: Trees and Secret Codes William Lovas (wlovas@cs) Karl Naden Out: Tuesday, Friday, June 10, 2011 Due: Monday, June 13, 2011 (Written
More informationHaar Transform CS 430 Denbigh Starkey
Haar Transform CS Denbig Starkey. Background. Computing te transform. Restoring te original image from te transform 7. Producing te transform matrix 8 5. Using Haar for lossless compression 6. Using Haar
More informationAVL Trees. CSE260, Computer Science B: Honors Stony Brook University
AVL Trees CSE260, Computer Science B: Honors Stony Brook University ttp://www.cs.stonybrook.edu/~cse260 1 Objectives To know wat an AVL tree is To understand ow to rebalance a tree using te LL rotation,
More informationBounding Tree Cover Number and Positive Semidefinite Zero Forcing Number
Bounding Tree Cover Number and Positive Semidefinite Zero Forcing Number Sofia Burille Mentor: Micael Natanson September 15, 2014 Abstract Given a grap, G, wit a set of vertices, v, and edges, various
More informationSection 2.3: Calculating Limits using the Limit Laws
Section 2.3: Calculating Limits using te Limit Laws In previous sections, we used graps and numerics to approimate te value of a it if it eists. Te problem wit tis owever is tat it does not always give
More informationThe AVL Balance Condition. CSE 326: Data Structures. AVL Trees. The AVL Tree Data Structure. Is this an AVL Tree? Height of an AVL Tree
CSE : Data Structures AL Trees Neva Cernavsy Summer Te AL Balance Condton AL balance property: Left and rgt subtrees of every node ave egts dfferng by at most Ensures small dept ll prove ts by sowng tat
More informationMaterials: Whiteboard, TI-Nspire classroom set, quadratic tangents program, and a computer projector.
Adam Clinc Lesson: Deriving te Derivative Grade Level: 12 t grade, Calculus I class Materials: Witeboard, TI-Nspire classroom set, quadratic tangents program, and a computer projector. Goals/Objectives:
More informationPart 2: Balanced Trees
Part 2: Balanced Trees 1 AVL Trees We could dene a perfectly balanced binary search tree with N nodes to be a complete binary search tree, one in which every level except the last is completely full. A
More informationRecall from Last Time: AVL Trees
CSE 326 Lecture 8: Getting to now AVL Trees Today s Topics: Balanced Search Trees AVL Trees and Rotations Splay trees Covered in Chapter 4 of the text Recall from Last Time: AVL Trees AVL trees are height-balanced
More informationAnnouncements SORTING. Prelim 1. Announcements. A3 Comments 9/26/17. This semester s event is on Saturday, November 4 Apply to be a teacher!
Announcements 2 "Organizing is wat you do efore you do someting, so tat wen you do it, it is not all mixed up." ~ A. A. Milne SORTING Lecture 11 CS2110 Fall 2017 is a program wit a teac anyting, learn
More information4.2 The Derivative. f(x + h) f(x) lim
4.2 Te Derivative Introduction In te previous section, it was sown tat if a function f as a nonvertical tangent line at a point (x, f(x)), ten its slope is given by te it f(x + ) f(x). (*) Tis is potentially
More informationMATH 5a Spring 2018 READING ASSIGNMENTS FOR CHAPTER 2
MATH 5a Spring 2018 READING ASSIGNMENTS FOR CHAPTER 2 Note: Tere will be a very sort online reading quiz (WebWork) on eac reading assignment due one our before class on its due date. Due dates can be found
More informationDeletion The Two Child Case 10 Delete(5) Deletion The Two Child Case. Balanced BST. Finally
Deletion Te Two Cild Cse Delete() Deletion Te Two Cild Cse Ide: Replce te deleted node wit vlue gurnteed to e etween te two cild sutrees! Options: succ from rigt sutree: findmin(t.rigt) pred from left
More informationAVL Trees. (AVL Trees) Data Structures and Programming Spring / 17
AVL Trees (AVL Trees) Data Structures and Programming Spring 2017 1 / 17 Balanced Binary Tree The disadvantage of a binary search tree is that its height can be as large as N-1 This means that the time
More information6 Computing Derivatives the Quick and Easy Way
Jay Daigle Occiental College Mat 4: Calculus Experience 6 Computing Derivatives te Quick an Easy Way In te previous section we talke about wat te erivative is, an we compute several examples, an ten we
More informationCS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya
CS62: Foundations of Algorithm Design and Machine Learning Sourangshu Bhattacharya Binary Search Tree - Best Time All BST operations are O(d), where d is tree depth minimum d is d = ëlog for a binary tree
More information3.6 Directional Derivatives and the Gradient Vector
288 CHAPTER 3. FUNCTIONS OF SEVERAL VARIABLES 3.6 Directional Derivatives and te Gradient Vector 3.6.1 Functions of two Variables Directional Derivatives Let us first quickly review, one more time, te
More informationAlgorithms in Systems Engineering ISE 172. Lecture 16. Dr. Ted Ralphs
Algorithms in Systems Engineering ISE 172 Lecture 16 Dr. Ted Ralphs ISE 172 Lecture 16 1 References for Today s Lecture Required reading Sections 6.5-6.7 References CLRS Chapter 22 R. Sedgewick, Algorithms
More informationCS60020: Foundations of Algorithm Design and Machine Learning. Sourangshu Bhattacharya
CS62: Foundations of Algorithm Design and Machine Learning Sourangshu Bhattacharya Balanced search trees Balanced search tree: A search-tree data structure for which a height of O(lg n) is guaranteed when
More information2.8 The derivative as a function
CHAPTER 2. LIMITS 56 2.8 Te derivative as a function Definition. Te derivative of f(x) istefunction f (x) defined as follows f f(x + ) f(x) (x). 0 Note: tis differs from te definition in section 2.7 in
More informationCOMP171. AVL-Trees (Part 1)
COMP11 AVL-Trees (Part 1) AVL Trees / Slide 2 Data, a set of elements Data structure, a structured set of elements, linear, tree, graph, Linear: a sequence of elements, array, linked lists Tree: nested
More informationComputational Optimization ISE 407. Lecture 16. Dr. Ted Ralphs
Computational Optimization ISE 407 Lecture 16 Dr. Ted Ralphs ISE 407 Lecture 16 1 References for Today s Lecture Required reading Sections 6.5-6.7 References CLRS Chapter 22 R. Sedgewick, Algorithms in
More informationAVL Trees Goodrich, Tamassia, Goldwasser AVL Trees 1
AVL Trees v 6 3 8 z 20 Goodrich, Tamassia, Goldwasser AVL Trees AVL Tree Definition Adelson-Velsky and Landis binary search tree balanced each internal node v the heights of the children of v can 2 3 7
More informationNote that this is a rep invariant! The type system doesn t enforce this but you need it to be true. Should use repok to check in debug version.
Announcements: Prelim tonight! 7:30-9:00 in Thurston 203/205 o Handed back in section tomorrow o If you have a conflict you can take the exam at 5:45 but can t leave early. Please email me so we have a
More information9/29/2016. Chapter 4 Trees. Introduction. Terminology. Terminology. Terminology. Terminology
Introduction Chapter 4 Trees for large input, even linear access time may be prohibitive we need data structures that exhibit average running times closer to O(log N) binary search tree 2 Terminology recursive
More information10/23/2013. AVL Trees. Height of an AVL Tree. Height of an AVL Tree. AVL Trees
// AVL Trees AVL Trees An AVL tree is a binary search tree with a balance condition. AVL is named for its inventors: Adel son-vel skii and Landis AVL tree approximates the ideal tree (completely balanced
More informationTrees. (Trees) Data Structures and Programming Spring / 28
Trees (Trees) Data Structures and Programming Spring 2018 1 / 28 Trees A tree is a collection of nodes, which can be empty (recursive definition) If not empty, a tree consists of a distinguished node r
More informationCh04 Balanced Search Trees
Presentation for use with the textbook Algorithm Design and Applications, by M. T. Goodrich and R. Tamassia, Wiley, 05 Ch0 Balanced Search Trees v 3 8 z Why care about advanced implementations? Same entries,
More informationHash-Based Indexes. Chapter 11. Comp 521 Files and Databases Spring
Has-Based Indexes Capter 11 Comp 521 Files and Databases Spring 2010 1 Introduction As for any index, 3 alternatives for data entries k*: Data record wit key value k
More informationData Structures Lesson 7
Data Structures Lesson 7 BSc in Computer Science University of New York, Tirana Assoc. Prof. Dr. Marenglen Biba 1-1 Binary Search Trees For large amounts of input, the linear access time of linked lists
More informationAdvanced Set Representation Methods
Advanced Set Representation Methods AVL trees. 2-3(-4) Trees. Union-Find Set ADT DSA - lecture 4 - T.U.Cluj-Napoca - M. Joldos 1 Advanced Set Representation. AVL Trees Problem with BSTs: worst case operation
More information4.1 Tangent Lines. y 2 y 1 = y 2 y 1
41 Tangent Lines Introduction Recall tat te slope of a line tells us ow fast te line rises or falls Given distinct points (x 1, y 1 ) and (x 2, y 2 ), te slope of te line troug tese two points is cange
More information2 The Derivative. 2.0 Introduction to Derivatives. Slopes of Tangent Lines: Graphically
2 Te Derivative Te two previous capters ave laid te foundation for te study of calculus. Tey provided a review of some material you will need and started to empasize te various ways we will view and use
More informationNumerical Derivatives
Lab 15 Numerical Derivatives Lab Objective: Understand and implement finite difference approximations of te derivative in single and multiple dimensions. Evaluate te accuracy of tese approximations. Ten
More informationDynamic Access Binary Search Trees
Dynamic Access Binary Search Trees 1 * are self-adjusting binary search trees in which the shape of the tree is changed based upon the accesses performed upon the elements. When an element of a splay tree
More informationDynamic Access Binary Search Trees
Dynamic Access Binary Search Trees 1 * are self-adjusting binary search trees in which the shape of the tree is changed based upon the accesses performed upon the elements. When an element of a splay tree
More informationAVL Tree Definition. An example of an AVL tree where the heights are shown next to the nodes. Adelson-Velsky and Landis
Presentation for use with the textbook Data Structures and Algorithms in Java, 6 th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 0 AVL Trees v 6 3 8 z 0 Goodrich, Tamassia, Goldwasser
More informationCSCI 136 Data Structures & Advanced Programming. Lecture 25 Fall 2018 Instructor: B 2
CSCI 136 Data Structures & Advanced Programming Lecture 25 Fall 2018 Instructor: B 2 Last Time Binary search trees (Ch 14) The locate method Further Implementation 2 Today s Outline Binary search trees
More informationHash-Based Indexes. Chapter 11. Comp 521 Files and Databases Fall
Has-Based Indexes Capter 11 Comp 521 Files and Databases Fall 2012 1 Introduction Hasing maps a searc key directly to te pid of te containing page/page-overflow cain Doesn t require intermediate page fetces
More informationMulti-Stack Boundary Labeling Problems
Multi-Stack Boundary Labeling Problems Micael A. Bekos 1, Micael Kaufmann 2, Katerina Potika 1 Antonios Symvonis 1 1 National Tecnical University of Atens, Scool of Applied Matematical & Pysical Sciences,
More informationCS350: Data Structures AVL Trees
S35: Data Structures VL Trees James Moscola Department of Engineering & omputer Science York ollege of Pennsylvania S35: Data Structures James Moscola Balanced Search Trees Binary search trees are not
More informationSearch Trees - 1 Venkatanatha Sarma Y
Search Trees - 1 Lecture delivered by: Venkatanatha Sarma Y Assistant Professor MSRSAS-Bangalore 11 Objectives To introduce, discuss and analyse the different ways to realise balanced Binary Search Trees
More informationAVL Trees / Slide 2. AVL Trees / Slide 4. Let N h be the minimum number of nodes in an AVL tree of height h. AVL Trees / Slide 6
COMP11 Spring 008 AVL Trees / Slide Balanced Binary Search Tree AVL-Trees Worst case height of binary search tree: N-1 Insertion, deletion can be O(N) in the worst case We want a binary search tree with
More informationMore on Functions and Their Graphs
More on Functions and Teir Graps Difference Quotient ( + ) ( ) f a f a is known as te difference quotient and is used exclusively wit functions. Te objective to keep in mind is to factor te appearing in
More informationSelf-Balancing Search Trees. Chapter 11
Self-Balancing Search Trees Chapter 11 Chapter Objectives To understand the impact that balance has on the performance of binary search trees To learn about the AVL tree for storing and maintaining a binary
More informationCSCI2100B Data Structures Trees
CSCI2100B Data Structures Trees Irwin King king@cse.cuhk.edu.hk http://www.cse.cuhk.edu.hk/~king Department of Computer Science & Engineering The Chinese University of Hong Kong Introduction General Tree
More informationCS350: Data Structures Red-Black Trees
Red-Black Trees James Moscola Department of Engineering & Computer Science York College of Pennsylvania James Moscola Red-Black Tree An alternative to AVL trees Insertion can be done in a bottom-up or
More informationSORTING 9/26/18. Prelim 1. Prelim 1. Why Sorting? InsertionSort. Some Sorting Algorithms. Tonight!!!! Two Sessions:
Prelim 1 2 "Organizing is wat you do efore you do someting, so tat wen you do it, it is not all mixed up." ~ A. A. Milne SORTING Tonigt!!!! Two Sessions: You sould now y now wat room to tae te final. Jenna
More informationECE250: Algorithms and Data Structures AVL Trees (Part A)
ECE250: Algorithms and Data Structures AVL Trees (Part A) Ladan Tahvildari, PEng, SMIEEE Associate Professor Software Technologies Applied Research (STAR) Group Dept. of Elect. & Comp. Eng. University
More informationCSCE476/876 Spring Homework 5
CSCE476/876 Spring 2016 Assigned on: Friday, Marc 11, 2016 Due: Monday, Marc 28, 2016 Homework 5 Programming assignment sould be submitted wit andin Te report can eiter be submitted wit andin as a PDF,
More informationCHAPTER 10 AVL TREES. 3 8 z 4
CHAPTER 10 AVL TREES v 6 3 8 z 4 ACKNOWLEDGEMENT: THESE SLIDES ARE ADAPTED FROM SLIDES PROVIDED WITH DATA STRUCTURES AND ALGORITHMS IN C++, GOODRICH, TAMASSIA AND MOUNT (WILEY 2004) AND SLIDES FROM NANCY
More informationNOTES: A quick overview of 2-D geometry
NOTES: A quick overview of 2-D geometry Wat is 2-D geometry? Also called plane geometry, it s te geometry tat deals wit two dimensional sapes flat tings tat ave lengt and widt, suc as a piece of paper.
More informationBinary Search Trees. Analysis of Algorithms
Binary Search Trees Analysis of Algorithms Binary Search Trees A BST is a binary tree in symmetric order 31 Each node has a key and every node s key is: 19 23 25 35 38 40 larger than all keys in its left
More informationData Structures in Java
Data Structures in Java Lecture 10: AVL Trees. 10/1/015 Daniel Bauer Balanced BSTs Balance condition: Guarantee that the BST is always close to a complete binary tree (every node has exactly two or zero
More information4.2 Binary Search Trees
Binary trees 4. Binary earc Trees Definition. BT is a binary tree in symmetric order. root a left link a subtree binary tree is eiter: mpty. rigt cild of root Two disjoint binary trees (left and rigt).
More informationCourse Review for. Cpt S 223 Fall Cpt S 223. School of EECS, WSU
Course Review for Midterm Exam 1 Cpt S 223 Fall 2011 1 Midterm Exam 1 When: Friday (10/14) 1:10-2pm Where: in class Closed book, closed notes Comprehensive Material for preparation: Lecture slides & in-class
More informationCS102 Binary Search Trees
CS102 Binary Search Trees Prof Tejada 1 To speed up insertion, removal and search, modify the idea of a Binary Tree to create a Binary Search Tree (BST) Binary Search Trees Binary Search Trees have one
More informationIntroduction. for large input, even access time may be prohibitive we need data structures that exhibit times closer to O(log N) binary search tree
Chapter 4 Trees 2 Introduction for large input, even access time may be prohibitive we need data structures that exhibit running times closer to O(log N) binary search tree 3 Terminology recursive definition
More informationYou Try: A. Dilate the following figure using a scale factor of 2 with center of dilation at the origin.
1 G.SRT.1-Some Tings To Know Dilations affect te size of te pre-image. Te pre-image will enlarge or reduce by te ratio given by te scale factor. A dilation wit a scale factor of 1> x >1enlarges it. A dilation
More informationAVL Trees. Version of September 6, AVL Trees Version of September 6, / 22
VL Trees Version of September 6, 6 VL Trees Version of September 6, 6 / inary Search Trees x 8 4 4 < x > x 7 9 3 inary-search-tree property For every node x ll eys in its left subtree are smaller than
More informationCourse Review. Cpt S 223 Fall 2009
Course Review Cpt S 223 Fall 2009 1 Final Exam When: Tuesday (12/15) 8-10am Where: in class Closed book, closed notes Comprehensive Material for preparation: Lecture slides & class notes Homeworks & program
More informationFault Localization Using Tarantula
Class 20 Fault localization (cont d) Test-data generation Exam review: Nov 3, after class to :30 Responsible for all material up troug Nov 3 (troug test-data generation) Send questions beforeand so all
More informationDATA STRUCTURES AND ALGORITHMS
LECTURE 13 Babeş - Bolyai University Computer Science and Mathematics Faculty 2017-2018 In Lecture 12... Binary Search Trees Binary Tree Traversals Huffman coding Binary Search Tree Today Binary Search
More informationCSE 326: Data Structures Splay Trees. James Fogarty Autumn 2007 Lecture 10
CSE 32: Data Structures Splay Trees James Fogarty Autumn 2007 Lecture 10 AVL Trees Revisited Balance condition: Left and right subtrees of every node have heights differing by at most 1 Strong enough :
More informationl Heaps very popular abstract data structure, where each object has a key value (the priority), and the operations are:
DDS-Heaps 1 Heaps - basics l Heaps very popular abstract data structure, where each object has a key value (the priority), and the operations are: l insert an object, find the object of minimum key (find
More informationChapter 2: Basic Data Structures
Chapter 2: Basic Data Structures Basic Data Structures Stacks Queues Vectors, Linked Lists Trees (Including Balanced Trees) Priority Queues and Heaps Dictionaries and Hash Tables Spring 2014 CS 315 2 Two
More informationFundamental Algorithms
WS 2007/2008 Fundamental Algorithms Dmytro Chibisov, Jens Ernst Fakultät für Informatik TU München http://www14.in.tum.de/lehre/2007ws/fa-cse/ Fall Semester 2007 1. AVL Trees As we saw in the previous
More informationNotes: Dimensional Analysis / Conversions
Wat is a unit system? A unit system is a metod of taking a measurement. Simple as tat. We ave units for distance, time, temperature, pressure, energy, mass, and many more. Wy is it important to ave a standard?
More information1.4 RATIONAL EXPRESSIONS
6 CHAPTER Fundamentals.4 RATIONAL EXPRESSIONS Te Domain of an Algebraic Epression Simplifying Rational Epressions Multiplying and Dividing Rational Epressions Adding and Subtracting Rational Epressions
More informationCOMP Analysis of Algorithms & Data Structures
COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Binary Search Trees CLRS 12.2, 12.3, 13.2, read problem 13-3 University of Manitoba COMP 3170 - Analysis of Algorithms & Data Structures
More informationAVL Trees (10.2) AVL Trees
AVL Trees (0.) CSE 0 Winter 0 8 February 0 AVL Trees AVL trees are balanced. An AVL Tree is a binary search tree such that for every internal node v of T, the heights of the children of v can differ by
More informationl So unlike the search trees, there are neither arbitrary find operations nor arbitrary delete operations possible.
DDS-Heaps 1 Heaps - basics l Heaps an abstract structure where each object has a key value (the priority), and the operations are: insert an object, find the object of minimum key (find min), and delete
More informationUNIT III BALANCED SEARCH TREES AND INDEXING
UNIT III BALANCED SEARCH TREES AND INDEXING OBJECTIVE The implementation of hash tables is frequently called hashing. Hashing is a technique used for performing insertions, deletions and finds in constant
More information5.3 Recursive definitions and structural induction
/8/05 5.3 Recursive defiitios ad structural iductio CSE03 Discrete Computatioal Structures Lecture 6 A recursively defied picture Recursive defiitios e sequece of powers of is give by a = for =0,,, Ca
More information19.2 Surface Area of Prisms and Cylinders
Name Class Date 19 Surface Area of Prisms and Cylinders Essential Question: How can you find te surface area of a prism or cylinder? Resource Locker Explore Developing a Surface Area Formula Surface area
More informationPriority Queues Heaps Heapsort
Priority Queues Heaps Heapsort After this lesson, you should be able to apply the binary heap insertion and deletion algorithms by hand implement the binary heap insertion and deletion algorithms explain
More informationCSE 326: Data Structures Lecture #8 Binary Search Trees
CSE 6: Data Structures Lecture #8 Binary Search Trees Alon Halevy Spring Quarter Binary Trees Many algorithms are efficient and easy to program for the special case of binary trees B A C Binary tree is
More informationAlgorithms. Deleting from Red-Black Trees B-Trees
Algorithms Deleting from Red-Black Trees B-Trees Recall the rules for BST deletion 1. If vertex to be deleted is a leaf, just delete it. 2. If vertex to be deleted has just one child, replace it with that
More informationCOMP Analysis of Algorithms & Data Structures
COMP 3170 - Analysis of Algorithms & Data Structures Shahin Kamali Lecture 9 - Jan. 22, 2018 CLRS 12.2, 12.3, 13.2, read problem 13-3 University of Manitoba COMP 3170 - Analysis of Algorithms & Data Structures
More information