Binary trees. Application: AVL trees and the golden ratio. The golden ratio. φ 1=1/φ 1. φ =1+

Similar documents
CS103 Handout 25 Spring 2017 May 5, 2017 Problem Set 5

MATH 200 FINAL EXAM PEYAM RYAN TABRIZIAN

Fibonacci Numbers ANSWERS Lesson 1 of 10, work individually or in pairs

Evacuation and a Geometric Construction for Fibonacci Tableaux

PRIORITY QUEUES AND HEAPS

Second Annual University of Oregon Programming Contest, 1998

CS/ENGRD 2110 Object-Oriented Programming and Data Structures Spring 2012 Thorsten Joachims. Lecture 17: Heaps and Priority Queues

GAMES AND STRATEGY BEGINNERS 12/03/2017

MITOCW 6. AVL Trees, AVL Sort

Introduction to Game Theory

5 AVL trees: deletion

A Note on Downup Permutations and Increasing Trees DAVID CALLAN. Department of Statistics. Medical Science Center University Ave

Learning Log Title: CHAPTER 2: ARITHMETIC STRATEGIES AND AREA. Date: Lesson: Chapter 2: Arithmetic Strategies and Area

PRIORITY QUEUES AND HEAPS. Lecture 19 CS2110 Spring 2014

On uniquely k-determined permutations

Sequential games. We may play the dating game as a sequential game. In this case, one player, say Connie, makes a choice before the other.

Unless stated otherwise, explain your logic and write out complete sentences. No notes, books, calculators, or other electronic devices are permitted.

Number Fun December 3,

CSE 100: BST AVERAGE CASE AND HUFFMAN CODES

DVA325 Formal Languages, Automata and Models of Computation (FABER)

Math236 Discrete Maths with Applications

Checkpoint Questions Due Monday, October 7 at 2:15 PM Remaining Questions Due Friday, October 11 at 2:15 PM

Chapter 7: Sorting 7.1. Original

Coding for Efficiency

CSE373: Data Structure & Algorithms Lecture 23: More Sorting and Other Classes of Algorithms. Nicki Dell Spring 2014

Merge Sort. Note that the recursion bottoms out when the subarray has just one element, so that it is trivially sorted.

Heuristics, and what to do if you don t know what to do. Carl Hultquist

Huffman Coding - A Greedy Algorithm. Slides based on Kevin Wayne / Pearson-Addison Wesley

Solutions to Part I of Game Theory

Maths lesson. Exploring sequences and the Fibonacci sequence. Learning objectives. Knowledge. Skills. Resources

Restricted Permutations Related to Fibonacci Numbers and k-generalized Fibonacci Numbers

FIBONACCI KOLAMS -- AN OVERVIEW

PRIORITY QUEUES AND HEAPS. Slides of Ken Birman, Cornell University

ECS 20 (Spring 2013) Phillip Rogaway Lecture 1

Solutions to Assignment-2 MOOC-Information Theory

Some Fine Combinatorics

CSE101: Design and Analysis of Algorithms. Ragesh Jaiswal, CSE, UCSD

Game Theory and Randomized Algorithms

NANYANG TECHNOLOGICAL UNIVERSITY SEMESTER II EXAMINATION MH1301 DISCRETE MATHEMATICS. Time Allowed: 2 hours

MAT3707. Tutorial letter 202/1/2017 DISCRETE MATHEMATICS: COMBINATORICS. Semester 1. Department of Mathematical Sciences MAT3707/202/1/2017

CSS 343 Data Structures, Algorithms, and Discrete Math II. Balanced Search Trees. Yusuf Pisan

EXPERIMENT 1: Amplitude Shift Keying (ASK)

Generalized Game Trees

An Optimal Algorithm for a Strategy Game

RESTRICTED PERMUTATIONS AND POLYGONS. Ghassan Firro and Toufik Mansour Department of Mathematics, University of Haifa, Haifa, Israel

MITOCW 7. Counting Sort, Radix Sort, Lower Bounds for Sorting

Facilitator Guide. Unit 2

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 11

5. (1-25 M) How many ways can 4 women and 4 men be seated around a circular table so that no two women are seated next to each other.

2. The lines with equations ax + 2y = c and bx - 3y = d are perpendicular. Find a b. A. -6 B C. -1 D. 1.5 E. 6

RBT Operations. The basic algorithm for inserting a node into an RBT is:

From Shared Memory to Message Passing

Design and Analysis of Algorithms Prof. Madhavan Mukund Chennai Mathematical Institute. Module 6 Lecture - 37 Divide and Conquer: Counting Inversions

Math Lecture 2 Inverse Functions & Logarithms

Balanced Trees. Balanced Trees Tree. 2-3 Tree. 2 Node. Binary search trees are not guaranteed to be balanced given random inserts and deletes

@CRC Press. Discrete Mathematics. with Ducks. sarah-marie belcastro. let this be your watchword. serious mathematics treated with levity

THE GAME CREATION OPERATOR

Information for teachers

Design of Parallel Algorithms. Communication Algorithms

Math Contest Level 2 - March 17, Coastal Carolina University

Geometry Unit 2 Review Day 1 What to expect on the test:

Introduction to Spring 2009 Artificial Intelligence Final Exam

CRACKING THE 15 PUZZLE - PART 4: TYING EVERYTHING TOGETHER BEGINNERS 02/21/2016

EQUIPOPULARITY CLASSES IN THE SEPARABLE PERMUTATIONS

SOME MORE DECREASE AND CONQUER ALGORITHMS

Math 122 Rough Guide to Studying for Exam 2 Spring, 2009

Topic 23 Red Black Trees

Subtraction games with expandable subtraction sets

Module 3 Greedy Strategy

6.042/18.062J Mathematics for Computer Science December 17, 2008 Tom Leighton and Marten van Dijk. Final Exam

Hello and welcome to today s lecture. In the last couple of lectures we have discussed about various transmission media.

Logs and Exponentials Higher.notebook February 26, Daily Practice

Directed Towers of Hanoi

GCSE Maths Revision Factors and Multiples

and problem sheet 7

CS 473G: Combinatorial Algorithms, Fall 2005 Homework 0. I understand the Homework Instructions and FAQ.

Splay tree concept Splaying operation: double-rotations Splay insertion Splay search Splay deletion Running time of splay tree operations

DIFFERENT SEQUENCES. Learning Outcomes and Assessment Standards T 2 T 3

132-avoiding Two-stack Sortable Permutations, Fibonacci Numbers, and Pell Numbers

Binary Search Tree (Part 2 The AVL-tree)

arxiv: v1 [cs.dm] 13 Feb 2015

CSE 100: RED-BLACK TREES

Section 7.2 Logarithmic Functions

Comm. 502: Communication Theory. Lecture 6. - Introduction to Source Coding

2004 Denison Spring Programming Contest 1

((( ))) CS 19: Discrete Mathematics. Please feel free to ask questions! Getting into the mood. Pancakes With A Problem!

Preface for Instructors and Other Teachers 1 About This Book... xvii

PHYSICS 330 LAB Operational Amplifier Frequency Response

Graphs of Tilings. Patrick Callahan, University of California Office of the President, Oakland, CA

Pattern Avoidance in Unimodal and V-unimodal Permutations

SURDS, SPIRALS, DYNAMIC GEOMETRY AND CAS

1 = 3 2 = 3 ( ) = = = 33( ) 98 = = =

CONTENTS GRAPH THEORY

Guest Lecture, October

Semester 2 F i n a l Project Create a Math Board Game Due: May 11 th and 13 th

#A13 INTEGERS 15 (2015) THE LOCATION OF THE FIRST ASCENT IN A 123-AVOIDING PERMUTATION

You could identify a point on the graph of a function as (x,y) or (x, f(x)). You may have only one function value for each x number.

Common Core Math Tutorial and Practice

Lesson 1. Unit 4. Golden Ratio. Ratio

LUCAS-SIERPIŃSKI AND LUCAS-RIESEL NUMBERS

Transcription:

Application: AVL trees and the golden ratio AVL trees are used for storing information in an efficient manner. We will see exactly how in the data structures course. This slide set takes a look at how high an AVL tree of agivensizecanbe. The golden ratio Discrete Math. for Engineering,. Application slides Binary trees A binary tree is either The empty binary tree, for which I ll write Or a point (called a node) connected to two smaller binary trees (called its children) The children must not share any nodes. An empty binary tree The golden ratio is an irrational number φ = + =.68 with many interesting properties. Among them φ =/φ φ =+ + +... φ turns up in many geometric figures including pentagrams and dodecahedra It is the ratio, in the limit, of successive members of the Fibonacci sequence A nonempty binary tree Another nonempty binary tree Typeset October 3, Typeset October 3,

The height and size of a binary tree Discrete Math. for Engineering,. Application slides AVL trees The size of a binary tree is the number of nodes it has. The height of a binary tree is number of levels of nodes it has height is 3 AVL trees are binary trees with the following restrictions. TheemptytreeisanAVLtree A nonempty binary tree is AVL if the height difference of the children is at most, and both children are AVL trees size is Note that has height and size. Clearly a binary tree of size n canhaveaheightofupto n. AVL Not AVL Not AVL When binary trees are used to store data: The amount of information stored is proportional to size of tree The time to access data is proportional to the height Typeset October 3, 3 Typeset October 3,

The question We wish to access large amounts of data quickly. Remember amount of information is proportional to size of tree and access time is proportional to the height of the tree. SothequestionishowhighcananAVLtreeofagiven size be? We start by asking a closely related question: HowsmallcananAVLtreeofagivenheightbe? Discrete Math. for Engineering,. Application slides How small can an AVL tree of a given height be? Let smakeatablewiththesmallestavltreeofeach height (empty trees are implied) Height Smallest tree Size 3 7 Typeset October 3, Typeset October 3, 6

The minsize function In the table, each tree (of height h>) has, as children, smallest trees of heights h and h So we have minsize() = minsize() = minsize(h) = minsize(h ) + minsize(h ) +, forh Note the recurrence is not homogeneous. Try a few values,,,, 7,,, 33, Compare with the Fibonacci sequence,,, 3,, 8, 3,, 3, We find minsize(h) =fib(h +) where fib() = fib() = fib(n) =fib(n ) + fib(n ), forn We can prove this by (complete induction). Typeset October 3, 7 Discrete Math. for Engineering,. Application slides Since fib is defined by a linear homogeneous recurrence relationofdegreewecansolveit fib(n) = φ n+ ( for all n N where φ )n+ φ = + Consider φ n+ ( φ )n+ for n R and n. The first term is real, the second is complex. As n gets big, the complex term becomes small. So we get minsize(h) = φ h+ 8 size 6 minsize(h) dots 3 height φ h+ line Typeset October 3, 8

The maximum height per given size Discrete Math. for Engineering,. Application slides So invert φ h+ Height 3 Min size 7 Let h be the height of a tree of size s. We know that for all h, h h s minsize(h) Contrapositively: For all h, s < minsize(h) h <h Size 3 6 7 8 9 3 Max height 3 3 3 Note that for s such that minsize(h ) <s minsize(h) maxheight(s) =h maxheight(s) is approximately an inverse of minsize(h) s = φ h+ (s +)=φ h+ log φ (s +)=h + log φ (s +) =h log φ log (s +)+log φ =h so maxheight(s) =. log (s +).3 For example maxheight( 6 ) = 9 maxheight( 9 ) = 3 maxheight( ) = 8 This means large amounts of data can be accessed in a small amount of time, if we store the data in AVL trees. Typeset October 3, 9 Typeset October 3,

Graphing maxheight 6 h3 6 8 6 8 s maxheight(s) dots. log (s +).3 line Typeset October 3,