1 welcome csci 3333 data structures section 03 thurs., 7:00–9:50 p.m. instructor: charles moen...

45
1 Welcome CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m. Instructor: Charles Moen Email – [email protected] Web page – http://sce.uhcl.edu/moenc Office – Delta Building 232 Office hours – Thurs. 5:00–7:00 p.m. – If the hall door is locked, phone me at (281) 283-3848 Home – 713-880-2924

Upload: cornelius-curtis

Post on 29-Jan-2016

218 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

1

Welcome

CSCI 3333 Data Structures• Section 03 Thurs., 7:00–9:50 p.m.

Instructor: Charles Moen• Email – [email protected]• Web page – http://sce.uhcl.edu/moenc• Office – Delta Building 232• Office hours

– Thurs. 5:00–7:00 p.m.– If the hall door is locked, phone me at (281) 283-3848

• Home – 713-880-2924

Page 2: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

2

CSCI 3333

Data Structures• Stacks, queues, lists, trees, hash tables

Algorithms• Searching, sorting, recursion, analysis of running

time

Software Engineering• Methods, abstraction, encapsulation, ethics

Java• Use object-oriented programming to implement data

structures

Page 3: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

3

Today’s Objectives

Class roster

Course overview• Required textbook, web site, syllabus, schedule • How to succeed

Main concepts

Software engineering

Software engineering ethics

Reminder• The Ethics Paper assignment is posted, and it is due on 31-Jan

17-Jan-2008

Page 4: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

4

Required Textbook

M. T. Goodrich and R. Tamassia, Data Structures and Algorithms in Java.Hoboken, NJ: John Wiley & Sons, Inc., 2006.ISBN 0-471-73884-0

Textbook web page: http://java.datastructures.net/

Course Overview

Page 5: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

5

Course Web Pages

Course pagehttp://sce.uhcl.edu/moenc/csci3333spring08/index.html

Schedulehttp://sce.uhcl.edu/moenc/csci3333spring08/schedule.html

Syllabushttp://sce.uhcl.edu/moenc/csci3333spring08/syllabus.html

Resourceshttp://sce.uhcl.edu/moenc/csci3333spring08/resources.html

Course Overview

Page 6: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

6

How to Succeed

Expect to spend 10–15 hours per week on this class Practice by writing a lot of small programs

• To learn object-oriented programming with Java• To apply those skills to data structures

Homework assignments• Start them early• Hand them in on time• Check the requirements and make sure

nothing is missing• Ensure that your programs compile

and work correctly

Attend the classes & participate Read the book

Course Overview

Page 7: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

7

Main Concepts

Page 8: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

8

Data Structure

“A systematic way of organizing and accessing data” in a computer’s memory

(Goodrich, 162)

Main Concepts

Page 9: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

9

Data Structure

“A systematic way of organizing and accessing data” in a computer’s memory

(Goodrich, 162)

Main Concepts

We use variables to store data in a computer’s memory. Does that mean that variables are data structures?

Page 10: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

10

Data Structure

“A systematic way of organizing and accessing data” in a computer’s memory

(Goodrich, 162)

Main Concepts

We use variables to store data in a computer’s memory. Does that mean that variables are data structures?

No. When we talk about data structures, we are referring to programming elements that can hold a lot of data, like an array.

Page 11: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

11

Data Structure

“A systematic way of organizing and accessing data” in a computer’s memory

(Goodrich, 162)

Important things to remember about any data structure:

1. How are the data related?• For example, are they in a sequence?• This is the “organizing” part

2. What operations can be performed on the data? This is the “accessing” part

Main Concepts

Page 12: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

12

Data Structure Example

Stack = data structure that stores data elements which are inserted or removed in LIFO (last-in first-out) order

How are the data related?• Stored in a linear sequence determined by the insertion order

What operations can be performed on the data?st.push(); st.pop(); st.top(); st.size(); st.isEmpty();

Uses:• Backtracking

– Storing addresses in a Web browser’s history– Implementing an “undo” feature by storing changes

• Reversing data• Parsing

Main Concepts

Page 13: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

13

Algorithm

“ A step-by-step procedure for performing some task in a finite amount of time”

(Goodrich, 162)

Main Concepts

Page 14: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

14

Algorithm

“ A step-by-step procedure for performing some task in a finite amount of time”

(Goodrich, 162)Pseudocode example of an algorithm:

Algorithm arrayMax(A,n): Input: An array A storing n >= 1 integers. Output: The maximum element in A.

currentMax A[0]for i 1 to n – 1 do if currentMax < A[i] then currentMax A[i]return currentMax

Main Concepts

Page 15: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

15

Our Motivation

Good data structures and algorithms are necessary for efficiency and speed in our applications

Motivation:When you are a professional programmer, it is likely that your company will have millions of records of data. Your job will be to search that data and find the answer in seconds. What happens if your algorithms are too slow?

Main Concepts

Page 16: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

16

Algorithms + Data Structures

Algorithms + Data Structures = ProgramsNiklaus Wirth, 1975

Title of Wirth’s book One point of view that illustrates the importance of

data structures and algorithms OOP takes a slightly different point of view

Main Concepts

Portrait of Niklaus Wirth taken in 1969, by Robert M.

McClure. From Wikipedia.

Niklaus Wirth lecturing in 2005. From Wikipedia.

Page 17: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

17

Data Structures & Algorithms

Core knowledge in computer scienceDonald Knuth, The Art of Computer Programming

Main Concepts

From Stanford Magazine, May–June 2006

From Amazon.com

Page 18: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

18

Data Structures as Tools

Data structures are tools that we use in our programs

We will study• The most important data structures & algorithms• How to make them• How to use them• How to measure their performance• How to find readymade tools

Main Concepts

Page 19: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

19

Software Engineering

Page 20: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

20

Basic Terms

Engineer• A person who makes things work by applying

theories, methods, and tools(Sommerville, 7)

Software Engineer• An engineer who is concerned with the practical

problems of software production• Writing code, project management, and developing

theories and methods related to software production

What is the difference between software engineering and computer science?

Software Engineering

Page 21: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

21

History

1968 – The “software crisis”• NATO Software Engineering Conference in

Garmisch, Germany (Randell)• Late projects• High costs• Code was hard to maintain• Ad hoc programming

Software engineering• Formal development techniques and processes• Goal is to control costs and complexity

Software Engineering

Page 22: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

22

Software Life Cycle

Software development activities and artifacts

Software process• Series of steps for software development

– Overall life cycle steps, e.g. Rational Unified Process– Steps in an individual activity, e.g. requirements process

• There is no standard software process– But it is important to use a process

• Goals accomplished by using a software process1.Repeatable procedure—better able to succeed

consistently2.Facilitate team interaction3.Measurable progress—on time and within budget

Software Engineering

Page 23: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

23

Software Life Cycle Models

Abstraction of the software life cycle

Examples• Waterfall model (Royce)

• Spiral model (Boehm)

• Unified Process (Booch, Jacobson, Rumbaugh)

• What are some others?

Software Engineering

Page 24: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

24

Waterfall Model

Each step is completed before the next is started (Royce, 7)• Requirements gathering• Analysis• Design• Implementation• Testing• Operations (daily use of the program)

Some big drawbacks• Difficult to make revisions due to unforeseen problems• Focus on paper documents and distrustful customer-

contractor relationships

Software Engineering

1

2

3

4

5

6

Page 25: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

25

Software Life Cycle

Important parts of the software life cycle that are needed by any model of it

• Requirements gathering– From the stakeholders

• Analysis– Determine what the program should do, but not specifically how it

will be done– Build models, e.g. with UML

• Design– Program design– Adjust the models to simplify implementation and improve

execution

• Implementation – coding• Testing

Software Engineering

Page 26: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

26

Iterative Models

Iteration = Repetition

Activities are not completed in a strictly linear way• Design can start when most requirements are known, and

the design may lead to new requirements

• During design, some implementation may be done to establish the feasibility of the design

• During implementation, some revisions of the design may be required

• The tests may be designed during the requirements-gathering activity

The project evolves through improvements and refinements

Software Engineering

Page 27: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

27

Rational Unified Process

An example of an iterative process

Software Engineering

(Jacobson et al.)

Page 28: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

28

What makes a computer program good?

It must work correctly.

It should be safe.

It should be efficient.

It should be general-purpose, as much as possible so that we can use it in many ways.

We need to be able to develop it rapidly.

It should be easy to maintain.

Software Engineering (Drake, 3–7)

Page 29: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

29

Evolution of Software Design

It’s difficult to write good, efficient programs in a reasonable amount of time because programs are very complex.

Goal = reduce complexity!

Approaches improved with time

• No particular plan (1960s and earlier)

• Functional design & structured programming

• Object-oriented design (OOD) (today)

Software Engineering

Page 30: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

30

OOD Goals

Robustness• “Capable of handling unexpected inputs”• Correct and safe

Reusability• Code should be reusable in other applications• Class libraries like the Java Collections Framework• General purpose code helps rapid development

Adaptability• Able to evolve over time in response to changes• Loosely connected classes• Easy to maintain

Software Engineering (Goodrich, 58)

Page 31: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

31

OOD Principles

Abstraction• Distill a complicated system into simple parts (objects) that

can be easily described and understood• e.g., a road map is an abstraction

Encapsulation• Data and the operations that can be performed with that

data are kept in the same place – the objects• Simplify a program by dividing it into distinct components or

objects

Information hiding• Internal details of a class are not revealed

– We don’t need to know how it’s done– We just need to know the “interface”

Software Engineering (Goodrich, 59)

Page 32: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

32

Data Type

Defined by: A range of data values The operations that can be performed on the data

Example:int data type

• Type of data: integer values from -231 to 231 - 1• Operations supported: arithmetic (+,–,*,/,%),

assignment (=), equality (==, !=), relational (<,>,<=,>=), increment (++), decrement (––), etc.

Software Engineering

Page 33: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

33

Abstract Data Type

A specification for a data structure that tells us• The type of data stored• The operations that are supported

Specifies what the operations do, but not how they do it

(Goodrich, p. 60)

Software Engineering

Page 34: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

34

Interface

Specifies operations that are supported

Specifies what the operations do, but not how they do it

We depend on the interface to tell us how to use a programming feature

• Example:API = Application Programming Interface

An ADT specifies an interface

Software Engineering

Page 35: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

35

Java interface

There is a language feature called an “interface” in Java

It is a “collection of method declarations with no data and no bodies”

A class that implements an interface must implement all its methods

We’ll use an interface to specify an ADT so that the classes that implement a data structure based on the ADT will have to implement all its operations

But the interface does not implement an ADT

Software Engineering (Goodrich, 80)

Page 36: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

36

Java class

In Java, we implement an ADT by writing a class• A class specifies how the operations are performed

A class contains• Data

– Called “instance variables”

– Usually private

• Operations– Operations that can be performed on the data

– Called “methods”

– Usually public

• The public operations are considered the “interface”

Software Engineering

Page 37: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

37

Information Hiding

Accomplished by keeping the instance variables private

The user of an object in your program can change its data, but cannot change it directly

Data members are manipulated only by accessor methods

• “Set” methods• “Get” methods

Advantage• We can control how the data is changed• We can control how the data is stored• Other parts of the program don’t need to know how it’s done,

they just need to know the “interface”

Software Engineering

Page 38: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

38

Software Engineering Ethics

Page 39: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

39

Ethics

Ethics = the study of moral choices that a person makes in relationships with other people

It’s about how we use the power that we have when making decisions that influence the dignity and well-being of other people

Software Engineering

Page 40: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

40

Computer Ethics

Computer systems are everywhere

As software engineers, systems engineers, or computer scientists we have “significant opportunities to do good or to cause harm” (ACM/IEEE-CS)

Cases:• Morris worm• Therac-25• Any other examples?

Software Engineering

Page 41: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

41

Ethics Training

Even minimal training in ethics helps us make better choices (Harris et al.)

CSCI 4837 Social, Ethical, and Security-Related Issues in Computing

Software Engineering

Page 42: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

42

Codes of Ethics

Professional organizations—both have professional codes of ethics

• ACM(Association for Computing Machinery)

• IEEE

http://sce.uhcl.moenc/csci3333spring08/resources.html

Software Engineering

Page 43: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

43

An Ethics Test

When faced with an ethical question, the best choice may be hard to pickExample:

You just got a job working for a college computing lab, and your supervisor asked you to install a new program on all 30 of the lab’s PCs. You discover that the school only owns a single copy of the software. What would you do?

An ethics test is a framework for making a decision when you are faced with an ethical issuehttp://sce.cl.uh.edu/moenc/ethicsTest.html

Software Engineering

Page 44: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

44

Ethics Paper

Assignment due on September 6http://sce.uhcl.edu/moenc/csci3333spring08/EthicsPaper.htm

Some food for thought:

As an ethical software engineer, why is it important for you to choose the most efficient data structures and algorithms in the programs you write for your clients?

Software Engineering

Page 45: 1 Welcome  CSCI 3333 Data Structures Section 03 Thurs., 7:00–9:50 p.m.  Instructor: Charles Moen Email –crmoen@juno.com Web page –

45

References

ACM/IEEE-CS Joint Task Force. (1999). Software Engineering Code of Ethics and Professional Practice. [Online]. Available:http://www.computer.org/tab/seprof/code.htm

Drake, Peter, Data Structures and Algorithms in Java. Upper Saddle River, NJ: Pearson Prentice Hall, 2006.

Goodrich, M. T. and R. Tamassia, Data Structures and Algorithms in Java. Hoboken, NJ: John Wiley & Sons, Inc., 2006.

Harris, J., M. Cummings, and C. Fogliasso, “Ethical Codes and Their Effect on Conduct.” Journal for Computing Sciences in Colleges, October 2002.

Jacobson, I., G. Booch, J. Rumbaugh, The Unified Software Development Process. Boston: Addison-Wesley,1999.

Knuth, D. E., The Art of Computer Programming, Second Edition. (Volumes 1–3). Boston: Addison-Wesley, 1998.

Randell, B., “Software Engineering in 1968,” Proceedings of the 4th International Conference on Software Engineering. Piscataway, NJ: IEEE Press, 1979.

Royce, W., Software Project Management. Boston: Addison-Wesley, 1998.

Sommerville, I. ,Software Engineering. Harlow, England: Addison-Wesley, 2001.

Wirth, N., Algorithms + Data Structures = Programs. Upper Saddle River, NJ: Prentice Hall, 1976.