Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.

Slides:



Advertisements
Similar presentations
STACKS & QUEUES. Stacks Abstract data types An abstract data type (ADT) is an abstraction of a data structure An ADT specifies : –Data stored –Operations.
Advertisements

Lists and the Collection Interface Chapter 4. Chapter Objectives To become familiar with the List interface To understand how to write an array-based.
AITI Lecture 19 Linked List Adapted from MIT Course 1.00 Spring 2003 Lecture 26 and Tutorial Note 9 (Teachers: Please do not erase the above note)
Stack & Queues COP 3502.
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++)
COSC 1P03 Data Structures and Abstraction 9.1 The Queue Whenever you are asked if you can do a job, tell 'em, "Certainly, I can!" Then get busy and find.
0 of 37 Stacks and Queues Lecture of 37 Abstract Data Types To use a method, need to know its essentials: signature and return type o additionally,
CS 106 Introduction to Computer Science I 12 / 06 / 2006 Instructor: Michael Eckmann.
1 Chapter 24 Lists Stacks and Queues. 2 Objectives F To design list with interface and abstract class (§24.2). F To design and implement a dynamic list.
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
Unit 11 1 Unit 11: Data Structures H We explore some simple techniques for organizing and managing information H This unit focuses on: Abstract Data Types.
CS 106 Introduction to Computer Science I 12 / 11 / 2006 Instructor: Michael Eckmann.
1 Data Structures  We can now explore some advanced techniques for organizing and managing information  Chapter 12 of the book focuses on: dynamic structures.
TCSS 342, Winter 2005 Lecture Notes
1 Foundations of Software Design Fall 2002 Marti Hearst Lecture 13: Queues and Vectors.
Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved. 1 Chapter 26 Implementing Lists, Stacks,
CS 106 Introduction to Computer Science I 12 / 13 / 2006 Instructor: Michael Eckmann.
CSC 212 – Data Structures Lecture 21: IndexList a/k/a Vector, ArrayList.
1 Lecture 26 Abstract Data Types – IV Overview  The List ADT  Implementing Stacks as Linked List  Linked List Implementation of Queues .  Preview:
CS 171: Introduction to Computer Science II Stacks Ymir Vigfusson.
Week 3 - Wednesday.  What did we talk about last time?  Started linked lists.
Data Structures Data structures permit the storage of related data for use in your program. –Arrays.
Copyright © Texas Education Agency, Advanced Computer Programming Data Structures: Collections.
Chapter 3 List Stacks and Queues. Data Structures Data structure is a representation of data and the operations allowed on that data. Data structure is.
Data Structures and Abstract Data Types "Get your data structures correct first, and the rest of the program will write itself." - David Jones.
Week 2 - Monday.  What did we talk about last time?  Exceptions  Threads  OOP  Interfaces.
Generalized Containers CSIS 3701: Advanced Object Oriented Programming.
Information and Computer Sciences University of Hawaii, Manoa
Week 3 – Wednesday.  What did we talk about last time?  ADTs  List implementation with a dynamic array.
Some Other Collections: Bags, Sets, Queues and Maps COMP T2 Lecture 4 School of Engineering and Computer Science, Victoria University of Wellington.
Data Design and Implementation. Definitions of Java TYPES Atomic or primitive type A data type whose elements are single, non-decomposable data items.
1 Chapter 7 Stacks and Queues. 2 Stack ADT Recall that ADT is abstract data type, a set of data and a set of operations that act upon the data. In a stack,
Data structures Abstract data types Java classes for Data structures and ADTs.
CSS446 Spring 2014 Nan Wang  Java Collection Framework ◦ LinkedList ◦ Set ◦ Map 2.
Week 3 - Friday.  What did we talk about last time?  Stacks  Array implementation of a stack.
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.
Stacks and Queues. 2 3 Runtime Efficiency efficiency: measure of computing resources used by code. can be relative to speed (time), memory (space), etc.
1 Linked-list, stack and queue. 2 Outline Abstract Data Type (ADT)‏ Linked list Stack Queue.
Week 4 - Monday.  What did we talk about last time?  Queues  Implementing queues with circular arrays.
LECTURE 27: DEQUES CSC 212 – Data Structures. Roses are red and violets are blue Implement push, pop, & top And you’re a Stack too! Stack & ADT Memory.
Ordered Linked Lists using Abstract Data Types (ADT) in Java Presented by: Andrew Aken.
Week 5 - Wednesday.  What did we talk about last time?  Recursion  Definitions: base case, recursive case  Recursive methods in Java.
Recitation 5 Enums and The Java Collections classes/interfaces 1.
CSE 373: Data Structures and Algorithms Lecture 2: Queues.
Some Other Collections: Bags, Sets, Queues and Maps COMP T2 Lecture 4 School of Engineering and Computer Science, Victoria University of Wellington.
Week 4 - Friday.  What did we talk about last time?  Continued doubly linked list implementation  Linked lists with iterators.
Stacks and Queues CMSC 201. Stacks and Queues Sometimes, when we use a data-structure in a very specific way, we have a special name for it. This is to.
Chapter 4 ADTs Stack and Queue. 4-2 Formal ADT Specifications The Java interface construct lets us collect together method interfaces into a syntactic.
Object Oriented Programming in Java Habib Rostami Lecture 7.
1 Queues (Continued) Queue ADT Linked queue implementation Array queue implementation Circular array queue implementation Deque Reading L&C , 9.3.
Week 15 – Monday.  What did we talk about last time?  Tries.
1 CS162: Introduction to Computer Science II Abstract Data Types.
Stacks and Queues. 2 Abstract Data Types (ADTs) abstract data type (ADT): A specification of a collection of data and the operations that can be performed.
Linked Data Structures
Week 4 - Monday CS221.
Single-Linked Lists.
QueueStack CS1020.
Week 4 - Friday CS221.
Chapter 12: Data Structures
Week 3 - Friday CS221.
Week 15 – Monday CS221.
CMSC 341 Lecture 5 Stacks, Queues
structures and their relationships." - Linus Torvalds
structures and their relationships." - Linus Torvalds
Based on slides by Alyssa Harding & Marty Stepp
slides created by Alyssa Harding
structures and their relationships." - Linus Torvalds
Data Structures & Programming
Presentation transcript:

Week 2 - Friday

 What did we talk about last time?  Computing Big Oh

Bitmap Manipulator

Student Lecture

 From a formal perspective, a type is a set of data values and the operations you can perform on them TypeValuesOperations int Integers from to , -, *, /, %, >, |, & double Floating points numbers +, -, *, /, % String All possible Java String objects +, length(), charAt(), substring(), etc. Wombat All possible Wombat objects toString(), eat(), etc.

 So, you have a type with operations  Do you need to know how those operations are implemented to be able to use them?  No!  In fact, in OOP (including Java), the data is usually hidden from you  Enter the Abstract Data Type (ADT)  It does something  We aren't necessarily concerned with implementation

 The idea of an interface has a strong connection to an ADT  Let's look at the List interface  Some of its methods:  boolean add(E element)  void add(int index, E element)  void clear()  E get(int index)  int size()  boolean remove(Object o)

 There are lots of different ways of keeping a list of data  The List ADT doesn't care how we do it  And there are lots of implementations that Java provides:  ArrayList  LinkedList  Stack  Vector  You can use whichever you think best suits your task in terms of efficiency

 A bag is an ADT that is iterable but otherwise only has one real operation  Add  Put an element in the bag  It's a collection of things in no particular order  A bag is also called a multiset  The book talks about bags partly because it's hard to imagine a simpler ADT

 The list ADT is not entirely standardized  Some lists allow insertion at the beginning, end, or at arbitrary locations  Some lists allow elements to be retrieved from an arbitrary location  Let's focus on an list that allows the following operations  Add  Insert element at the end of the list  Add at index  Insert element at an arbitrary location  Get  Retrieve element from arbitrary location

 A stack is an ADT with three main operations  Push  Add an item to the top of the stack  Pop  Remove an item from the top of the stack  Top  Retrieve the item at the top of the stack  Stacks are often implemented with a dynamic array or a linked list

 A queue is an ADT with three main operations  Enqueue  Add an item to the back of the queue  Dequeue  Remove an item from the front of the queue  Front  Retrieve the item at the front of the queue  Queues are also often implemented with a dynamic array or a linked list

 We're not going to implement the bag ADT since it's very limited  Instead, we'll focus on the following methods from our list ADT (and a couple of other useful ones)  Constructor  Add: Insert element at the end of the list  Add at index: Insert element at an arbitrary location  Get: Retrieve element from arbitrary location  Size: Get the current number of elements stored  For now, we'll implement the list with a dynamic array that holds String objects

public class ArrayList private String[] array; private int size; public ArrayList() {} public void add(String s) {} public void insert(String s, int index) {} public String get(int index) {} public int size() {} }

 Stacks  Keep reading section 1.3

 No class Monday!  Keep reading section 1.3  Start on Assignment 2  Due next Friday by 11:59pm  Keep working on Project 1  Due Friday, September 18 by 11:59pm