Week 6 - Monday CS221.

Slides:



Advertisements
Similar presentations
Week 7 - Wednesday.  What did we talk about last time?  Recursive running time  Master Theorem  Introduction to trees.
Advertisements

Lists in Python.
CS212: DATA STRUCTURES Lecture 10:Hashing 1. Outline 2  Map Abstract Data type  Map Abstract Data type methods  What is hash  Hash tables  Bucket.
Lecture 10: Class Review Dr John Levine Algorithms and Complexity March 13th 2006.
Information and Computer Sciences University of Hawaii, Manoa
Week 6 - Wednesday.  What did we talk about last time?  Exam 1 post-mortem  Recursive running time.
Week 6 - Friday.  What did we talk about last time?  Recursive running time  Fast exponentiation  Merge sort  Introduced the Master theorem.
Week 3 – Wednesday.  What did we talk about last time?  ADTs  List implementation with a dynamic array.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Built-in Data Structures in Python An Introduction.
Week 8 - Wednesday.  What did we talk about last time?  Level order traversal  BST delete  2-3 trees.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Week 7 - Friday.  What did we talk about last time?  Trees in general  Binary search trees.
Week 10 - Friday.  What did we talk about last time?  Graph representations  Adjacency matrix  Adjacency lists  Depth first search.
Week 15 – Wednesday.  What did we talk about last time?  Review up to Exam 1.
April 27, 2017 COSC Data Structures I Review & Final Exam
Week 7 - Wednesday.  What did we talk about last time?  Recursive running time  Master Theorem  Symbol tables.
1 i206: Lecture 17: Exam 2 Prep ; Intro to Regular Expressions Marti Hearst Spring 2012.
Final Exam Review CS 3358.
Searching and Sorting Searching algorithms with simple arrays
CSE373: Data Structures & Algorithms Priority Queues
Sort & Search Algorithms
Week 7 - Friday CS221.
October 2nd – Dictionary ADT
Now with a speaking professor! (hopefully...)
CS 315 Data Structures B. Ravikumar Office: 116 I Darwin Hall Phone:
GC211Data Structure Lecture2 Sara Alhajjam.
Programming Abstractions
Lecture No.43 Data Structures Dr. Sohail Aslam.
Week 8 - Wednesday CS221.
UNIT III TREES.
Week 3 - Friday CS221.
Week 6 - Wednesday CS221.
Week 8 - Friday CS221.
Week 15 – Monday CS221.
October 30th – Priority QUeues
Week 11 - Friday CS221.
Hashing Exercises.
Binary Search Trees Why this is a useful data structure. Terminology
Map interface Empty() - return true if the map is empty; else return false Size() - return the number of elements in the map Find(key) - if there is an.
Road Map CS Concepts Data Structures Java Language Java Collections
structures and their relationships." - Linus Torvalds
structures and their relationships." - Linus Torvalds
Data Structures and Algorithms
Draw pictures to indicate the subproblems middleMax solves at each level and the resulting maxPtr and PrevPtr for each on this linked list:
A Kind of Binary Tree Usually Stored in an Array
B-Tree Insertions, Intro to Heaps
ITEC 2620M Introduction to Data Structures
Priority Queues.
CSE 373: Data Structures and Algorithms
8/04/2009 Many thanks to David Sun for some of the included slides!
Recitation Outline C++ STL associative containers Examples
CSE 373 Data Structures and Algorithms
CSE 373: Data Structures and Algorithms
Implementing Hash and AVL
Hash Tables Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common.
CS202 - Fundamental Structures of Computer Science II
Binary Search Trees Chapter 7 Objectives
Hash Tables Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common.
CSE 12 – Basic Data Structures
Priority Queues.
Priority Queues.
CSCE 3110 Data Structures & Algorithm Analysis
CSCE 3110 Data Structures & Algorithm Analysis
CSCE 3110 Data Structures & Algorithm Analysis
CO4301 – Advanced Games Development Week 12 Using Trees
structures and their relationships." - Linus Torvalds
Week 7 - Monday CS 121.
Week 9 - Monday CS222.
Presentation transcript:

Week 6 - Monday CS221

Last time What did we talk about last time? More recursion examples Recursive running time

Questions?

Assignment 3 Recursion

Project 2 Infix to Postfix Converter

Wittman's Guide to Quick Debugging a = b; a and b have to have the same type Exception: b is a subtype of a == is a comparison operator that produces a boolean, = is a left-pointing arrow if statements always have parentheses No semicolons after if or while headers (and rarely after for headers) The following is always wrong: x = y; x = z; Know your String methods A non-void method has to return something The new keyword is always followed by a type and either parentheses (possibly with arguments) or square brackets with integers inside Local variables cannot be declared private, public, or protected Don't use the name of the type for method arguments

Know your syntax By now, you should know your syntax inside and out If you don't know how something in Java works, find out! Syntax is your basic tool for everything Read about some syntax once? Doesn't help! Write some code to see it in practice! CS121 CS122 CS221 Syntax Problem Solving Design

Merge Sort

Merge Sort algorithm (recursive) Beautiful divide and conquer Base case: List has size 1 Recursive case: Divide your list in half Recursively merge sort each half Merge the two halves back together in sorted order

Let’s code that up… Great. Now, how long does it take?

Student Lecture: Symbol Tables

Symbol Tables

Symbol tables A symbol table goes by many names: Map Lookup table Dictionary The idea is a table that has a two columns, a key and a value You can store, lookup, and change the value based on the key

Example A symbol table can be applied to almost anything: The key doesn't have to be a String But it should be unique Key Value Spiderman Climbing and webs Wolverine Super healing Professor X Telepathy Human Torch Flames and flying Deadpool Mr. Fantastic Stretchiness Key Value 121 Programming I 122 Programming II 221 Data Structures and Algorithms 322 Formal methods 361 Computer Graphics 363 Computer Security

Symbol table ADT We can define a symbol table ADT with a few essential operations: put(Key key, Value value) Put the key-value pair into the table get(Key key): Retrieve the value associated with key delete(Key key) Remove the value associated with key contains(Key key) See if the table contains a key isEmpty() size() It's also useful to be able to iterate over all keys

Ordered symbol tables The idea of order in a symbol table is reasonable: You want to iterate over all the keys in some natural order Ordering can give certain kinds of data structures (like a binary search tree) a way to organize

Ordered symbol table ADT An ordered symbol table ADT adds the following operations to a regular symbol table ADT: Key min() Get the smallest key Key max() Get the biggest key void deleteMin() Remove the smallest key void deleteMax() Remove the largest key Other operations might be useful, like finding keys closest in value to a given key or counting the number of keys in a range between two keys

Implementations Like other ADTs, a symbol table can be implemented in a number of different ways: Linked list Sorted array Binary search tree Balanced binary search tree Hash table Note that a hash table cannot be used to implement an ordered symbol table And it's inefficient to use a linked list for ordered

Sorted array We know how to make a sorted array symbol table A search is Θ(log n) time, which is great! The trouble is that doing an insert takes Θ(n) time, because we have to move everything in the array around A sorted array is a reasonable model for a symbol table where you don't have to add or remove items

Trees Trees will allow us to make a sorted symbol table with the following miraculous properties: Θ(log n) get Θ(log n) put Θ(log n) delete Θ(n) traversal (iterating over everything) Unfortunately, only balanced binary search trees will give us this property We'll start this week with binary search trees and then built up to balanced ones

Upcoming

Next time… Binary search trees BST implementation Keep reading Chapter 3.1

Reminders Finish Assignment 3 Keep working on Project 2 Due Wednesday, October 4 Keep working on Project 2 Due Friday, October 13