ITEC 2620M Introduction to Data Structures Instructor: Prof. Z. Yang Course Website: http://people.math.yorku.ca/~zyang/itec2620m.htm Office: DB 3049
Complexity Estimation – recurrence relations
Key Points Estimation of recursive algorithms Basic Data Types I How many times? What does it cost? Basic Data Types I Stacks
Relating Complexity Estimation to Recurrence Relations “How many times?” is the number of recurrences – levels of recursion. “What does it cost?” is for an entire “level” of recursion. linear recursion What does this recursive call cost? binary recursion What do all recursive calls at this “level” cost?
Examples Factorial Binary search Mergesort Quicksort
Abstract Data Types A way to specify the functionality of an entity without worrying about its implementation List ADT interface SortedList { public void insert (Object item); public object remove (); public boolean isInList (); … }
Stacks A stack is a “Last-In, First-Out” = “LIFO” buffer. Only the top element of a stack is accessible. When elements are added, they are pushed onto the top When elements are removed, they are popped off the top push() and pop() are the two defining functions of a stack Example Array-based Stacks