Tutorial 2 Abstract Data Types 1. Admin Stuffs Some of you request to change tutorial class… – Transfer within my own classes (T3, T4, T5, T6) is fine.

Slides:



Advertisements
Similar presentations
Lists: An internal look
Advertisements

Lists Chapter 4 Carrano, Data Structures and Abstractions with Java, Second Edition, (c) 2007 Pearson Education, Inc. All rights reserved X.
Hash Tables and Sets Lecture 3. Sets A set is simply a collection of elements Unlike lists, elements are not ordered Very abstract, general concept with.
Container Classes A container class is a data type that is capable of holding a collection of items. In C++, container classes can be implemented as.
Introduction to Linked Lists In your previous programming course, you saw how data is organized and processed sequentially using an array. You probably.
Comp 212: Intermediate Programming Lecture 18 – Java Generics By: Anupam Chanda.
Linked Lists Compiled by Dr. Mohammad Alhawarat CHAPTER 04.
Object Orientated Concepts. Overview  The world is objects  Defining an object  Not a function, it’s a method  Lets inherit want we can  Objects.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
List Implementations That Use Arrays Chapter 5 Slides by Steve Armstrong LeTourneau University Longview, TX  2007,  Prentice Hall.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
List Implementations That Use Arrays Chapter 5. 2 Chapter Contents Using a Fixed-Size Array to Implement the ADT List An Analogy The Java Implementation.
Object Oriented Programming.  OOP Basic Principles  C++ Classes  September 2004  John Edgar 22.
IEG 3080 Tutorial 1 Wilson Ip. Outline Lecture reviews: Some basics of Software Engineering principle Some basics of OOP How to use Visual Studio.NET.
Subclasses and Subtypes CMPS Subclasses and Subtypes A class is a subclass if it has been built using inheritance. ▫ It says nothing about the meaning.
Editing Java programs with the BlueJ IDE. Working environments to develop (= write) programs There are 2 ways to develop (write) computer programs: 1.Using.
Computer Science 102 Data Structures and Algorithms V Fall 2009 Lecture 1: administrative details Professor: Evan Korth New York University 1.
WEEK 1 CS 361: ADVANCED DATA STRUCTURES AND ALGORITHMS Dong Si Dept. of Computer Science 1.
Week 4-5 Java Programming. Loops What is a loop? Loop is code that repeats itself a certain number of times There are two types of loops: For loop Used.
Object Oriented Programming Concepts OOP – reasoning about a program as a set of objects rather than as a set of actions Object – a programming entity.
Welcome to CS1102 sem1 08/09 Notes: All of my PowerPoint slides will be uploaded to my website after my last tutorial class every week.
More with Methods (parameters, reference vs. value, array processing) Corresponds with Chapters 5 and 6.
CSC 212 Object-Oriented Programming and Java Part 1.
Programming Concept Chapter I Introduction to Java Programming.
1 21 COP 3540 Data Structures with OOP Overview: Chapter 1.
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
CIT 590 Intro to Programming First lecture on Java.
Abstract Data Types. What’s on the menu? What’s an abstract data type? How do you implement it? ADT List.
Computer Science 102 Data Structures and Algorithms CSCI-UA.0102 Fall 2012 Lecture 1: administrative details Professor: Evan Korth New York University.
Working with arrays (we will use an array of double as example)
 A Collection class is a data type that is capable of holding a group of items.  In Java, Collection classes can be implemented as a class, along with.
ICOM 4035 – Data Structures Lecture 3 – Bag ADT Manuel Rodriguez Martinez Electrical and Computer Engineering University of Puerto Rico, Mayagüez ©Manuel.
Design.ppt1 Top-down designs: 1. Define the Problem IPO 2. Identify tasks, Modularize 3. Use structure chart 4. Pseudocode for Mainline 5. Construct pseudocode.
C++ and Ubuntu Linux Review and Practice CS 244 Brent M. Dingle, Ph.D. Game Design and Development Program Department of Mathematics, Statistics, and.
Some Thoughts about Hits, Geometry etc Rob Kutschke, Hans Wenzel Fermilab March 13, 2007.
Chapter 4 Data Abstraction: The Walls. © 2004 Pearson Addison-Wesley. All rights reserved4-2 Abstract Data Types Modularity –Keeps the complexity of a.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Tutorial 3 More C++ and ADT 1. Admin Some students have moved to different class – Changes have been reflected in the attendance list See the last few.
Stacks The content for these slides was originally created by Gerard Harrison. Ported to C# by Mike Panitz.
Data Abstaraction Chapter 10.
Abstraction ADTs, Information Hiding and Encapsulation.
Week 8 - Monday.  What did we talk about last time?  BST traversals  Get range implementation.
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
90-723: Data Structures and Algorithms for Information Processing Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 1: Introduction Data.
Ordered Linked Lists using Abstract Data Types (ADT) in Java Presented by: Andrew Aken.
Graphs, Continued ECE 297.
Container Classes  A container class is a data type that is capable of holding a collection of items.  In C++, container classes can be implemented as.
2.1 Functions. Functions in Mathematics f x y z f (x, y, z) Domain Range.
Course: Object Oriented Programming - Abstract Data Types Unit2: ADT ListsSlide Number 1 Principles for implementing ADTs ADT operations as “walls” between.
1 Class 1 Lecture Topic Concepts, Definitions and Examples.
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming - Week.
Data Structures and Algorithms in Java AlaaEddin 2012.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
Unit 1 - Introducing Abstract Data Type (ADT) Part 3 – Slides 24 to end.
CSC 243 – Java Programming, Fall, 2008 Tuesday, September 30, end of week 5, Interfaces, Derived Classes, and Abstract Classes.
Section 2.2 The StringLog ADT Specification. 2.2 The StringLog ADT Specification The primary responsibility of the StringLog ADT is to remember all the.
The need for Programming Languages
CSC 222: Computer Programming II
Computer Science 102 Data Structures CSCI-UA
PRG 421 GUIDE Higher Education / prg421guide.com.
PRG 421 MART Higher Education / prg421mart.com
PRG 421 MART Lessons in Excellence-- prg421mart.com.
PRG 421 GUIDE Lessons in Excellence -- prg421guide.com.
PRG 421 GUIDE Education for Service-- prg421guide.com.
Introduction to Data Structures
Data Structures and Algorithms for Information Processing
Object Comparisons and Arrays
Review of Previous Lesson
Chapter 2. Problem Solving and Software Engineering
Presentation transcript:

Tutorial 2 Abstract Data Types 1

Admin Stuffs Some of you request to change tutorial class… – Transfer within my own classes (T3, T4, T5, T6) is fine. – Transfer between different tutors requires permission. Ask Dr Tan Sun Teck’s permission for such changes. Refrain from asking lab assignments to me – I am not supposed to help you with debugging or finding the algorithm etc… Bidding system not working (yet)  – If this system is not good, I will be forced to change it… 2

Abstract Data Type (ADT) Data Structure: – “Structure of Data”, structure makes life easier Algorithm: – Step by step way to solve certain problem Abstract Data Type – Data + Operations (Algorithms) to organize that data structure – Walls: We do not need to know the implementation details – Examples: Complex Number, Sphere, ColoredSphere:Sphere, List, etc. Wait!! Contradictions?? – We are given so many implementation details here! Why bother with details? In fact, we are going to do that throughout this module – To give you a strong theoretical foundation… – Later on, you will just use these ADTs for your programming tasks 3

Implementing ADT in Java: Class Java class is used to implement these ADT This is the basic pattern of a class implementation: – public class C { // save as C.java private (instance) attributes… public (instance) attributes, constructor, methods… } Sometimes we use “Interface” – interface C_interface { // signature of public methods are mentioned here desired interfaces… } – public class C implements C_interface { // a guarantee that we will implement the methods implementation must adhere the agreed interface, otherwise we have compile error } In main method: – public static void main(String[] args) { C cInstance = new C(); } 4

Object Oriented Programming We learned these OOP concepts via these two questions: – Q1: Programming using agreed interfaces; Abstraction provided by ADTs; Implementing ADTs in Java. – Q2: Software re-use, A demonstration of “Integration” of (F1_2008); (F1_Driver, F1_Team, F1_Championship); and (F1_Race) 5

Student Presentation T3 1.N/A 2.N/A 3.N/A T4 1.N/A 2.N/A 3.N/A T5 1.Tan Yan Hao 2.Tan Yan Hao 3.Tan Yan Hao T6 1.Wong Shiang Ker 2.Nguyen Duy Hoang 3.Nguyen Duy Hoang 6  Better participation level is expected for tutorial 3 onwards!

Question 1 & 2 - F1 (1) The answer for these two questions are in the Java source codes! 7

8 Visit this Simulator (free) at Singtel Headquarter, Somerset

Question 1 & 2 - F1 (2) Coded by your TA: – F1_2008.java Coded by you: – Q1: F1_Driver.java F1_Team.java F1_Championship.java – Q2: F1_Race.java 9 The bridge between the two: INTERFACE Airbus 380 Integration Problem:

Q3 – Compact Array a)How to add? – Find first empty slot, insert it (bad).  O(n) – Maintain an index of first empty slot, insert there, add the index by 1 (good).  O(1) b)How to add when full? – Create a new array, double the size, copy the entries to new array. c)How to edit? – Search it from left to right, if found, replace the content. – As soon as you hit an empty slot, it means that the entry is not in the compact array. d)How to delete? – Search it, delete the entry, shift everything on the right side of it to left by one! Tedious! e)What are the potential issues with (b) and (d)? (see above) 10

That’s all for today Next week, we will continue our lesson with Linked List. Maybe a better data structure than “compact array”, especially for Q3. – Remember that the “best” data structure depends on the given scenario! 11