each 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.

Size: px
Start display at page:

Download "each 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."

Transcription

1 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

2 Data Structures CSC212 2 AVL Trees A binary tree is an AVL tree if Eac node satisfies BST property key of te node is grater tan te key of eac node in its left subtree and is smaller tan te key of eac node in its rigt subtree Eac node satisfies eigt-balanced-tree property te difference between te eigts of te left subtree and rigt subtree of te node does not exceed one.

3 Data Structures CSC An Imbalanced Tree A Balanced Tree

4 Data Structures CSC212 4 Insert 1, 2, 3, 4 and 5 in te given order BST after insertions AVL Tree after insertions

5 Data Structures CSC212 5 Wy AVL Trees? Wen data elements are inserted in a BST in sorted order: 1, 2, 3, 1 BST becomes a degenerate tree. Searc operation FindKey takes O(n), wic is as inefficient as in a list. 3 It is possible tat after a number of insert and delete operations a binary tree may become imbalanced and increase in eigt. Can we insert and delete elements from BST so tat its eigt is guaranteed to be O(log n)? AVL tree ensures tis. 2 n

6 Data Structures CSC212 6 Specification of AVL Tree ADT Elements: Any data type Structure: A binary tree suc tat if N is any node in te tree ten all nodes in its left subtree are smaller tan N, and all nodes in its rigt subtree are larger tan N. Te eigt difference of te two subtrees of any node is at te most one. Note: : A node N is larger tan te node M if key value of N is larger tan tat of M and vice versa. Domain: Number of elements is bounded d Operations: Operation Specification void empty() Precondition: none. Process: returns true if te AVL as no nodes.

7 Data Structures CSC212 7 Operation Specification void findkey (int k) Precondition: none. Process: searces te AVL for a node wose key = k. If found ten tat node will be set as te current node and returns true. And if searc failed, ten (1) AVL empty ten just return false; or (2) AVL not empty ten current node is te node to wic a node containing k would be attaced as a cild if it were added to AVL and return false. void insert(intint k, Type val) Precondition: AVL not full. Process: (1) if we already ave a node wit key = k ten current retain its old value (te value prior to calling tis operation) and return false; or (2) insert a new node wit te given key and data and setting it as current node, return true. void update(type) Precondition/Requires : AVLis not empty. Process: update te value of data of te current node, key remains uncanged. Type retrieve() Precondition: AVL is not empty. Process: returns data of te current node.. bool remove_key(int k) Precondition: none. Process: removes te node containing te key = k, and in case BST is not empty ten sets te root as te current node. Returns true or false depending on weter te operation was successful or not.

8 Data Structures CSC212 8 Representation of AVL Tree ADT Since AVL is a special binary tree, it can be represented using - Linked List Note : Array is not suitable for AVL

9 Data Structures CSC212 9 Implementation of AVL public class AVLNode <T> { public int key, bal; public T data; public AVLNode<T> left, rigt; } public AVLNode(int k, T val) { key = k; bal = ; data = val; left = rigt = null; } public AVLNode (int k, AVLNode<T> l, AVLNode<T> r) { key = k; bal = ; } left = l; rigt = r;

10 Data Structures CSC212 1 Implementation of AVL public class Flag { boolean value; /** Creates a new instance of Flag */ public Flag() { value = false; } public Flag(boolean v){ value = v; } public boolean get_value (){ return value; } public void set_value(boolean l v){ value = v; } }

11 Data Structures CSC212 Implementation of AVL public class AVL <T> { AVLNode<T> root, current; public BST() private AVLNode<T> findparent (AVLNode<T> p) private AVLNode<T> find_min(avlnode<t> p) private AVLNode<T> remove_aux(int key, AVLNode<T> p, Flag flag) } public boolean empty() public T retrieve () public boolean findkey(int tkey) public boolean insert (int k, T val) public boolean remove_key (int tkey) public boolean update(int key, T data)

12 Data Structures CSC Note Tere is always a unique pat from te root to te new node. It is called te searc pat. A pivot node is a node closest to te new node on te searc pat, wose balance factor is eiter 1 or. Insert

13 Data Structures CSC No Pivot node 3 3 Insert Insert Pivot node 55 65

14 Data Structures CSC If, after an insert operation or a delete operation, an AVL tree becomes imbalanced, adjustments must be made to te tree to cange it back into an AVL tree. Tese adjustments are called rotations. Rotations are eiter single or double rotations.

15 Data Structures CSC Insert Operation Step 1: Insert a node into te AVL tree as it is inserted in a BST Step 2: Examine te searc pat to see if tere is a pivot node. Tree cases may arise. Case 1: Tere is no pivot node. No adjustment required. Case 2: Te pivot node exists and te subtree of te pivot node to wic te new node is added as smaller eigt. No adjustment required Case 3: Te pivot node exists and te subtree to wic te new node is added as te larger eigt. Adjustment required.

16 Data Structures CSC Insert: Case 1 No pivot node Insert Insert

17 Data Structures CSC Insert: Case 2 Pivot node exits New node added to te sorter subtree of te Pivot node. Pivot Node 2 2 Insert Insert Pivot Node 45 7

18 Data Structures CSC Note In tis case If balance factor of te pivot node is, te new node is inserted in te left subtree If balance factor of te pivot node is, te new node is inserted in te rigt subtree

19 Data Structures CSC Insert: Case 3 Pivot node exits New node added to te longer subtree of te Pivot node. 6 Insert 5 Pivot Node Note: AVL Tree is no more an AVL Tree after insertion.

20 Data Structures CSC212 2 Note Case 3 as furter 4 cases: Left-left case: An insertion in te left subtree of te left cild of te pivot node Rigt-left case: An insertion in te rigt subtree of te left cild of pivot node Left-rigt case: An insertion in te left subtree of te rigt cild of pivot node Rigt-rigt case: An insertion in te rigt subtree of te rigt cild of pivot node In te cases left-left and rigt-rigt rigt, single rotation is applied after new node is inserted. In te cases rigt-left and rigt-left left,, double rotation is applied after new node is inserted.

21 Data Structures CSC Insert: Left-left subcase te tree te tree B Pivot Single Rotation A A T3 B T2 T2 T3 New Node New Node Note: Rotation is applied about pivot node.

22 Data Structures CSC B Pivot A A T3 Single Rotation B T2 T2 T3 New Node New Node public void rotateleftcild(avlnode<t> B) { AVLNode<T> A = B.left; B.left = A.rigt; A.rigt = B; B = A; }

23 Data Structures CSC Example 1 6 Insert Single rotation 8 1

24 Data Structures CSC Insert: Rigt-rigt subcase te tree te tree Pivot B Single Rotation A T3 T2 A T3 B T2 New Node New Node

25 Data Structures CSC Pivot B A T3 T2 A Single Rotation T3 B T2 New Node New Node public void rotaterigtcild(avlnode<t> B) { AVLNode<T> A = B.rigt; B.rigt = A.left; A.left = B; B = A; }

26 Data Structures CSC Example 2 6 Insert Single rotation

27 Data Structures CSC Insert: Left-rigt subcase te tree te tree B Pivot Double Rotation C Pivot A T4 C T2 T3 A B T2 T3 T4

28 Data Structures CSC B Pivot C Pivot A T4 C Double Rotation T2 T3 A B T2 T3 T4 public void doublerotateleftcild(avlnode<t> B) { rotaterigtcild(b.left B.left); rotateleftcild(b); }

29 Data Structures CSC Example 3 6 Insert Double rotation 8 1

30 Data Structures CSC212 3 Insert: Left-rigt subcase te tree te tree B Pivot Double Rotation C Pivot A T4 C T2 T3 A B T2 T3 T4

31 Data Structures CSC Example 4 6 Insert Double rotation 8 1

32 Data Structures CSC Insert: Rigt- Left subcase te tree te tree Pivot B Double Rotation Pivot C T4 T3 C A T2 T4 B T3 T2 A

33 Data Structures CSC Pivot B Pivot C T4 T3 C A T2 Double Rotation T4 B T3 T2 A public void doublerotaterigtcild(avlnode<t> B) { rotateleftcild(b.rigt B.rigt); rotatrigtcild(b); }

34 Data Structures CSC Example Insert Double rotation

35 Data Structures CSC Insert: Rigt- Left subcase te tree te tree Pivot B Double Rotation Pivot C T4 A B A C T3 T2 T3 T2 T4

36 Data Structures CSC Example Insert Double rotation

37 Data Structures CSC Delete Operation Step 1: : Delete te node as in BST. Leaf node will always be deleted. Step 2: Ceck eac node p on te pat from te root to te parent node W of te deleted node. Start from te node on te pat closest to W. Tree cases are possible. Case 1: : Node p as balance factor. No rotation needed. Case 2: Node p as balance factor of (or 1) and a node was deleted from rigt sub-tree (or left subtree). No rotation needed. Case 3: Node p as balance factor of (or 1) and a node was deleted from left sub-tree (rigt sub-tree). Rotation needed. Four sub-cases are possible.

38 Data Structures CSC Let q be te cild of p wit larger eigt r be te cild of q wit larger eigt Sub-case (left-left) left) r is left cild of q, and q is left cild of p Apply Single rotation Sub-case -2 (rigt-rigt g ) r is rigt cild of q, and q is rigt cild of p Apply Single rotation Sub-case -3 (left-rigt ) r is left cild of q, and q is rigt cild of p Apply double rotation Sub-case -4 (rigt-left) r is rigt cild of q, and q is left cild of p Apply Single rotation te tree p -2 q T4 r T2 T3

39 Data Structures CSC Case 1 Balance factor of p is te tree te tree p p Node to be deleted.

40 Data Structures CSC212 4 Case 2 Balance factor of p is and node is deleted from left subtree te tree te tree p p Node to be deleted.

41 Data Structures CSC Case 2 Balance factor of p is and node is deleted from rigt subtree te tree te tree p p Node to be deleted.

42 Data Structures CSC Case 3 Subcase 1 (left-left) r is left cild of q, and q is left cild of p te tree te tree -2 p q r T4 Single Rotation r T2 T3 q p T4 T2 T3

43 Data Structures CSC Case 3 Subcase 2 (rigt-rigt) r is rigt cild of q, and q is rigt cild of p te tree te tree +2 p q Single Rotation q p r T4 T2 r T3 T4 T2 T3

44 Data Structures CSC Case 3 Subcase 3 (left-rigt) r is rigt cild of q, and q is left cild of p te tree te tree -2 p Double Rotation r q q p r T4 T2 T3 T4 T2 T3

45 Data Structures CSC Case 3 Subcase 4 (rigt-left) r is left cild of q, and q is rigt cild of p te tree te tree +2 p q Single Rotation r p q T4 r T4 T2 T3 T2 T3

46 Data Structures CSC Deletion: Example c e j m n p Delete p s b d k o r u a g i l t f

47 Data Structures CSC Deletion: Example c e j m n +2 o Delete p s b d k Sub-Case 1 Single Rotation a g i l t f r u

48 Data Structures CSC Deletion: Example c e j -2 m o s u b d k n r t a g i l f Sub Case 8 Double Rotation

49 Data Structures CSC Deletion: Example After Double Rotation c e j k m s a b d g i l o u n f r t

50 Data Structures CSC212 5 Exercise 1 (i) Is te following tree an AVL tree? If not, convert it into an AVL tree (ii) Insert te nodes 7, 125, 65, 72, and 61 in te tree given in part (i), one at a time, and sow te result of eac insertion in a separate diagram. Ensure tat te resulting tree satisfies AVL condition. (iii) Delete node 12 from te AVL tree you get in part (ii) and sow te result in a separate diagram. Make sure te resulting tree is an AVL tree.

51 Data Structures CSC Exercise 1 1. Wat is an AVL tree and wen is it used? 2. Wat is te time complexity for inserting N keys into an AVL tree? 3. Insert te following keys into an empty AVL tree 5, 1, 2, 6, 8, 3, 9 4. Delete 88 and ten

52 Data Structures CSC Delete 38 from te following AVL tree

CS 234. Module 6. October 16, CS 234 Module 6 ADT Dictionary 1 / 33

CS 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 information

When a BST becomes badly unbalanced, the search behavior can degenerate to that of a sorted linked list, O(N).

When 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 information

1 Copyright 2012 by Pearson Education, Inc. All Rights Reserved.

1 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 information

CS 234. Module 6. October 25, CS 234 Module 6 ADT Dictionary 1 / 22

CS 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 information

AVL Trees Outline and Required Reading: AVL Trees ( 11.2) CSE 2011, Winter 2017 Instructor: N. Vlajic

AVL 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 information

Announcements. Lilian s office hours rescheduled: Fri 2-4pm HW2 out tomorrow, due Thursday, 7/7. CSE373: Data Structures & Algorithms

Announcements. Lilian s office hours rescheduled: Fri 2-4pm HW2 out tomorrow, due Thursday, 7/7. CSE373: Data Structures & Algorithms Announcements Lilian s office ours resceduled: Fri 2-4pm HW2 out tomorrow, due Tursday, 7/7 CSE373: Data Structures & Algoritms Deletion in BST 2 5 5 2 9 20 7 0 7 30 Wy migt deletion be arder tan insertion?

More information

Wrap up Amortized Analysis; AVL Trees. Riley Porter Winter CSE373: Data Structures & Algorithms

Wrap 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 information

CE 221 Data Structures and Algorithms

CE 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 information

CSE 332: Data Structures & Parallelism Lecture 8: AVL Trees. Ruth Anderson Winter 2019

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 information

Consider the search operation FindKey (): find an element of a particular key value in a binary tree. This operation takes O(n) time in a binary

Consider the search operation FindKey (): find an element of a particular key value in a binary tree. This operation takes O(n) time in a binary 1 Consider the search operation FindKey (): find an element of a particular key value in a binary tree. This operation takes O(n) time in a binary tree. In a binary tree of 10 6 nodes 10 6 steps required

More information

Data Structures and Programming Spring 2014, Midterm Exam.

Data 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 information

Binary Search Tree - Best Time. AVL Trees. Binary Search Tree - Worst Time. Balanced and unbalanced BST

Binary 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 information

Design Patterns for Data Structures. Chapter 10. Balanced Trees

Design 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 information

Lecture 7. Binary Search Trees / AVL Trees

Lecture 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 information

Advanced Tree. Structures. AVL Tree. Outline. AVL Tree Recall, Binary Search Tree (BST) is a special case of. Splay Tree (Ch 13.2.

Advanced 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 information

AVL Trees. CSE260, Computer Science B: Honors Stony Brook University

AVL 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 information

Design Patterns for Data Structures. Chapter 10. Balanced Trees

Design 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 information

15-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 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 information

TREES. General Binary Trees The Search Tree ADT Binary Search Trees AVL Trees Threaded trees Splay Trees B-Trees. UNIT -II

TREES. 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 information

4.2 The Derivative. f(x + h) f(x) lim

4.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 information

19.2 Surface Area of Prisms and Cylinders

19.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 information

More on Functions and Their Graphs

More 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 information

2 The Derivative. 2.0 Introduction to Derivatives. Slopes of Tangent Lines: Graphically

2 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 information

4.1 Tangent Lines. y 2 y 1 = y 2 y 1

4.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 information

, 1 1, A complex fraction is a quotient of rational expressions (including their sums) that result

, 1 1, A complex fraction is a quotient of rational expressions (including their sums) that result RT. Complex Fractions Wen working wit algebraic expressions, sometimes we come across needing to simplify expressions like tese: xx 9 xx +, xx + xx + xx, yy xx + xx + +, aa Simplifying Complex Fractions

More information

Section 2.3: Calculating Limits using the Limit Laws

Section 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 information

Materials: Whiteboard, TI-Nspire classroom set, quadratic tangents program, and a computer projector.

Materials: 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 information

CS211 Spring 2004 Lecture 06 Loops and their invariants. Software engineering reason for using loop invariants

CS211 Spring 2004 Lecture 06 Loops and their invariants. Software engineering reason for using loop invariants CS211 Spring 2004 Lecture 06 Loops and teir invariants Reading material: Tese notes. Weiss: Noting on invariants. ProgramLive: Capter 7 and 8 O! Tou ast damnale iteration and art, indeed, ale to corrupt

More information

When the dimensions of a solid increase by a factor of k, how does the surface area change? How does the volume change?

When the dimensions of a solid increase by a factor of k, how does the surface area change? How does the volume change? 8.4 Surface Areas and Volumes of Similar Solids Wen te dimensions of a solid increase by a factor of k, ow does te surface area cange? How does te volume cange? 1 ACTIVITY: Comparing Surface Areas and

More information

CHAPTER 7: TRANSCENDENTAL FUNCTIONS

CHAPTER 7: TRANSCENDENTAL FUNCTIONS 7.0 Introduction and One to one Functions Contemporary Calculus 1 CHAPTER 7: TRANSCENDENTAL FUNCTIONS Introduction In te previous capters we saw ow to calculate and use te derivatives and integrals of

More information

1.4 RATIONAL EXPRESSIONS

1.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 information

CSCE476/876 Spring Homework 5

CSCE476/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 information

Bounding Tree Cover Number and Positive Semidefinite Zero Forcing Number

Bounding 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 information

CS 261 Data Structures. AVL Trees

CS 261 Data Structures. AVL Trees CS 261 Data Structures AVL Trees 1 Binary Search Tree Complexity of BST operations: proportional to the length of the path from a node to the root Unbalanced tree: operations may be O(n) E.g.: adding elements

More information

2.8 The derivative as a function

2.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 information

VOLUMES. The volume of a cylinder is determined by multiplying the cross sectional area by the height. r h V. a) 10 mm 25 mm.

VOLUMES. The volume of a cylinder is determined by multiplying the cross sectional area by the height. r h V. a) 10 mm 25 mm. OLUME OF A CYLINDER OLUMES Te volume of a cylinder is determined by multiplying te cross sectional area by te eigt. r Were: = volume r = radius = eigt Exercise 1 Complete te table ( =.14) r a) 10 mm 5

More information

Interference and Diffraction of Light

Interference and Diffraction of Light Interference and Diffraction of Ligt References: [1] A.P. Frenc: Vibrations and Waves, Norton Publ. 1971, Capter 8, p. 280-297 [2] PASCO Interference and Diffraction EX-9918 guide (written by Ann Hanks)

More information

MTH-112 Quiz 1 - Solutions

MTH-112 Quiz 1 - Solutions MTH- Quiz - Solutions Words in italics are for eplanation purposes onl (not necessar to write in te tests or. Determine weter te given relation is a function. Give te domain and range of te relation. {(,

More information

and installation instructions Power Converter DLU 02

and installation instructions Power Converter DLU 02 Always read te operating and installation instructions before start-up! Work on automatic burner control systems may only be carried out by trained specialist personnel! Operating and installation instructions

More information

Areas of Triangles and Parallelograms. Bases of a parallelogram. Height of a parallelogram THEOREM 11.3: AREA OF A TRIANGLE. a and its corresponding.

Areas of Triangles and Parallelograms. Bases of a parallelogram. Height of a parallelogram THEOREM 11.3: AREA OF A TRIANGLE. a and its corresponding. 11.1 Areas of Triangles and Parallelograms Goal p Find areas of triangles and parallelograms. Your Notes VOCABULARY Bases of a parallelogram Heigt of a parallelogram POSTULATE 4: AREA OF A SQUARE POSTULATE

More information

Hash-Based Indexes. Chapter 11. Comp 521 Files and Databases Spring

Hash-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 information

12.2 Investigate Surface Area

12.2 Investigate Surface Area Investigating g Geometry ACTIVITY Use before Lesson 12.2 12.2 Investigate Surface Area MATERIALS grap paper scissors tape Q U E S T I O N How can you find te surface area of a polyedron? A net is a pattern

More information

Balanced Binary Search Trees. Victor Gao

Balanced Binary Search Trees. Victor Gao Balanced Binary Search Trees Victor Gao OUTLINE Binary Heap Revisited BST Revisited Balanced Binary Search Trees Rotation Treap Splay Tree BINARY HEAP: REVIEW A binary heap is a complete binary tree such

More information

MATH 5a Spring 2018 READING ASSIGNMENTS FOR CHAPTER 2

MATH 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 information

2.5 Evaluating Limits Algebraically

2.5 Evaluating Limits Algebraically SECTION.5 Evaluating Limits Algebraically 3.5 Evaluating Limits Algebraically Preinary Questions. Wic of te following is indeterminate at x? x C x ; x x C ; x x C 3 ; x C x C 3 At x, x isofteform 0 xc3

More information

Algorithms. AVL Tree

Algorithms. 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 information

4.2 Binary Search Trees

4.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 information

Announcements SORTING. Prelim 1. Announcements. A3 Comments 9/26/17. This semester s event is on Saturday, November 4 Apply to be a teacher!

Announcements 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 information

SORTING 9/26/18. Prelim 1. Prelim 1. Why Sorting? InsertionSort. Some Sorting Algorithms. Tonight!!!! Two Sessions:

SORTING 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 information

Hash-Based Indexes. Chapter 11. Comp 521 Files and Databases Fall

Hash-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 information

You should be able to visually approximate the slope of a graph. The slope m of the graph of f at the point x, f x is given by

You should be able to visually approximate the slope of a graph. The slope m of the graph of f at the point x, f x is given by Section. Te Tangent Line Problem 89 87. r 5 sin, e, 88. r sin sin Parabola 9 9 Hperbola e 9 9 9 89. 7,,,, 5 7 8 5 ortogonal 9. 5, 5,, 5, 5. Not multiples of eac oter; neiter parallel nor ortogonal 9.,,,

More information

Areas of Parallelograms and Triangles. To find the area of parallelograms and triangles

Areas of Parallelograms and Triangles. To find the area of parallelograms and triangles 10-1 reas of Parallelograms and Triangles ommon ore State Standards G-MG..1 Use geometric sapes, teir measures, and teir properties to descrie ojects. G-GPE..7 Use coordinates to compute perimeters of

More information

Classify solids. Find volumes of prisms and cylinders.

Classify solids. Find volumes of prisms and cylinders. 11.4 Volumes of Prisms and Cylinders Essential Question How can you find te volume of a prism or cylinder tat is not a rigt prism or rigt cylinder? Recall tat te volume V of a rigt prism or a rigt cylinder

More information

Haar Transform CS 430 Denbigh Starkey

Haar 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 information

PLK-B SERIES Technical Manual (USA Version) CLICK HERE FOR CONTENTS

PLK-B SERIES Technical Manual (USA Version) CLICK HERE FOR CONTENTS PLK-B SERIES Technical Manual (USA Version) CLICK ERE FOR CONTENTS CONTROL BOX PANEL MOST COMMONLY USED FUNCTIONS INITIAL READING OF SYSTEM SOFTWARE/PAGES 1-2 RE-INSTALLATION OF TE SYSTEM SOFTWARE/PAGES

More information

Fall, 2015 Prof. Jungkeun Park

Fall, 2015 Prof. Jungkeun Park Data Structures and Algorithms Binary Search Trees Fall, 2015 Prof. Jungkeun Park Copyright Notice: This material is modified version of the lecture slides by Prof. Rada Mihalcea in Univ. of North Texas.

More information

12.2 Techniques for Evaluating Limits

12.2 Techniques for Evaluating Limits 335_qd /4/5 :5 PM Page 863 Section Tecniques for Evaluating Limits 863 Tecniques for Evaluating Limits Wat ou sould learn Use te dividing out tecnique to evaluate its of functions Use te rationalizing

More information

MAC-CPTM Situations Project

MAC-CPTM Situations Project raft o not use witout permission -P ituations Project ituation 20: rea of Plane Figures Prompt teacer in a geometry class introduces formulas for te areas of parallelograms, trapezoids, and romi. e removes

More information

13.5 DIRECTIONAL DERIVATIVES and the GRADIENT VECTOR

13.5 DIRECTIONAL DERIVATIVES and the GRADIENT VECTOR 13.5 Directional Derivatives and te Gradient Vector Contemporary Calculus 1 13.5 DIRECTIONAL DERIVATIVES and te GRADIENT VECTOR Directional Derivatives In Section 13.3 te partial derivatives f x and f

More information

Multi-Stack Boundary Labeling Problems

Multi-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 information

DATA STRUCTURES AND ALGORITHMS. Hierarchical data structures: AVL tree, Bayer tree, Heap

DATA STRUCTURES AND ALGORITHMS. Hierarchical data structures: AVL tree, Bayer tree, Heap DATA STRUCTURES AND ALGORITHMS Hierarchical data structures: AVL tree, Bayer tree, Heap Summary of the previous lecture TREE is hierarchical (non linear) data structure Binary trees Definitions Full tree,

More information

You Try: A. Dilate the following figure using a scale factor of 2 with center of dilation at the origin.

You 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 information

Symmetric Tree Replication Protocol for Efficient Distributed Storage System*

Symmetric Tree Replication Protocol for Efficient Distributed Storage System* ymmetric Tree Replication Protocol for Efficient Distributed torage ystem* ung Cune Coi 1, Hee Yong Youn 1, and Joong up Coi 2 1 cool of Information and Communications Engineering ungkyunkwan University

More information

Deletion The Two Child Case 10 Delete(5) Deletion The Two Child Case. Balanced BST. Finally

Deletion 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 information

Chapter K. Geometric Optics. Blinn College - Physics Terry Honan

Chapter K. Geometric Optics. Blinn College - Physics Terry Honan Capter K Geometric Optics Blinn College - Pysics 2426 - Terry Honan K. - Properties of Ligt Te Speed of Ligt Te speed of ligt in a vacuum is approximately c > 3.0µ0 8 mês. Because of its most fundamental

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 11: Binary Search Trees MOUNA KACEM mouna@cs.wisc.edu Fall 2018 General Overview of Data Structures 2 Introduction to trees 3 Tree: Important non-linear data structure

More information

Vector Processing Contours

Vector Processing Contours Vector Processing Contours Andrey Kirsanov Department of Automation and Control Processes MAMI Moscow State Tecnical University Moscow, Russia AndKirsanov@yandex.ru A.Vavilin and K-H. Jo Department of

More information

Fault Localization Using Tarantula

Fault 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 information

Numerical Derivatives

Numerical 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 information

5.4 Sum and Difference Formulas

5.4 Sum and Difference Formulas 380 Capter 5 Analtic Trigonometr 5. Sum and Difference Formulas Using Sum and Difference Formulas In tis section and te following section, ou will stud te uses of several trigonometric identities and formulas.

More information

Sorting and Searching

Sorting and Searching CS 1110: Introduction to Computing Using Pyton Lecture 23 Sorting and Searcing [Andersen, Gries, Lee, Marscner, Van Loan, Wite] Announcements Final Exam conflicts due tonigt at 11:59pm Final Exam review

More information

EXERCISES 6.1. Cross-Sectional Areas. 6.1 Volumes by Slicing and Rotation About an Axis 405

EXERCISES 6.1. Cross-Sectional Areas. 6.1 Volumes by Slicing and Rotation About an Axis 405 6. Volumes b Slicing and Rotation About an Ais 5 EXERCISES 6. Cross-Sectional Areas In Eercises and, find a formula for te area A() of te crosssections of te solid perpendicular to te -ais.. Te solid lies

More information

12.2 TECHNIQUES FOR EVALUATING LIMITS

12.2 TECHNIQUES FOR EVALUATING LIMITS Section Tecniques for Evaluating Limits 86 TECHNIQUES FOR EVALUATING LIMITS Wat ou sould learn Use te dividing out tecnique to evaluate its of functions Use te rationalizing tecnique to evaluate its of

More information

CS 206 Introduction to Computer Science II

CS 206 Introduction to Computer Science II CS 206 Introduction to Computer Science II 04 / 26 / 2017 Instructor: Michael Eckmann Today s Topics Questions? Comments? Balanced Binary Search trees AVL trees Michael Eckmann - Skidmore College - CS

More information

Lesson 21: AVL Trees. Rotation

Lesson 21: AVL Trees. Rotation The time required to perform operations on a binary search tree is proportional to the length of the path from root to leaf. This isn t bad in a well-balanced tree. But nothing prevents a tree from becoming

More information

The Problem with Linked Lists. Topic 18. Attendance Question 1. Binary Search Trees. -Monty Python and The Holy Grail

The Problem with Linked Lists. Topic 18. Attendance Question 1. Binary Search Trees. -Monty Python and The Holy Grail Topic 18 Binary Search Trees "Yes. Shrubberies are my trade. I am a shrubber. My name is 'Roger the Shrubber'. I arrange, design, and sell shrubberies." -Monty Python and The Holy Grail The Problem with

More information

4. Trees. 4.1 Preliminaries. 4.2 Binary trees. 4.3 Binary search trees. 4.4 AVL trees. 4.5 Splay trees. 4.6 B-trees. 4. Trees

4. Trees. 4.1 Preliminaries. 4.2 Binary trees. 4.3 Binary search trees. 4.4 AVL trees. 4.5 Splay trees. 4.6 B-trees. 4. Trees 4. Trees 4.1 Preliminaries 4.2 Binary trees 4.3 Binary search trees 4.4 AVL trees 4.5 Splay trees 4.6 B-trees Malek Mouhoub, CS340 Fall 2002 1 4.1 Preliminaries A Root B C D E F G Height=3 Leaves H I J

More information

Week 2. TA Lab Consulting - See schedule (cs400 home pages) Peer Mentoring available - Friday 8am-12pm, 12:15-1:30pm in 1289CS

Week 2. TA Lab Consulting - See schedule (cs400 home pages) Peer Mentoring available - Friday 8am-12pm, 12:15-1:30pm in 1289CS ASSIGNMENTS h0 available and due before 10pm on Monday 1/28 h1 available and due before 10pm on Monday 2/4 p1 available and due before 10pm on Thursday 2/7 Week 2 TA Lab Consulting - See schedule (cs400

More information

CS200: Balanced Search Trees

CS200: Balanced Search Trees Value Oriented Data Structures CS200: Balanced Search Trees Walls & Mirrors Chapters 12,13 Homework 4 extension Next week: Programming quiz during recit Midterm 2 April 8 th (in class) New partners and

More information

Cubic smoothing spline

Cubic smoothing spline Cubic smooting spline Menu: QCExpert Regression Cubic spline e module Cubic Spline is used to fit any functional regression curve troug data wit one independent variable x and one dependent random variable

More information

BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE

BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE BRONX COMMUNITY COLLEGE of the City University of New York DEPARTMENT OF MATHEMATICS AND COMPUTER SCIENCE CSI Section E01 AVL Trees AVL Property While BST structures have average performance of Θ(log(n))

More information

3.6 Directional Derivatives and the Gradient Vector

3.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 information

Data Structures and Algorithms for Engineers

Data Structures and Algorithms for Engineers 04-630 Data Structures and Algorithms for Engineers David Vernon Carnegie Mellon University Africa vernon@cmu.edu www.vernon.eu Data Structures and Algorithms for Engineers 1 Carnegie Mellon University

More information

Data Structures in Java

Data Structures in Java Data Structures in Java Lecture 9: Binary Search Trees. 10/7/015 Daniel Bauer 1 Contents 1. Binary Search Trees. Implementing Maps with BSTs Map ADT A map is collection of (key, value) pairs. Keys are

More information

Section 3. Imaging With A Thin Lens

Section 3. Imaging With A Thin Lens Section 3 Imaging Wit A Tin Lens 3- at Ininity An object at ininity produces a set o collimated set o rays entering te optical system. Consider te rays rom a inite object located on te axis. Wen te object

More information

Binary Search Trees 1

Binary Search Trees 1 Binary Search Trees 1 The Problem with Linked Lists 8Accessing a item from a linked list takes O(N) time for an arbitrary element 8Binary trees can improve upon this and reduce access to O( log N ) time

More information

Coarticulation: An Approach for Generating Concurrent Plans in Markov Decision Processes

Coarticulation: An Approach for Generating Concurrent Plans in Markov Decision Processes Coarticulation: An Approac for Generating Concurrent Plans in Markov Decision Processes Kasayar Roanimanes kas@cs.umass.edu Sridar Maadevan maadeva@cs.umass.edu Department of Computer Science, University

More information

wrobot k wwrobot hrobot (a) Observation area Horopter h(θ) (Virtual) horopters h(θ+ θ lim) U r U l h(θ+ θ) Base line Left camera Optical axis

wrobot k wwrobot hrobot (a) Observation area Horopter h(θ) (Virtual) horopters h(θ+ θ lim) U r U l h(θ+ θ) Base line Left camera Optical axis Selective Acquisition of 3-D Information Enoug for Finding Passable Free Spaces Using an Active Stereo Vision System Atsusi Nisikawa, Atsusi Okubo, and Fumio Miyazaki Department of Systems and Human Science

More information

Piecewise Polynomial Interpolation, cont d

Piecewise Polynomial Interpolation, cont d Jim Lambers MAT 460/560 Fall Semester 2009-0 Lecture 2 Notes Tese notes correspond to Section 4 in te text Piecewise Polynomial Interpolation, cont d Constructing Cubic Splines, cont d Having determined

More information

5.3 Recursive definitions and structural induction

5.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 information

CS 315 Data Structures mid-term 2

CS 315 Data Structures mid-term 2 CS 315 Data Structures mid-term 2 1) Shown below is an AVL tree T. Nov 14, 2012 Solutions to OPEN BOOK section. (a) Suggest a key whose insertion does not require any rotation. 18 (b) Suggest a key, if

More information

Measuring Length 11and Area

Measuring Length 11and Area Measuring Lengt 11and Area 11.1 Areas of Triangles and Parallelograms 11.2 Areas of Trapezoids, Romuses, and Kites 11.3 Perimeter and Area of Similar Figures 11.4 Circumference and Arc Lengt 11.5 Areas

More information

Chapter 20: Binary Trees

Chapter 20: Binary Trees Chapter 20: Binary Trees 20.1 Definition and Application of Binary Trees Definition and Application of Binary Trees Binary tree: a nonlinear linked list in which each node may point to 0, 1, or two other

More information

Lecture 25. Sequence Algorithms (Continued)

Lecture 25. Sequence Algorithms (Continued) Lecture 25 Sequence Algoritms (Continued) Announcements for Tis Lecture Assignment & Lab A6 is not graded yet Done by end of classes A7 due Wed, Dec. 10 Wednesday after classes Keep on top of milestones

More information

Some Search Structures. Balanced Search Trees. Binary Search Trees. A Binary Search Tree. Review Binary Search Trees

Some Search Structures. Balanced Search Trees. Binary Search Trees. A Binary Search Tree. Review Binary Search Trees Some Search Structures Balanced Search Trees Lecture 8 CS Fall Sorted Arrays Advantages Search in O(log n) time (binary search) Disadvantages Need to know size in advance Insertion, deletion O(n) need

More information

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University CS 112 Introduction to Computing II Wayne Snyder Department Boston University Today: Efficiency of binary trees; Balanced Trees 2-3 Trees Next Time: 2-3 Trees continued B-Trees and External Search Efficiency

More information

Module 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree.

Module 4: Index Structures Lecture 13: Index structure. The Lecture Contains: Index structure. Binary search tree (BST) B-tree. B+-tree. The Lecture Contains: Index structure Binary search tree (BST) B-tree B+-tree Order file:///c /Documents%20and%20Settings/iitkrana1/My%20Documents/Google%20Talk%20Received%20Files/ist_data/lecture13/13_1.htm[6/14/2012

More information

Computer Science 302 Spring 2007 Practice Final Examination: Part I

Computer Science 302 Spring 2007 Practice Final Examination: Part I Computer Science 302 Spring 2007 Practice Final Examination: Part I Name: This practice examination is much longer than the real final examination will be. If you can work all the problems here, you will

More information

All truths are easy to understand once they are discovered; the point is to discover them. Galileo

All truths are easy to understand once they are discovered; the point is to discover them. Galileo Section 7. olume All truts are easy to understand once tey are discovered; te point is to discover tem. Galileo Te main topic of tis section is volume. You will specifically look at ow to find te volume

More information

6 Computing Derivatives the Quick and Easy Way

6 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 information