CS 112 - Fall 2012, Lab 04 Haohan Zhu. Boston University Slideshow Title Goes Here CS 112 - Fall 2012, Lab 04 2 2/29/2016 Changes of Office Hours  Monday.

Slides:



Advertisements
Similar presentations
Introduction to Java 2 Programming Lecture 5 The Collections API.
Advertisements

Transparency No. 1 Java Collection API : Built-in Data Structures for Java.
Lists and the Collection Interface Chapter 4. Chapter Objectives To become familiar with the List interface To understand how to write an array-based.
ITEC200 Week04 Lists and the Collection Interface.
Processing Data in Collections Chapter Object Wrappers Collections can only hold objects. Primitive types ( int, double, float, etc.) are not objects.
Data Structures A data structure is a collection of data organized in some fashion that permits access to individual elements stored in the structure This.
Chapter 6 The Collections API. Simple Container/ Iterator Simple Container Shape [] v = new Shape[10]; Simple Iterator For( int i=0 ; i< v.length ; i++)
CS Fall 2012, Lab 08 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /17/2015 Tree - Data Structure  Basic.
CS Fall 2012, Lab 01 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /17/2015 Using Piazza 
Collections Framework A very brief look at Java’s Collection Framework David Davenport May 2010.
Collections Sets - no duplicates Lists - duplicates allowed Maps - key / value pairs A collection is an Object which contains other Objects. There are.
Java Collections Framework COMP53 Oct 24, Collections Framework A unified architecture for representing and manipulating collections Allows collections.
1 Generics, Type Safety, and Dynamic Data Structures.
Fall 2007CS 2251 Iterators and Tree Traversals. Fall 2007CS 2252 Binary Trees In a binary tree, each node has at most two subtrees A set of nodes T is.
1 L41 Collections (1). 2 OBJECTIVES  What collections are.  To use class Arrays for array manipulations.  To use the collections framework (prepackaged.
Lists and the Collection Interface Chapter 4. Chapter 4: Lists and the Collection Interface2 Chapter Objectives To become familiar with the List interface.
24-Jun-15 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
1 Data Structures  We can now explore some advanced techniques for organizing and managing information  Chapter 12 of the book focuses on: dynamic structures.
Fall 2007CS 2251 Lists and the Collection Interface Chapter 4.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved L15 (Chapter 22) Java Collections.
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 13: Queues and Vectors.
Liang, Introduction to Java Programming, Tenth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 20 Lists, Stacks, Queues, and Priority.
Chapter 19 Java Data Structures
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 22 Lists, Stacks, Queues, and Priority.
Java Collections. Collections, Iterators, Algorithms CollectionsIteratorsAlgorithms.
CSE373 Optional Section Java Collections 11/12/2013 Luyi Lu.
Java Collections Framework A presentation by Eric Fabricant.
Lists Based on content from: Java Foundations, 3rd Edition.
1 Java's Collection Framework By Rick Mercer with help from The Java Tutorial, The Collections Trail, by Joshua BlockThe Collections Trail.
Jan 12, 2012 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
111 © 2002, Cisco Systems, Inc. All rights reserved.
CS 46B: Introduction to Data Structures July 9 Class Meeting Department of Computer Science San Jose State University Summer 2015 Instructor: Ron Mak
Computer Science 209 Software Development Java Collections.
Data structures Abstract data types Java classes for Data structures and ADTs.
CSS446 Spring 2014 Nan Wang  Java Collection Framework ◦ LinkedList ◦ Set ◦ Map 2.
09-1 Queues and List-Based ADT Implementations Problem Set: PS3 due Wednesday, March 7 Wellesley College CS230 Lecture 09 Monday, February 26 Handout #18.
Data structures and algorithms in the collection framework 1.
Holding Your Objects Generics and type-safe containers One of the problems of using pre-Java SE5 containers was that the compiler allowed.
Collection 105 Yola. To store data in RAM Variables (name all the types with their length) Arrays (one, two or more) Collections and Maps.
CS-2852 Data Structures LECTURE 7A Andrew J. Wozniewicz Image copyright © 2010 andyjphoto.com.
CS Fall 2012, Lab 09 Haohan Zhu. Boston University Slideshow Title Goes Here CS Fall 2012, Lab /20/2015 GUI - Graphical User Interface.
COP INTERMEDIATE JAVA Data Structures. A data structure is a way of organizing a collection of data so that it can be manipulated effectively. A.
Chapter 12: Collections by Lewis and Loftus (Updated by Dan Fleck) Coming up: Collections.
2013-T2 Lecture 18 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae, and John.
CS-2852 Data Structures Week 5, Class 2 – Testing and Stacks Announcement: Lab Demos - 2/3 & 4 on Friday Testing  Definitions, Example  (tentative) Testing.
1 Interfaces in Java’s Collection Framework Rick Mercer.
Collections Data structures in Java. OBJECTIVE “ WHEN TO USE WHICH DATA STRUCTURE ” D e b u g.
CSC 212 Sequences & Iterators. Announcements Midterm in one week  Will cover through chapter 5 of book  Midterm will be open book, open note (but, closed.
Recitation 5 Enums and The Java Collections classes/interfaces 1.
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
List Interface and Linked List Mrs. Furman March 25, 2010.
Priority Queues. Priority Queue ADT A priority queue stores a collection of entries Each entry is a pair (key, value) Main methods of the Priority Queue.
1 Java's Collection Framework Map and Sets. 2 Collection Framework  A collections framework is a unified architecture for representing and manipulating.
Topic 13 Iterators. 9-2 Motivation We often want to access every item in a data structure or collection in turn We call this traversing or iterating over.
2015-T2 Lecture 19 School of Engineering and Computer Science, Victoria University of Wellington  Marcus Frean, Lindsay Groves, Peter Andreae, and John.
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
CS202 Java Object Oriented Programming Introduction to Collection Classes Chengyu Sun California State University, Los Angeles.
Introduction to Java Collection. Java Collections What are they? –A number of pre-packaged implementations of common ‘container’ classes, such as LinkedLists,
Lists and the Collection Interface Chapter 4. Chapter 4: Lists and the Collection Interface2 Chapter Objectives To become familiar with the List interface.
G64ADS Advanced Data Structures
CS Fall 2012, Lab 02 Haohan Zhu.
Chapter 20 Lists, Stacks, Queues, and Priority Queues
Road Map CS Concepts Data Structures Java Language Java Collections
Chapter 12 Collections.
Chapter 20 Lists, Stacks, Queues, and Priority Queues
Chapter 12 Collections.
Road Map CS Concepts Data Structures Java Language Java Collections
CS 240 – Advanced Programming Concepts
Chapter 20 Lists, Stacks, Queues, and Priority Queues
Presentation transcript:

CS Fall 2012, Lab 04 Haohan Zhu

Boston University Slideshow Title Goes Here CS Fall 2012, Lab /29/2016 Changes of Office Hours  Monday. 5-6:30 p.m.  Tuesday. 5-6:30 p.m.  Wednesday. 3-4:30 p.m.

Boston University Slideshow Title Goes Here CS Fall 2012, Lab /29/2016 Arrays  An array is a container object that holds a fixed number of values of a single type.  The length of an array is established when the array is created. After creation, its length is fixed.

Boston University Slideshow Title Goes Here CS Fall 2012, Lab /29/2016 Data Structure from the lectures  BagsNot in Java API  Can contain duplicate elements  QueuesInterface in Java API as Queue  FIFO  StacksClass in Java API as Stack  LIFOImplementation of List  Linked listsClass in Java API as LinkedList  Implementation of List

Boston University Slideshow Title Goes Here CS Fall 2012, Lab /29/2016 Java Collection  CollectionInterface & Class (as Collections)  Set (not Bag)Interface  Cannot contain duplicate elements  QueueInterface  FIFO  ListInterface & Class (as List)  Can contain duplicate elements, ordered

Boston University Slideshow Title Goes Here CS Fall 2012, Lab /29/2016 Implementation of Set  Set   HashSet 

Boston University Slideshow Title Goes Here CS Fall 2012, Lab /29/2016 Implementation of Queue  Queue   PriorityQueue  l l

Boston University Slideshow Title Goes Here CS Fall 2012, Lab /29/2016 Implementation of List  List   ArrayList  LinkedList  Stack  Vector

Boston University Slideshow Title Goes Here CS Fall 2012, Lab /29/2016 Iterator  Iterator is an interface   Methods of Iterator  hasNext()  next()  remove()

Boston University Slideshow Title Goes Here CS Fall 2012, Lab /29/2016 Practice  Pruning duplicate elements from a collection that has duplicate elements

Boston University Slideshow Title Goes Here CS Fall 2012, Lab /29/2016 Practice  Use Hashset to prune  Use iterator(), addAll in Hashset  Assume we have 1 million elements in an ArrayList or Queue, and we do not know how many elements have duplicates. We should use another Hashset to help us prune all duplicates in our ArrayList or Queue. Use Iterator to traverse the Hashset.