mcs 231: concepts of data structure class hour: section 1: mw 2:15pm - 3:30pm. hyland 2306

67
MCS 231: Concepts of Data Structure Class Hour: Section 1: MW 2:15PM - 3:30PM. Hyland 2306

Upload: les

Post on 22-Feb-2016

34 views

Category:

Documents


0 download

DESCRIPTION

MCS 231: Concepts of Data Structure Class Hour: Section 1: MW 2:15PM - 3:30PM. Hyland 2306. Instructor contact information. [email protected] (fastest way to contact me) McGraw 106 Office Hours: 9:00am – 11:00am MTW or by appointment 262 472 5170. Course Objectives. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

MCS 231: Concepts of Data Structure

Class Hour:Section 1: MW 2:15PM - 3:30PM. Hyland 2306

Page 2: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Instructor contact [email protected](fastest way to contact me)

McGraw 106Office Hours: 9:00am –

11:00am MTW or by appointment

262 472 5170

Page 3: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Course Objectives- Given a basic data structure (e.g. queue, stack, list),

students will be able to apply the theory to implement applications using those data structures and analyze efficiency of each type.

- Given a complex data structure (trees, graph),students will be able to design and implement it, apply theory, and compute its efficiency.

- Given a large project that uses basic and complex data structures, students will be able to implement it using advanced Java techniques such as inheritance and polymorphism, interfaces and abstract classes, and the use of classes from the JAVA API.

Page 4: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Course Objectives- Given a basic data structure (e.g. queue, stack, list),

students will be able to apply the theory to implement applications using those data structures and analyze efficiency of each type.

- Given a complex data structure (trees, graph),students will be able to design and implement it, apply theory, and compute its efficiency.

- Given a large project that uses basic and complex data structures, students will be able to implement it using advanced Java techniques such as inheritance and polymorphism, interfaces and abstract classes, and the use of classes from the JAVA API.

Page 5: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Course Objectives- Given a basic data structure (e.g. queue, stack, list),

students will be able to apply the theory to implement applications using those data structures and analyze efficiency of each type.

- Given a complex data structure (trees, graph),students will be able to design and implement it, apply theory, and compute its efficiency.

- Given a large project that uses basic and complex data structures, students will be able to implement it using advanced Java techniques such as inheritance and polymorphism, interfaces and abstract classes, and the use of classes from the JAVA API.

Page 6: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Technology Requirement• J2SE Software Development Kit (SDK): ):

http://java.sun.com/javase/downloads/index.jsp (just download SDK 5.0 or later)

• Eclipse: http://www.eclipse.org/downloads/

Page 7: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Course detail - Evaluation

GRADABLE POINTS

Labs 100

Mid term Exam 150

5 Projects 500

Final Exam 200

Quizzes 50

Total 1000

Page 8: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Grading (+/-)

Letter Grade Percentage Letter

Grade Percentage

A 94 to 100% A- 90 to 93% B+ 87 to 89% B 84 to 86% B- 80 to 83% C+ 77 to 79% C 74 to 76% C- 70 to 73%

D+ 67 to 69% D 64 to 66% D- 60 to 63% F Less than 60%

Page 9: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Quiz• Quiz is used to measure:

- class attendance- class preparation

• Not all material will be covered in a 75-minute class

– Book complements the lectures

Page 10: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Must-have for success

Reading textbook Practicing (labs+projects) Devote time)

+ +

=

Page 11: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Philosophy for teaching Data Structure in this course

• Traditional way:implementing everything + starting from beginning+ focusing on complexity analysis

• Modern way:taking advantages of built-in methods from

Java/C++• Hybrid way:

taking advantages of built-in methods for simple data structure + implement everything for complex data structure + emphasize on complexity analysis

Page 12: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Philosophy for teaching Data Structure in this course

• Traditional way:implementing everything + starting from beginning+ focusing on complexity analysis

• Modern way:taking advantages of built-in methods from

Java/C++• Hybrid way:

taking advantages of built-in methods for simple data structure + implement everything for complex data structure + emphasize on complexity analysis

Page 13: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Philosophy for teaching Data Structure in this course

• Traditional way:implementing everything + starting from beginning+ focusing on complexity analysis

• Modern way:taking advantages of built-in methods from

Java/C++• Hybrid way:

taking advantages of built-in methods for simple data structure + implement everything for complex data structure + emphasize on complexity analysis

Page 14: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Getting started…Prerequisite:MCS 220

What do we still remember or know about Java and Software life cycle activity?

Page 15: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Class Focus

Balance between theory and implementation

Strict deadlines, high standard, ridiculous demands (always)

Page 16: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

AssessmentPrerequisite:MCS 220

What do we still remember or know about Java and Software life cycle activity?

Page 17: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Assessment1.1 What does “UML” stand for?

a. Understanding Modern Languageb. Unified Modeling Languagec. Unified Modern Languaged. Understanding Modeling Language

Page 18: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Assessment1.2 This task is not included in a software

development process.a. Architectural, component, and detailed

designsb. Implementationc. Acceptable testsd. Maintenancee. Marketing

Page 19: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Assessment1.3 Which of the following symbols can

be used in a UML class diagram to represent access ability of a data member or a method

a. –b. +c. #d. *

Page 20: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Assessment1.5 What is the complexity of selection

sorta. O(n)b. O(nlog2(n))c. O(n2)d. O(log2(n))

Page 21: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Assessment2.1 Overriding a method differs from overloading

a method because:a. For an overloaded constructor, the superclass

constructor will always be called first.b. For an overridden constructor, the superclass

constructor will always be called first.c. Overloaded methods have the same signature.d. Overridden methods have the same signature

Page 22: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Assessment2.2 Using the protected keyword gives a

member:a.public access (any classes can access

it).b.package access (only classes in the

same inheritance hierarchy can access it).

c.private access (nobody can access it)d.block scope (only the variables inside

the same block can access it).

Page 23: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Assessment2.3 Suppose method1 is declared as

void method1 ( int a, float b )Which of the following methods overloads method1?

a. void method2 ( int a, float b ).b. void method2 ( float a, int b ).c. void method1 ( float a, float b ).d. void method1 ( int b, float a ).

Page 24: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Assessment2.5. Variables should be declared as data

members only ifa. they are local variables.b. they are used only within a method.c. they are required for use in more than one

method or their values must be saved between calls to the class’s methods.

d. they are arguments.

Page 25: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Java development environment and Review

of Java

Page 26: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

EclipseTM Intergrated Development Environment (IDE)• Running Eclipse:

Warning: Never check the “Use this as the default and do not ask again” box.

Page 27: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

The importance of workspace• This is where you will find all your java

files.• You can switch from one workspace to

another.• You need to define the workspace first

(where you want to put your files) before click on OK

Page 28: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

EclipseTM tutorial

Perspective is a set of related Views (windows)

that enable a development specialist to perform

specific tasks

Page 29: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Create an Eclipse project

From the Eclipse menu bar select File, New, Project to start the “New Project” wizard.Select “Java Project” and click “Next”.

Page 30: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Create an Eclipse project

Page 31: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Create a Java package• Structure in dot format:

for example: com.tm.tutorial.main

Page 32: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Create Java classes Create Application class under com.tm.tutorial.main package

Page 33: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Create Java classes Create Application class under com.tm.tutorial.main package

Page 34: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Implementation of Java class

Page 35: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Implementation of Java classGenerating setters and getters for attributes

Page 36: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Implementation of Java classGenerating constructors

Page 37: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Implementation of Java classGenerating constructors

Page 38: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Compile Java Application

Page 39: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Compile Java Application

Page 40: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Run the application

Page 41: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Run the application

Page 42: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Run the application

Page 43: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Run the application

Page 44: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Run Application (Shorter way)

Page 45: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Setting up preferences in Eclipse

If you did not download the JDK earlier in this tutorial, and your existing JRE does not appear in the “Installed JREs” preference, you must add it yourself.

Page 46: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Setting up preferences in Eclipse

Page 47: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Setting up preferences in Eclipse

Page 48: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Introduction to Software Design

Page 49: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

49

The Software Challenge• In industry, a software product is expected to

be used for an extended period of time by someone who did not write the program and who is not intimately familiar with its internal design

• Initial specification for a software product may be incomplete

• Specification is clarified through extensive interaction between users of the software and the system analyst

Page 50: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

The Software challenge• A requirements specification should be

generated at the beginning of any software project

• Designers and users should both approve the document

Page 51: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

51

The Software Life Cycle• Software Life Cycle: the sequence of

stages that software products go through as they mature from initial concept to finished product

Page 52: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

52

Software Life Cycle Models• Waterfall model: simplest way of

organizing activities that transform software from one stage to another

• Activities are performed in sequence and the results of one flows into the next

• Waterfall model is simple but unworkable– Fundamental flaw is assumption that each

stage can and must be completed before the next one occurs

Page 53: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

53

Waterfall Model

Page 54: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

54

Waterfall Model (continued)

Page 55: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

55

Software Life Cycle Models (continued)

• Unified Model: the cycles are called phases and iterations and the activities are called workflows

• Four phases– Inception– Elaboration– Construction– Transition

Page 56: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

56

Software Life Cycle Models (continued)

Page 57: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

57

Software Life Cycle Activities (continued)

• Certain activities are essential for software development– Requirements specification– Architectural, component, and detailed

designs– Implementation– Unit, integration, and acceptance tests– Installation and maintenance

Page 58: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

58

Software Life Cycle Activities (continued)

• Requirements Specification– System analyst works with software users to

clarify the detailed system requirements– Questions include format of input data,

desired form of any output screens, and data validation

• Analysis– Make sure you completely understand the

problem before starting the design or program a solution

– Evaluate different approaches to the design

Page 59: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

59

Software Life Cycle Activities (continued)

• Design– Top-down approach: breaking a system into

a set of smaller subsystems– Object-oriented approach: identification of a

set of objects and specification of their interactions

– UML diagrams are a design tool to illustrate the interactions between• Classes• Classes and external entities

Page 60: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

60

Software Life Cycle Activities (continued)

Page 61: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

61

Using Abstraction to Manage Complexity

• An abstraction is a model of a physical entity or activity

• Abstraction helps programmers deal with complex issues in a piecemeal fashion

• Procedural abstraction: distinguish what is to be achieved by a procedure from its implementation

• Data abstraction: specify the data objects for a problem and the operations to be performed on them without concern for their representation in memory

Page 62: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

62

Using Abstraction to Manage Complexity (continued)

• If a higher-level class references a data object only through its methods, the higher-level class will not have to be rewritten, even if the data representation changes

• Information hiding: Concealing the details of a class implementation from users of the class

Page 63: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

63

Abstract Data Types• A major goal of software engineering is

to write reusable code• Abstract data type (ADT): The

combination of data together with its methods

Page 64: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Interface• A Java interface is a way to specify an

ADT– The interface specifies the names,

parameters, and return values of the ADT methods without specifying how the methods perform their operations and without specifying how the data is internally represented

• Each class that implements an interface must provide the definitions of all methods declared in the interface

Page 65: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

65

Abstract Data Types, Interfaces• You cannot instantiate an interface• You can declare a variable that has an interface

type and use it to reference an actual object• A Java interface is a contract between the

interface designer and the programmer who codes a class that implements the interface

Page 66: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Pre-condition, Post-condition• Precondition: a statement of any

assumptions or constraints on the method data before the method begins execution

• Postcondition: a statement that describes the result of executing a method

Page 67: MCS  231:  Concepts of  Data Structure Class Hour: Section 1:  MW 2:15PM - 3:30PM. Hyland 2306

Chapter 1: Introduction to Software Design

67

Requirements Analysis, Use Cases, and Sequence

Diagrams• First step in analysis is to study the problem of

input and output requirements carefully to make sure they are understood and make sense

• Use case: list of the user actions and system responses for a particular sub-problem in the order that they are likely to occur

• Sequence diagram: shows all the objects involved in this use case across the horizontal axis, time is shown along the vertical axis