1 / 11

Tutorial 2 Abstract Data Types

Tutorial 2 Abstract Data Types. 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.

trevor
Télécharger la présentation

Tutorial 2 Abstract Data Types

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Tutorial 2Abstract Data Types

  2. 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…

  3. 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

  4. 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();}

  5. 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)

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

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

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

  9. 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 The bridge between the two: INTERFACE Airbus 380 Integration Problem: http://news.airwise.com/story/view/1169812254.html

  10. Q3 – Compact Array • 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) • How to add when full? • Create a new array, double the size, copy the entries to new array. • 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. • How to delete? • Search it, delete the entry, shift everything on the right side of it to left by one! Tedious! • What are the potential issues with (b) and (d)? (see above)

  11. 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!

More Related