CPSC 102: Computer Science II Dr. Roy P. Pargas 408 Edwards Hall 864-656-5855 Office Hours 10:00-11:00 am MWF 2:00-3:00 pm TTh.

Slides:



Advertisements
Similar presentations
Data Structures.
Advertisements

Computer Science 112 Fundamentals of Programming II Overview of Collections.
Working With Collections in the AP ™ Java Subset 2003 ACTE Convention © 2003 by Kenneth A. Lambert.
Ordered Containers Cmput Lecture 21 Department of Computing Science University of Alberta ©Duane Szafron 2000 Some code in this lecture is based.
CHAPTER 3 COLLECTIONS Abstract Data Types. 2 A data type consists of a set of values or elements, called its domain, and a set of operators acting on.
CS 307 Fundamentals of Computer Science 1 Abstract Data Types many slides taken from Mike Scott, UT Austin.
Basic Definitions Data Structures: Data Structures: A data structure is a systematic way of organizing and accessing data. Or, It’s the logical relationship.
The List Interface Cmput Lecture 14 Department of Computing Science University of Alberta ©Duane Szafron 2000 Some code in this lecture is based.
CS 106 Introduction to Computer Science I 03 / 17 / 2008 Instructor: Michael Eckmann.
CS 106 Introduction to Computer Science I 04 / 30 / 2010 Instructor: Michael Eckmann.
Java's Collection Framework
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
Computer Science II 810:062 Section 01 Session 2 - Objects and Responsibilities.
CSE 332: C++ templates This Week C++ Templates –Another form of polymorphism (interface based) –Let you plug different types into reusable code Assigned.
Chapter 3 Introduction to Collections – Stacks Modified
Advanced Java Session 3 New York University School of Continuing and Professional Studies.
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.
Java™ How to Program, 9/e Presented by: Dr. José M. Reyes Álamo © Copyright by Pearson Education, Inc. All Rights Reserved.
CSC 212 Object-Oriented Programming and Java Part 1.
CSCI 62 Data Structures Dr. Joshua Stough September 9, 2008.
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Marcus Frean.
Course: Object Oriented Programming - Abstract Data Types Unit1: IntroductionSlide Number 1 Introduction Course: Object Oriented Programming Abstract Data.
Computer Science Department Data Structures and Algorithms Lecture 1.
Jan 12, 2012 Introduction to Collections. 2 Collections A collection is a structured group of objects Java 1.2 introduced the Collections Framework Collections.
The Java Collections Framework (JCF) Introduction and review 1.
Spring 2008 Mark Fontenot CSE 1341 Principles of Computer Science I Note Set 2.
Computer Science II 810:062 Section 01. How is CS I different from CS II? When you teach Java there are a series of decisions that have to be made…
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
1 Java: AP Curriculum Focus and Java Subset Alyce Brady.
Copyright © 2002, Systems and Computer Engineering, Carleton University Hashtable.ppt * Object-Oriented Software Development Unit 8.
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 - 1 CS230: Data Structures Spring 2007 Reading:Downey: Chapters 1, 2, 3, Sections , 4.13, , Chapters 5 and 6 Problem Set:Problem Set.
Data structures Abstract data types Java classes for Data structures and ADTs.
Priority Queues Dr. David Matuszek
15440 Distributed Systems Recitation 1 Objected-Oriented Java Programming.
Stacks and Queues. 2 3 Runtime Efficiency efficiency: measure of computing resources used by code. can be relative to speed (time), memory (space), etc.
Chapter 1: Object Oriented Paradigm. 1.1 Data Abstraction and Encapsulation OOP allows programmer to – separate the details that are important to the.
Introduction to Classes and Objects. Real Life When a design engineer needs an electrical motor he doesn’t need to worry about –How a foundry will cast.
Computer Science Projects Internal Assessment. Mastery Item Claimed Justification Where Listed Random Access File – Searching Lines P. 53 Random.
COP INTERMEDIATE JAVA Designing Classes. Class Template or blueprint for creating objects. Their definition includes the list of properties (fields)
Sets and Maps Computer Science 4 Mr. Gerb Reference: Objective: Understand the two basic applications of searching.
Ordered Linked Lists using Abstract Data Types (ADT) in Java Presented by: Andrew Aken.
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Thomas Kuehne.
Abstract Data Type EnhanceEdu.
2 Obaid Ullah HOD Computer Science Dept. Superior University Sialkot Campus.
Introduction to Collections. Collections Collections provide a way of organizing related data in a model Different types of collections have different.
Sets and Maps Part of the Collections Framework. 2 The Set interface A Set is unordered and has no duplicates Operations are exactly those for Collection.
Computer Science II 810:062 Section 01 Session 2 - Objects and Responsibilities.
Introduction to Objects and Encapsulation Computer Science 4 Mr. Gerb Reference: Objective: Understand Encapsulation and abstract data types.
JAVA COLLECTIONS LIBRARY School of Engineering and Computer Science, Victoria University of Wellington COMP T2, Lecture 2 Marcus Frean.
1 Lecture 8 b Data Structures b Abstraction b The “Structures” package b Preconditions and postconditions b Interfaces b Polymorphism b Vector class b.
Collections Dwight Deugo Nesa Matic
C19: Collection Classes (don’t forget to look at all the online code examples)
3-1 Java's Collection Framework Another use of polymorphism and interfaces Rick Mercer.
CSC 243 – Java Programming, Fall, 2008 Tuesday, September 30, end of week 5, Interfaces, Derived Classes, and Abstract Classes.
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.
Using the Java Collection Libraries COMP 103 # T2
Fundamentals of Programming II Overview of Collections
Efficiency of in Binary Trees
structures and their relationships." - Linus Torvalds
TCSS 143, Autumn 2004 Lecture Notes
JAVA Collections Framework Set Interfaces & Implementations
Introduction to Data Structure
CS2013 Lecture 7 John Hurley Cal State LA.
structures and their relationships." - Linus Torvalds
Presentation transcript:

CPSC 102: Computer Science II Dr. Roy P. Pargas 408 Edwards Hall Office Hours 10:00-11:00 am MWF 2:00-3:00 pm TTh

Overview of Course Construction and Use of Objects –Definition –Methods –Use Data Structures –Definition and Use Algorithm Analysis

Semester Outline 1. The Object-Oriented Method (2) 2. Comments, Conditions, and Assertions (1) 3. Vectors (3) 4. Design Fundamentals(4) 5. Sorting (2) 6.Lists(2) Test 1 7. Linear Structures (2) 9. Ordered Structures (2) 10. Trees (3) 11. Priority Queues (2) 12. Search Trees (2) 14. Graphs (1) Test 2

Objects Classes –templates for objects Instances or Objects –constructed from classes Message passing –usually changes state of object

Data Abstraction and Encapsulation Objects –sports car –string of characters –array of objects Details of structure (implementation) unimportant Interface (contract) important A p p l e data

Object Model Data for program managed by its objects Program manipulates data through messages or method calls to the objects

Object-Oriented Terminology Data abstraction is accomplished through encapsulation of data in an object (an instance of a class) Fields and methods may be declared public or protected Fields are encapsulated by a class Classes are encapsulated by a package Public classes may be used by anyone who imports the package

Example: class Ratio Interface –public Ratio(int top, int bottom) –public int getNumerator() –public int getDenominator() –public double value() –public Ratio add(Ratio other)

Example: class WordList WordList, initially empty, will contain words User must be able to add words to, retrieve words from, and remove words from WordList User must know when Wordlist empty

Example: class WordList Interface –public WordList(int size) –public boolean isEmpty() –public void add(String s) –public String selectAny() –public void remove(String word)

We do not need to know anything about application other than its interaction with Object (abstract list of words) We really don’t know how WordList is implemented Result is the WordList interface Example: class WordList

Example: class BankAccount Read on your own Pay attention to discussion of the method equals

Example: Linked Lists Refer to Program #1 handout Program #1 –due Monday, August 31, 1998 –handin List.java –handin ListNode.java –handin LinkedList.java –handin *.java

handin *.java Submission for 102 section 2 asg number 1: LinkedList.java List.java ListNode.java Do you wish to continue with the submission [y/n] y file LinkedList.java: 3642 bytes copied file List.java: 993 bytes copied file ListNode.java: 227 bytes copied handin command

Example: An Association Pig Latin translator Example of (key-value) pair Example of precondition Principle 2: –Free the future: reuse code

Interfaces Sometimes useful to describe the interface for a number of different classes without committing to an implementation No code specified in an interface Interfaces may be extended Example: public interface Store public interface Collection extends Store

Example: Extending Interfaces public interface Store –public int size() –public boolean isEmpty() –public void clear public interface Collection extends Store –public boolean contains(Object value) –public void add(Object value) –public Object remove(Object value) –public Iterator elements()

Conclusions Principle 3: Design and abide by interfaces as though you were the user Principle 4: Declare data fields protected Data abstraction is supported by separating the interface from the implementation of the data structure

Homework #1 Problems 1.10, 1.11, 1.13 of textbook Assigned August 26, 1998 Due September 2, 1998 Refer to printed handout distributed in class

Program #2 (?) Problems: 1.6, 1.7 Refer to Program #2 handout Due: September 9, 1998