CS 310: Maps and Sets and Trees
|
|
- Miles Allen
- 6 years ago
- Views:
Transcription
1 CS 310: Maps and Sets and Trees Chris Kauman Week 8-2
2 Logistics Oce hours Wednesday normal: 4:30-5:30pm Thursday 2-3pm special oce hours Reading Weiss Ch. 6 (Java Library Classes/Interfaces) 6.7 Sets, 6.8 Maps Weiss Ch 18 (Trees) Ch 18.4: - Iterator classes for traversals Reading: Weiss Ch 19 Binary Search Trees Today Maps and Sets General Trees and Traversals
3 Map and Set Map: TreeMap and HashMap (key,value) pairs Insert value into a map according to its key Retrieve value using same key Same for removal Same key maps to same "place" in the data structure Set TreeSet and HashSet Maps where key is value Insert into set using value itself as key Retrieve using value itself as key Same for removal Same value maps to same "place" in data structure
4 Have Set, Build Map Sets and Maps share much functionality. Q: If I have Set, how would I build Map? Given: SimpleSet Build: SimpleMap Collection of distinct objects Can only contain one of each thing Uniqueness determined by equals() method Operations add(x), get(x), remove(x), contains(x) ArraySet implements SimpleSet Set of (key,value) pairs Compare pairs only on whether their key is equal (a,x) == (a,x) (a,x) == (a,y) (a,x)!= (b,y) (a,x)!= (b,x) Use the set to ensure no redundant keys enter Implement put(k,v), get(k), remove(k), contains(k)
5 Trick 1: Use an internal class public class MapFromSet<K, V>{ // Trick: Use a nested class // Class to carry around (key,val) pairs public static class KeyVal<K, V>{ public K key; public V value; public KeyVal(K key, V value){ this.key = key; this.value = value; } // Required for any set to work // Compare only based on key public boolean equals(object o); // Required for HashSet to work right public int hashcode(); // Required for TreeSet to work public int compareto(keyval<k,v> kv); }
6 Trick 2: Use a set of the key/val pairs public interface SimpleSet<T> { boolean contains(t x); boolean add(t x); boolean remove(t x); T get(t x); } public class MapFromSet<K, V>{ public static class KeyVal<K, V>{...} // Trick: Given a working Set class: use it! private SimpleSet< KeyVal<K,V> > theset; // Implement these using theset public MapFromSet(); public void put(k key, V value); public void remove(k key); public boolean contains(k key); public V get(k key); }
7 Have Map, Build Set A great exam question: build a Set from a Map Map TreeMap and HashMap (key,value) pairs Each key has exactly one value Insert value into a map according to its key Same key maps to same "place" in the data structure Supports put(k,v), remove(k), contains(k) Set TreeSet and HashSet Use an internal Map Dene Set operations void add(t x) void remove(t x) T get(t x) boolean contains(t x)
8 Java Does it In Java: Map Set java.util.treemap is a red-black tree java.util.treeset uses a TreeMap java.util.hashmap is a separate chained hash table java.util.hashset uses a HashMap In Weiss: Set Map weiss.util.treeset is an AA-tree (another balanced tree) weiss.util.treemap uses TreeSet Lesson Re-use when it makes sense Think hard about when it makes sense to re-use
9 Ordering List property There is a well dened ordering of rst, next, last objects in the data structure A property of the Data Structure being used Wide ranging uses Supported structurally in LinkedList, ArrayList Not supported in hash tables (why not?) Sorting property There is a well dened ordering relation over all possible data of a particular type A property of the Data being stored "bigger than" "less than" "equal to" are well dened A data structure can try to mirror the data ordering structurally Useful for searching, walking through stored data in order
10 Sorted Lists Denition is straight-forward "Smallest" things are structurally "rst", "Biggest" last Ordering on elements (Comparable/Comparator) add/insert put elements in proper place Question: For a sorted List L, what is the complexity of L.insert(x) which preserves sorting? L is an ArrayList How long to nd insertion location? complete insertion? traverse elements in order (e.g. for printing)? L is a LinkedList How long to nd insertion location? complete insertion? traverse elements in order (e.g. for printing)?
11 Alternatives Hash Tables Abandon list property Abandon sorting property O(1) insertion/retrieval O(N) traversal, not ordered Trees Abandon list property Preserve sorting property O(log N) insertion/retrieval O(N) traversal, ordered Commonly Binary Trees Other variants
12 Roots Next the 2 weeks we'll talk about roots For simplicity, we'll call them trees Source
13 Mutated Nodes Node Data Next (???) (node) Data 5 data Binary Tree Node Left Right next Linked Nodes aka Tree 8 Linked Nodes, aka List 22 data root 31 next data 20 next Node structures should be familiar for linked lists Singly linked: next/data Doubly linked: next/previous/data Trees use Nodes as well children, data, possibly parent Arbitrary Trees: List<Node> of children Binary Trees: left and right children
14 Tree Properties of Interest Root of tree Leaves Data at nodes Size (number of nodes) Height of tree Depth of a node
15 The Many Ways to Walk No list property: several orders to traverse tree (a) Pre-order traversal (parent, left, right) (b) Post-order traversal (left, right, parent) (c) In-order traversal (left, parent, right)
16 Next Time Binary Search Trees insert/remove findmin/findmax Order statistics Start start discussing balance Read Weiss Ch. 6 (Java Library Classes/Interfaces) 6.7 Sets, 6.8 Maps Weiss Ch 18 (Trees) Ch 18.4: - Iterator classes for traversals Reading: Weiss Ch 19 Binary Search Trees
CS 310: Maps and Sets
CS 310: Maps and Sets Chris Kauffman Week 9-1 Logistics Goals Today HW2 Discussion Maps and Sets HW2 Discussion Milestones due Thu 7/6 Discuss AdditiveList Iterator Implementation O(1) Undo/Redo Reading
More informationCS 310: Hash Table Collision Resolution Strategies
CS 310: Hash Table Collision Resolution Strategies Chris Kauffman Week 7-1 Logistics HW 2 Due Wednesday night Test Cases Final Questions for group discussion? Goals Today Midterm Exam Next Monday Review
More informationProgramming 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 informationNAME: c. (true or false) The median is always stored at the root of a binary search tree.
EE 322C Spring 2009 (Chase) Exam 2: READ THIS FIRST. Please use the back side of each page for scratch paper. For some of the questions you may need to think quite a bit before you write down an answer.
More informationCS 310: Hash Table Collision Resolution
CS 310: Hash Table Collision Resolution Chris Kauffman Week 7-1 Logistics Reading Weiss Ch 20: Hash Table Weiss Ch 6.7-8: Maps/Sets Goals Today Hash Functions Separate Chaining In Hash Tables Upcoming
More informationCS 310: Hash Table Collision Resolution
CS 310: Hash Table Collision Resolution Chris Kauffman Week 8-1 Logistics Reading Weiss Ch 20: Hash Table Weiss Ch 6.7-8: Maps/Sets Homework HW 1 Due Saturday Discuss HW 2 next week Questions? Schedule
More informationEXAMINATIONS 2016 TRIMESTER 2
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2016 TRIMESTER 2 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS
More informationAnnouncements HEAPS & PRIORITY QUEUES. Abstract vs concrete data structures. Concrete data structures. Abstract data structures
Announcements A due TOMORROW. Late deadline is Sunday. A5 released. Due next Thursday. Deadline for Prelim 1 regrade requests is tomorrow. Remember to complete your TA evaluations by tonight. HEAPS & PRIORITY
More informationHEAPS & PRIORITY QUEUES
HEAPS & PRIORITY QUEUES Lecture 13 CS2110 Spring 2018 Announcements 2 A4 goes out today! Prelim 1: regrades are open a few rubrics have changed No Recitations next week (Fall Break Mon & Tue) We ll spend
More informationEXAMINATIONS 2015 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS
T E W H A R E W Ā N A N G A O T E Student ID:....................... Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2015 TRIMESTER 2 COMP103 INTRODUCTION
More information13 A: External Algorithms II; Disjoint Sets; Java API Support
13 A: External Algorithms II; ; Java API Support Martin Henz April 15, 2009 Generated on Friday 13 17 A: th External April, 2009, Algorithms 12:37 II; ; Java API Support 1 1 External Sorting 2 3 4 13 A:
More informationDIT960 Datastrukturer
DIT960 Datastrukturer suggested solutions for exam 2017-08-17 1. Assume that n is a non-negative integer, that s is an integer set implemented with a hash table and containing at most n elements, that
More informationModel Solutions. COMP 103: Test May, 2013
Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Instructions Time allowed: 45 minutes
More informationCSC 321: Data Structures. Fall 2016
CSC 321: Data Structures Fall 2016 Balanced and other trees balanced BSTs: AVL trees, red-black trees TreeSet & TreeMap implementations heaps priority queue implementation heap sort 1 Balancing trees recall:
More informationCSC 321: Data Structures. Fall 2017
CSC 321: Data Structures Fall 2017 Balanced and other trees balanced BSTs: AVL trees, red-black trees TreeSet & TreeMap implementations heaps priority queue implementation heap sort 1 Balancing trees recall:
More informationAP Computer Science 4325
4325 Instructional Unit Algorithm Design Techniques -divide-and-conquer The students will be -Decide whether an algorithm -classroom discussion -backtracking able to classify uses divide-and-conquer, -worksheets
More informationClass 32: The Java Collections Framework
Introduction to Computation and Problem Solving Class 32: The Java Collections Framework Prof. Steven R. Lerman and Dr. V. Judson Harward Goals To introduce you to the data structure classes that come
More informationModel Solutions. COMP 103: Mid-term Test. 19th of August, 2016
Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Instructions Time allowed: 45 minutes
More informationLecture 13: AVL Trees and Binary Heaps
Data Structures Brett Bernstein Lecture 13: AVL Trees and Binary Heaps Review Exercises 1. ( ) Interview question: Given an array show how to shue it randomly so that any possible reordering is equally
More informationAnnouncements. Hash Functions. Hash Functions 4/17/18 HASHING
Announcements Submit Prelim conflicts by tomorrow night A7 Due FRIDAY A8 will be released on Thursday HASHING CS110 Spring 018 Hash Functions Hash Functions 1 0 4 1 Requirements: 1) deterministic ) return
More informationBinary Trees
Binary Trees 4-7-2005 Opening Discussion What did we talk about last class? Do you have any code to show? Do you have any questions about the assignment? What is a Tree? You are all familiar with what
More informationTrees in java.util. A set is an object that stores unique elements In Java, two implementations are available:
Trees in java.util A set is an object that stores unique elements In Java, two implementations are available: The class HashSet implements the set with a hash table and a hash function The class TreeSet,
More informationEXAMINATIONS 2012 MID YEAR. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2012 MID YEAR COMP103 Introduction to Data
More informationCollections (Java) Collections Framework
Collections (Java) https://docs.oracle.com/javase/tutorial/collections/index.html Collection an object that groups multiple elements into a single unit. o store o retrieve o manipulate o communicate o
More informationEXAMINATIONS 2017 TRIMESTER 2
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW VICTORIA U N I V E R S I T Y O F W E L L I N G T O N EXAMINATIONS 2017 TRIMESTER 2 COMP103 INTRODUCTION TO DATA STRUCTURES AND ALGORITHMS
More informationTaking Stock. IE170: Algorithms in Systems Engineering: Lecture 7. (A subset of) the Collections Interface. The Java Collections Interfaces
Taking Stock IE170: Algorithms in Systems Engineering: Lecture 7 Jeff Linderoth Department of Industrial and Systems Engineering Lehigh University January 29, 2007 Last Time Practice Some Sorting Algs
More informationAnnouncements. Submit Prelim 2 conflicts by Thursday night A6 is due Nov 7 (tomorrow!)
HASHING CS2110 Announcements 2 Submit Prelim 2 conflicts by Thursday night A6 is due Nov 7 (tomorrow!) Ideal Data Structure 3 Data Structure add(val x) get(int i) contains(val x) ArrayList 2 1 3 0!(#)!(1)!(#)
More information! Tree: set of nodes and directed edges. ! Parent: source node of directed edge. ! Child: terminal node of directed edge
Trees (& Heaps) Week 12 Gaddis: 20 Weiss: 21.1-3 CS 5301 Spring 2015 Jill Seaman 1 Tree: non-recursive definition! Tree: set of nodes and directed edges - root: one node is distinguished as the root -
More informationData 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 informationPrelim 2. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer
Prelim 2 CS 2110, November 20, 2014, 7:30 PM 1 2 3 4 5 Extra Total Question True/False Short Answer Complexity Induction Trees Graphs Extra Credit Max 20 10 15 25 30 5 100 Score Grader The exam is closed
More informationSamples of Evidence to Satisfy the AP Computer Science AB Curricular Requirements
Samples of Evidence to Satisfy the AP Computer Science AB Curricular Requirements What s here? This table presents samples of evidence that address the curricular requirements for AP Computer Science AB.
More informationINTRODUCTION TO DATA AND PROCEDURE
INTRODUCTION TO DATA AND PROCEDURE In this book, our goal is to understand computation. In particular, we want to be able to take any computational problem and produce a technique for solving it that is
More informationSchool of Computing and Information Sciences. Course Title: Data Structures Date: 3/30/2010 Course Number: COP 3530 Number of Credits: 3
Course Title: Date: 3/30/2010 Course Number: Number of Credits: 3 Subject Area: Programming Subject Area Coordinator: Tim Downey email: downeyt@cis.fiu.edu Catalog Description: Basic concepts of data organization,
More informationPoints off Total off Net Score. CS 314 Final Exam Spring 2017
Points off 1 2 3 4 5 6 Total off Net Score CS 314 Final Exam Spring 2017 Your Name Your UTEID Instructions: 1. There are 6 questions on this test. 100 points available. Scores will be scaled to 300 points.
More informationCSC 421: Algorithm Design Analysis. Spring 2013
CSC 421: Algorithm Design Analysis Spring 2013 Transform & conquer transform-and-conquer approach presorting balanced search trees, heaps Horner's Rule problem reduction 1 Transform & conquer the idea
More informationModel Solutions. COMP 103: Test April, 2013
Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Instructions Time allowed: 40 minutes
More informationTREES Lecture 12 CS2110 Spring 2018
TREES Lecture 12 CS2110 Spring 2018 Important Announcements 2 A4 is out now and due two weeks from today. Have fun, and start early! Data Structures 3 There are different ways of storing data, called data
More informationAnnouncements. Container structures so far. IntSet ADT interface. Sets. Today s topic: Hashing (Ch. 10) Next topic: Graphs. Break around 11:45am
Announcements Today s topic: Hashing (Ch. 10) Next topic: Graphs Break around 11:45am Container structures so far Array lists O(1) access O(n) insertion/deletion (average case), better at end Linked lists
More informationJava Collections. Readings and References. Collections Framework. Java 2 Collections. CSE 403, Spring 2004 Software Engineering
Readings and References Java Collections "Collections", Java tutorial http://java.sun.com/docs/books/tutorial/collections/index.html CSE 403, Spring 2004 Software Engineering http://www.cs.washington.edu/education/courses/403/04sp/
More informationEXAMINATIONS 2011 Trimester 2, MID-TERM TEST. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2011 Trimester 2, MID-TERM TEST COMP103 Introduction
More informationCS61BL Summer 2013 Midterm 2
CS61BL Summer 2013 Midterm 2 Sample Solutions + Common Mistakes Question 0: Each of the following cost you.5 on this problem: you earned some credit on a problem and did not put your five digit on the
More informationAnnouncements. Today s topic: Hashing (Ch. 10) Next topic: Graphs. Break around 11:45am
Announcements Today s topic: Hashing (Ch. 10) Next topic: Graphs Break around 11:45am 1 Container structures so far Array lists O(1) access O(n) insertion/deletion (average case), better at end Linked
More information1B1b Implementing Data Structures Lists, Hash Tables and Trees
1B1b Implementing Data Structures Lists, Hash Tables and Trees Agenda Classes and abstract data types. Containers. Iteration. Lists Hash Tables Trees Note here we only deal with the implementation of data
More informationChapter 5 Java Collection. Wang Yang
Chapter 5 Java Collection Wang Yang wyang@njnet.edu.cn Outline Last Chapter Review Array & Arrays Tourism Collection & Collections Map Performance benchmark Last Chapter Review Exception Exception is an
More informationFall 2017 Mentoring 9: October 23, Min-Heapify This. Level order, bubbling up. Level order, bubbling down. Reverse level order, bubbling up
CSM B Heaps & Hashing Fall 0 Mentoring : October 3, 0 Min-Heapify This. In general, there are 4 ways to heapify. Which ways actually work? Level order, bubbling up Level order, bubbling down Reverse level
More informationCISC 3130 Data Structures Fall 2018
CISC 3130 Data Structures Fall 2018 Instructor: Ari Mermelstein Email address for questions: mermelstein AT sci DOT brooklyn DOT cuny DOT edu Email address for homework submissions: mermelstein DOT homework
More informationSOLUTIONS. COMP103 Introduction to Data Structures and Algorithms
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2011 MID YEAR COMP103 Introduction to Data
More informationInterfaces and Collections
Interfaces and Collections COMPSCI 2S03 Mikhail Andrenkov Department of Computing and Software McMaster University Week 9: November 14-18 Mikhail Andrenkov Interfaces and Collections 1 / 25 Outline 1 Interfaces
More informationData Structures. Giri Narasimhan Office: ECS 254A Phone: x-3748
Data Structures Giri Narasimhan Office: ECS 254A Phone: x-3748 giri@cs.fiu.edu Search Tree Structures Binary Tree Operations u Tree Traversals u Search O(n) calls to visit() Why? Every recursive has one
More informationPoints off Total off Net Score. CS 314 Final Exam Spring Your Name Your UTEID
Points off 1 2 3 4 5 6 Total off Net Score CS 314 Final Exam Spring 2018 Your Name Your UTEID Instructions: 1. There are 6 questions on this test. 100 points available. Scores will be scaled to 300 points.
More informationCS 314 Exam 2 Fall 2017
Points off 1 2 3 4 5 Total off CS 314 Exam 2 Fall 2017 Your Name Your UTEID Circle your TAs Name: Gilbert Jacob Jorge Joseph Lucas Rebecca Shelby Instructions: 1. There are 5 questions on this test. 100
More informationJava Collections Framework reloaded
Java Collections Framework reloaded October 1, 2004 Java Collections - 2004-10-01 p. 1/23 Outline Interfaces Implementations Ordering Java 1.5 Java Collections - 2004-10-01 p. 2/23 Components Interfaces:
More informationCS 314 Exam 2 Spring 2018
Points off 1 2 3 4 5 Total off CS 314 Exam 2 Spring 2018 Your Name Your UTEID Circle your TA's Name: Aish Anthony Chris Dayanny Hailey Ivan Jacob Joseph Lucas Shelby Instructions: 1. There are 5 questions
More informationTrees. Chapter 6. strings. 3 Both position and Enumerator are similar in concept to C++ iterators, although the details are quite different.
Chapter 6 Trees In a hash table, the items are not stored in any particular order in the table. This is fine for implementing Sets and Maps, since for those abstract data types, the only thing that matters
More information! Tree: set of nodes and directed edges. ! Parent: source node of directed edge. ! Child: terminal node of directed edge
Trees & Heaps Week 12 Gaddis: 20 Weiss: 21.1-3 CS 5301 Fall 2018 Jill Seaman!1 Tree: non-recursive definition! Tree: set of nodes and directed edges - root: one node is distinguished as the root - Every
More information27/04/2012. Objectives. Collection. Collections Framework. "Collection" Interface. Collection algorithm. Legacy collection
Objectives Collection Collections Framework Concrete collections Collection algorithm By Võ Văn Hải Faculty of Information Technologies Summer 2012 Legacy collection 1 2 2/27 Collections Framework "Collection"
More informationBinary Search Trees (10.1) Dictionary ADT (9.5.1)
Binary Search Trees (10.1) CSE 011 Winter 011 4 March 011 1 Dictionary ADT (..1) The dictionary ADT models a searchable collection of keyelement items The main operations of a dictionary are searching,
More informationEXAMINATIONS 2010 END YEAR. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2010 END YEAR COMP103 Introduction to Data
More informationSUMMARY INTRODUCTION COLLECTIONS FRAMEWORK. Introduction Collections and iterators Linked list Array list Hash set Tree set Maps Collections framework
SUMMARY COLLECTIONS FRAMEWORK PROGRAMMAZIONE CONCORRENTE E DISTR. Università degli Studi di Padova Dipartimento di Matematica Corso di Laurea in Informatica, A.A. 2015 2016 Introduction Collections and
More informationThe class Object. Lecture CS1122 Summer 2008
The class Object http://www.javaworld.com/javaworld/jw-01-1999/jw-01-object.html Lecture 10 -- CS1122 Summer 2008 Review Object is at the top of every hierarchy. Every class in Java has an IS-A relationship
More informationJava Collections. Readings and References. Collections Framework. Java 2 Collections. References. CSE 403, Winter 2003 Software Engineering
Readings and References Java Collections References» "Collections", Java tutorial» http://java.sun.com/docs/books/tutorial/collections/index.html CSE 403, Winter 2003 Software Engineering http://www.cs.washington.edu/education/courses/403/03wi/
More informationCS 314 Final Fall 2012
Points off 1 2A 2B 2C 3 4A 4B 5 Total off Net Score CS 314 Final Fall 2012 Your Name_ Your UTEID Instructions: 1. There are 5 questions on this exam. The raw point total on the exam is 110. 2. You have
More informationCollections Questions
Collections Questions https://www.journaldev.com/1330/java-collections-interview-questions-and-answers https://www.baeldung.com/java-collections-interview-questions https://www.javatpoint.com/java-collections-interview-questions
More informationPoints off Total off Net Score. CS 314 Final Exam Fall 2016
Points off 1 2 3 4 5 6 Total off Net Score CS 314 Final Exam Fall 2016 Your Name Your UTEID Instructions: 1. There are 6 questions on this test. 100 points available. Scores will be scaled to 300 points.
More informationCS2110 Assignment 3 Inheritance and Trees, Summer 2008
CS2110 Assignment 3 Inheritance and Trees, Summer 2008 Due Sunday July 13, 2008, 6:00PM 0 Introduction 0.1 Goals This assignment will help you get comfortable with basic tree operations and algorithms.
More informationSets and Maps. Sets Maps The Comparator Interface Sets and Maps in Java Collections API. Review for Exam Reading:
Sets and Maps Sets Maps The Comparator Interface Sets and Maps in Java Collections API TreeSet TreeMap Review for Exam Reading: 13.1-13.6 Sets A set is a collection of elements with no duplicates We had
More informationTree: non-recursive definition. Trees, Binary Search Trees, and Heaps. Tree: recursive definition. Tree: example.
Trees, Binary Search Trees, and Heaps CS 5301 Fall 2013 Jill Seaman Tree: non-recursive definition Tree: set of nodes and directed edges - root: one node is distinguished as the root - Every node (except
More informationPrelim 2 Solutions. CS 2110, November 20, 2014, 7:30 PM Extra Total Question True/False Short Answer
Prelim 2 Solutions CS 2110, November 20, 2014, 7:30 PM 1 2 3 4 5 Extra Total Question True/False Short Answer Complexity Induction Trees Graphs Extra Credit Max 20 10 15 25 30 5 100 Score Grader The exam
More informationStandard ADTs. Lecture 19 CS2110 Summer 2009
Standard ADTs Lecture 19 CS2110 Summer 2009 Past Java Collections Framework How to use a few interfaces and implementations of abstract data types: Collection List Set Iterator Comparable Comparator 2
More informationCOMP-202: Foundations of Programming. Lecture 26: Image Manipulation; Wrap-Up Jackie Cheung, Winter 2015
COMP-202: Foundations of Programming Lecture 26: Image Manipulation; Wrap-Up Jackie Cheung, Winter 2015 Announcements Assignment 6 due Tue Apr 14 at 11:59pm Final is scheduled for Apr 29, 6pm 9pm Please
More informationAnnouncements. Midterm exam 2, Thursday, May 18. Today s topic: Binary trees (Ch. 8) Next topic: Priority queues and heaps. Break around 11:45am
Announcements Midterm exam 2, Thursday, May 18 Closed book/notes but one sheet of paper allowed Covers up to stacks and queues Today s topic: Binary trees (Ch. 8) Next topic: Priority queues and heaps
More informationSets and Maps. Part of the Collections Framework
Sets and Maps Part of the Collections Framework The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection int size( ); boolean isempty( ); boolean contains(object
More informationCIT-590 Final Exam. Name: Penn Key (Not ID number): If you write a number above, you will lose 1 point
1 CIT-590 Final Exam Name: Penn Key (Not ID number): If you write a number above, you will lose 1 point Instructions: You will have two hours to complete this exam. If you finish in the last 15 minutes,
More informationHash table basics mod 83 ate. ate
Hash table basics After today, you should be able to explain how hash tables perform insertion in amortized O(1) time given enough space ate hashcode() 82 83 84 48594983 mod 83 ate Topics: weeks 1-6 Reading,
More informationEXAMINATIONS 2011 END YEAR. COMP103 Introduction to Data Structures and Algorithms SOLUTIONS
T E W H A R E W Ā N A N G A O T E Ū P O K O O T E I K A A M Ā U I VUW V I C T O R I A UNIVERSITY OF WELLINGTON Student ID:....................... EXAMINATIONS 2011 END YEAR COMP103 Introduction to Data
More informationCOMP 103 : Test. 2019, Jan 9 ** WITH SOLUTIONS **
Family Name:.............................. Other Names:...................................... Signature.................................. COMP 103 : Test 2019, Jan 9 ** WITH SOLUTIONS ** Instructions Time
More informationFriday Four Square! 4:15PM, Outside Gates
Binary Search Trees Friday Four Square! 4:15PM, Outside Gates Implementing Set On Monday and Wednesday, we saw how to implement the Map and Lexicon, respectively. Let's now turn our attention to the Set.
More informationFamily Name:... Other Names:... ID Number:... Signature... Model Solutions. COMP 103: Test 1. 9th August, 2013
Family Name:............................. Other Names:............................. ID Number:............................... Signature.................................. Model Solutions COMP 103: Test
More informationTopic #9: Collections. Readings and References. Collections. Collection Interface. Java Collections CSE142 A-1
Topic #9: Collections CSE 413, Autumn 2004 Programming Languages http://www.cs.washington.edu/education/courses/413/04au/ If S is a subtype of T, what is S permitted to do with the methods of T? Typing
More informationAbstract Data Types Data Structure Grand Tour Java Collections.
Abstract Data Types Data Structure Grand Tour Java Collections http://gcc.gnu.org/onlinedocs/libstdc++/images/pbds_different_underlying_dss_1.png } Stacks and Queues Ideally, you have met with your partner
More informationToday: Java Library Classes for lists. Iterators, ListIterators. CS61B Lecture #7. Last modified: Fri Sep 12 14:41: CS61B: Lecture #7 1
Today: Java Library Classes for lists. Iterators, ListIterators CS61B Lecture #7 Last modified: Fri Sep 12 14:41:31 2008 CS61B: Lecture #7 1 Abstracting Listness So far, we ve seen fairly primitive types
More informationSummer Final Exam Review Session August 5, 2009
15-111 Summer 2 2009 Final Exam Review Session August 5, 2009 Exam Notes The exam is from 10:30 to 1:30 PM in Wean Hall 5419A. The exam will be primarily conceptual. The major emphasis is on understanding
More informationPoints off Total off Net Score. CS 314 Final Exam Spring 2016
Points off 1 2 3 4 5 6 Total off Net Score CS 314 Final Exam Spring 2016 Your Name Your UTEID Instructions: 1. There are 6 questions on this test. 100 points available. Scores will be scaled to 300 points.
More informationPriority Queues Heaps Heapsort
Priority Queues Heaps Heapsort After this lesson, you should be able to apply the binary heap insertion and deletion algorithms by hand implement the binary heap insertion and deletion algorithms explain
More informationData Structure. A way to store and organize data in order to support efficient insertions, queries, searches, updates, and deletions.
DATA STRUCTURES COMP 321 McGill University These slides are mainly compiled from the following resources. - Professor Jaehyun Park slides CS 97SI - Top-coder tutorials. - Programming Challenges book. Data
More informationCSE Data Structures and Introduction to Algorithms... In Java! Instructor: Fei Wang. Binary Search Trees. CSE2100 DS & Algorithms 1
CSE 2100 Data Structures and Introduction to Algorithms...! In Java!! Instructor: Fei Wang! Binary Search Trees 1 R-10.6, 10.7!!! Draw the 11-entry hash table that results from using the hash function
More informationAbstract vs concrete data structures HEAPS AND PRIORITY QUEUES. Abstract vs concrete data structures. Concrete Data Types. Concrete data structures
10/1/17 Abstract vs concrete data structures 2 Abstract data structures are interfaces they specify only interface (method names and specs) not implementation (method bodies, fields, ) HEAPS AND PRIORITY
More informationHierarchical data structures. Announcements. Motivation for trees. Tree overview
Announcements Midterm exam 2, Thursday, May 18 Closed book/notes but one sheet of paper allowed Covers up to stacks and queues Today s topic: Binary trees (Ch. 8) Next topic: Priority queues and heaps
More information1.00/1.001 Introduction to Computers and Engineering Problem Solving. Final Exam
1.00/1.001 Introduction to Computers and Engineering Problem Solving Final Exam Name: Email Address: TA: Section: You have three hours to complete this exam. For coding questions, you do not need to include
More informationCS Introduction to Data Structures Week 3, 2017
CS 367 - Introduction to Data Structures Week 3, 2017 Homework h1 graded. Email TA (di3@wisc.edu) by Friday, July 7th - 5 pm. Program 1 due July 11 th - 10 pm Homework h3 posted, complete as soon as possible;
More information17. Java Collections. Organizing Data. Generic List in Java: java.util.list. Type Parameters ( Parameteric Polymorphism ) Data Structures that we know
Organizing Data Data Structures that we know 17 Java Collections Generic Types, Iterators, Java Collections, Iterators Today: Arrays Fixed-size sequences Strings Sequences of characters Linked Lists (up
More informationSTANDARD ADTS Lecture 17 CS2110 Spring 2013
STANDARD ADTS Lecture 17 CS2110 Spring 2013 Abstract Data Types (ADTs) 2 A method for achieving abstraction for data structures and algorithms ADT = model + operations In Java, an interface corresponds
More informationToday's Agenda. > To give a practical introduction to data structures. > To look specifically at Lists, Sets, and Maps
Today's Agenda > To give a practical introduction to data structures > To look specifically at Lists, Sets, and Maps > To talk briefly about Generics in Java > To talk about interfaces in Java Data Structures
More informationLinked Lists. References and objects
Linked Lists slides created by Marty Stepp http://www.cs.washington.edu/143/ Modified by Sarah Heckman Reading: RS Chapter 16 References and objects In Java, objects and arrays use reference semantics.
More informationCollections, Maps and Generics
Collections API Collections, Maps and Generics You've already used ArrayList for exercises from the previous semester, but ArrayList is just one part of much larger Collections API that Java provides.
More informationAbstract Data Types (ADTs) Queues & Priority Queues. Sets. Dictionaries. Stacks 6/15/2011
CS/ENGRD 110 Object-Oriented Programming and Data Structures Spring 011 Thorsten Joachims Lecture 16: Standard ADTs Abstract Data Types (ADTs) A method for achieving abstraction for data structures and
More informationCONTAİNERS COLLECTİONS
CONTAİNERS Some programs create too many objects and deal with them. In such a program, it is not feasible to declare a separate variable to hold reference to each of these objects. The proper way of keeping
More informationCS 210 Algorithms and Data Structures College of Information Technology and Engineering Weisberg Division of Engineering and Computer Science
CS 210 Algorithms and Data Structures College of Information Technology and Engineering Weisberg Division of Engineering and Computer Science Semester and Year: Fall 2008 Classroom Section, Meeting Times,
More informationCS 314 Exam 2 Spring
Points off 1 2 3 4 5 Total off CS 314 Exam 2 Spring 2017 Your Name Your UTEID Instructions: 1. There are 5 questions on this test. 100 points available. Scores will be scaled to 200 points. 2. You have
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 10: Search and Heaps MOUNA KACEM mouna@cs.wisc.edu Spring 2018 Search and Heaps 2 Linear Search Binary Search Introduction to trees Priority Queues Heaps Linear Search
More information