Cse 373 April 12th – TreEs.

Slides:



Advertisements
Similar presentations
More on Randomized Data Structures. Motivation for Randomized Data Structures We’ve seen many data structures with good average case performance on random.
Advertisements

Chapter 4: Trees Binary Search Trees
Sorting with Heaps Observation: Removal of the largest item from a heap can be performed in O(log n) time Another observation: Nodes are removed in order.
Lec 15 Oct 18 Binary Search Trees (Chapter 5 of text)
David Stotts Computer Science Department UNC Chapel Hill.
CSE373: Data Structures & Algorithms Lecture 6: Priority Queues Kevin Quinn Fall 2015.
FALL 2005CENG 213 Data Structures1 Review. FALL 2005CENG 213 Data Structures2 Collection of items Problems that must manage data by value. Some important.
Priority Queues and Heaps Tom Przybylinski. Maps ● We have (key,value) pairs, called entries ● We want to store and find/remove arbitrary entries (random.
CSE373: Data Structures & Algorithms Priority Queues
CSC317 Selection problem q p r Randomized‐Select(A,p,r,i)
May 26th –non-comparison sorting
CSCE 3110 Data Structures & Algorithm Analysis
October 2nd – Dictionary ADT
May 17th – Comparison Sorts
April 19th – Avl Operations
Searching – Linear and Binary Searches
Midterm Review.
March 27 – Course introductions; Adts; Stacks and Queues
BST Trees
Lecture 15 AVL Trees Slides modified from © 2010 Goodrich, Tamassia & by Prof. Naveen Garg’s Lectures.
Binary Search Trees.
Week 6 - Wednesday CS221.
October 20th – Hashing Conclusion + memory Analysis
Introduction to Algorithms
Cse 373 April 24th – Hashing.
CSE373: Data Structures & Algorithms Lecture 7: AVL Trees
Cse 373 May 15th – Iterators.
October 30th – Priority QUeues
Trees Lecture 12 CS2110 – Fall 2017.
Binary Search Tree Chapter 10.
Cse 373 April 14th – TreEs pt 2.
Source: Muangsin / Weiss
March 31 – Priority Queues and the heap
September 27 – Course introductions; Adts; Stacks and Queues
Cse 373 April 26th – Exam Review.
Dynamic Dictionaries Primary Operations: Additional operations:
Binary Search Trees Why this is a useful data structure. Terminology
CSE373: Data Structures & Algorithms Lecture 7: AVL Trees
Bit Vector Linked List (Sorted and Unsorted) Hash Table Search Trees
Welcome to IT 516! Data Structures & Algorithms Review of Linked Lists Parallel ordered arrays Binary Search Trees Tom Becker Summerr 2018 Lecture 7.
Trees Lecture 12 CS2110 – Spring 2018.
CSE373: Data Structures & Algorithms Lecture 6: Binary Search Trees
CSE 326: Data Structures: Midterm Review
Lec 12 March 9, 11 Mid-term # 1 (March 21?)
Instructor: Lilian de Greef Quarter: Summer 2017
CMSC 341 Lecture 14 Priority Queues & Heaps
Data Structures and Algorithms
B-Tree Insertions, Intro to Heaps
CSE 332: Data Abstractions Binary Search Trees
CSE 373 Data Structures and Algorithms
Implementing Hash and AVL
Priority Queues (Chapter 6.6):
CSE 332: Data Abstractions AVL Trees
Binary Trees: Motivation
Data Structures and Algorithms
Hashing Sections 10.2 – 10.3 Lecture 26 CS302 Data Structures
Definition Applications Implementations Heap Comparison
Amortized Analysis and Heaps Intro
Richard Anderson Spring 2016
Priority Queues (Chapter 6):
Data Structures and Algorithms
CSCE 3110 Data Structures & Algorithm Analysis
CSCE 3110 Data Structures & Algorithm Analysis
CSCE 3110 Data Structures & Algorithm Analysis
Data Structures for Shaping and Scheduling
CSE 373 Data Structures Lecture 12
CO4301 – Advanced Games Development Week 12 Using Trees
CSE 326: Data Structures Lecture #14
More on Randomized Data Structures
Presentation transcript:

Cse 373 April 12th – TreEs

Assorted minutiae HW2 due tonight Wrong submissions Static functions for your test cases HW3 out tonight Dictionaries – LL, Array, BST Empirical testing Regrade system up by Friday

Lecture Style Too fast More time-in-class examples Lots of material to cover, but it isn’t doing any good if no one understands Too mathy A bit tougher, abstract concepts are the most important part of the course More physical examples

Today Review of Dictionaries BSTs as dictionaries Analysis of BSTs Tree traversals

Dictionary Data is inserted in <Key,Value> pairs. Keys must be comparable Implements three functions: Insert (key, value) Find (key) Delete (key) Monday, we discussed 4 implementations

Implementations Simple implementations Unsorted linked-list insert find delete Unsorted linked-list Unsorted array Sorted linked list Sorted array * Unless we need to check for duplicates Simple implementations O(1)* O(n) O(n) O(1)* O(n) O(n) O(n) O(n) O(n) O(n) O(log n) O(n)

Implementations Other implementations? Binary Search Tree (BST) Sort based on keys (which have to be comparable) How do we implement this? What changes need to be made? Discuss how your 143 BST is different from a dictionary BST Consider particularly how the BST Node changes

Implementations BST Node: Before: Now? Node left Node right Value data Key k Value v

Implementations BST Changes: Insert(), find() and remove() remain similar Key is the primary comparison Value is attached to the key Dictionary fact: All values have an associated key For now, assume all keys are unique, i.e. each key only has one value

Implementations BST Analysis: What is our time for the three functions? Insert()? Delete()? Find()? Take 5 minutes to discuss Consider average and worst-case. What are the inputs for average and worst-case?

Implementations BST Analysis: Insert(): Worst case: O(n) Average case: O(height) What is “average” data? Best case: O(log n)

Average case Interesting concept Average to the user? Average among all possible inputs? Random data trials Produce random test cases and observe the result Timer?

Average case Timing cases Advantages and disadvantages + Actual runtime performance - Can be skewed + Easy to implement - Difficult to ascertain asymptotic growth

Average case HW3 will have you do timing cases Many runs will reduce hardware uncertainty Running at many sizes will make trends more apparent Demonstrate some real implementation behavior

Binary Search Tree Back to BST How do we test average case for a dictionary? We want varied input, without repititions One solution: Create a bunch of keys in a range Select without replacement Add into the dictionary “Shape” of a dictionary is determined by insert() order, so ordering is critical.

Intro for Next Week Tree traversals How do we search through a tree? Multiple ways? What if it isn’t a search tree?

Intro for Next Week

Intro for Next Week

Intro for Next Week If we have search!

Intro for Next Week If we have search!

Intro for Next Week What if we don’t? Say it’s a heap

Intro for Next Week

Intro for Next Week

Intro for Next Week

Intro for Next Week

Intro for Next Week Possible to interrupt early

Intro for Next Week

Intro for Next Week

Intro for Next Week Any other ways?

Intro for Next Week Any other ways?

Intro for Next Week Any other ways?

Intro for Next Week Any other ways?

Intro for Next Week Any other ways?

Intro for Next Week Any other ways?

Intro for Next Week Any other ways?

Intro for Next Week Any other ways?

Intro for Next Week Any other ways?

Intro for Next Week Any other ways?

Intro for Next Week Any other ways?

Intro for Next Week Any other ways?