cse-c1 algs & ds 1 cse–c1 algorithms and data structures 1 lecturer dr.matthew montebello...

12
CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail [email protected] credit 1 lectures 10 assignment 1 (50%) test 1 (50%) •webpage http://staff.um.edu.mt/mmon1/lectures/ dip_cs_edu

Upload: gladys-shelton

Post on 31-Dec-2015

224 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail mmont@cs.um.edu.mt credit 1 lectures 10

CSE-C1 Algs & DS 1

CSE–C1Algorithms and

Data Structures 1•lecturer Dr.Matthew Montebello

•office CB 409

•e-mail [email protected]

•credit 1

•lectures 10

•assignment 1 (50%)

•test 1 (50%)

•webpage

http://staff.um.edu.mt/mmon1/lectures/dip_cs_edu

Page 2: CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail mmont@cs.um.edu.mt credit 1 lectures 10

CSE-C1 Algs & DS 1

Lecture Schedule

1. Introduction to CSE-C1.

2. Abstract Data Types (ADTs)

3. Lists.

4. Stacks.

5. Queues.

6. Deques.

7. Trees.

8. Sets.

9. Past Papers & other Queries.

10. Closure – Pre-Test Revision.

Assign. Out

Assign. In

Page 3: CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail mmont@cs.um.edu.mt credit 1 lectures 10

CSE-C1 Algs & DS 1

Introduction to CSE-C1

• What will happen during lectures.

• Practice makes perfect.

• Web pages of interest:

http://pascal.about.com/compute/ pascal/library/weekly/aa011901.htm

http://taoyue.com/tutorials/pascal

http://www.cs.virginia.edu/~mab8e/ structures.html

http://allserv.rug.ac.be/~vfack/files/ algori.html

• Use of Compiler.

•Other procedures.

Page 4: CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail mmont@cs.um.edu.mt credit 1 lectures 10

CSE-C1 Algs & DS 1

2. Abstract Data Types Today’s lecture:

1. Overview of schedule

2. Recall of last lecture

3. General introd. to DS & Algs.

4. DS in everyday life

5. Introduction to ADTs

6. Overview of ADTs covered

7. Normal processes of an ADT

8. Closure – Summary

9. Next Lecture

10.Questions.

Page 5: CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail mmont@cs.um.edu.mt credit 1 lectures 10

CSE-C1 Algs & DS 1

General Introd. to DS & AlgsA Data Structure is an

Abstract Data Type that has three following components:

1. Operations: Specifications of external appearance of a data structure

2. Storage Structures: Organizations of data implemented in lower level data structures

3. Algorithms: Description on how to manipulate information in the storage structures to obtain the results defined for the operations

Page 6: CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail mmont@cs.um.edu.mt credit 1 lectures 10

CSE-C1 Algs & DS 1

General Introd. to DS & AlgsAn algorithm is a finite set of

instructions chosen from a finite, fixed set of instructions.

Every algorithm must satisfy the following criteria.

1. Input: It has zero or more input parameters.

2. Output: It produces at least one output parameter.

3. Definiteness: Each instruction must be clear and unambiguous.

4. Finiteness: For every input, it executes only a finite number of instructions.

5. Effectiveness: Every instruction must be sufficiently basic so that a machine can execute the instruction.

Page 7: CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail mmont@cs.um.edu.mt credit 1 lectures 10

CSE-C1 Algs & DS 1

DS in Everyday LifeWe use DS in the normal things we

do during the day, like:

• Shopping list

• List of Shores

• Telephone directory

Same thing with algorithms, we implicitly define our own set of instructions on how we manipulate these daily DS, like:

• Add/removing items

• Prioritizing items

• Data to enter with each item

Page 8: CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail mmont@cs.um.edu.mt credit 1 lectures 10

CSE-C1 Algs & DS 1

Introduction to ADTsDefinition of Abstract

Data Type

Class of data objects (i.e., instances of the data type) with a set of the operations that can be applied to the objects (telling what to do instead of how to do)

ADT is specified by

1. a set of operations which can be applied to the objects and

2. a set of properties (called axioms) which all the objects and operations must satisfy.

Page 9: CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail mmont@cs.um.edu.mt credit 1 lectures 10

CSE-C1 Algs & DS 1

Introduction to ADTsAdvantage of Abstract

Data Type

• Modularity (Encapsulation) The definition of operations isolates implementation of ADT from construction of a program using ADT.

• Cohesiveness (Self-maintaining) Implementation of ADT can be changed without modifying programs using ADT.

• Data Abstraction (minimal Coupling) The ADT does not depend on other processes during input or output.

Page 10: CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail mmont@cs.um.edu.mt credit 1 lectures 10

CSE-C1 Algs & DS 1

Introduction to ADTsSimple example of ADTName of ADT :Integer

Operations that it will perform

• Create:Defines an identifier with an undefined value

• Assign:Assigns the value of one integer identifier or value to another integer identifier

• IsEqual:returns true if the values (or values associated with identifiers) of the two integers are the same

• LessThan:returns true if the value of the first integer is less than the value of the second integer

• Negative:returns the negative of the integer value

• Sum:returns the sum of two integer values

Page 11: CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail mmont@cs.um.edu.mt credit 1 lectures 10

CSE-C1 Algs & DS 1

Overview of ADTs coveredAs already discussed and as seen in

the schedule we will be covering in some detail the following DS based on the concept of ADT:

• Lists.

• Stacks.

• Queues.

• Deques.

• Trees.

• Sets.

• Tables

Page 12: CSE-C1 Algs & DS 1 CSE–C1 Algorithms and Data Structures 1 lecturer Dr.Matthew Montebello office CB 409 e-mail mmont@cs.um.edu.mt credit 1 lectures 10

CSE-C1 Algs & DS 1

Normal Process of an ADTThe standard operations that we will

be doing with each of the DS we will be covering will be explained in theory and programmed in the Pascal language.

Operations include:

• Define

• Create

• Add to

• Remove from

• Search

• Empty

•Check if full

•Check if empty

•Destroy