## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

DEPT OF ELECTRONIC AND COMPUTER ENGINEERING

DATA STRUCTURES

AND

FILE STRUCTURES

Euripides G.M. Petrakis

http://www.intelligence.tuc.gr/~petrakis

Chania, 2014

E.G.M. Petrakis

Abstract Data Types (ADT)

1

Introduction

! We study data structures and we

learn how to write efficient programs

! this hasn’t to do with programming tricks

but rather with

! good organization of information and

good algorithms that save

! computer memory and running time

E.G.M. Petrakis

Abstract Data Types (ADT)

2

.M.Data Structures ! Representation of data in the memory ! file structure: representation of data on the disk ! e. tree.g. etc) ! Efficient programs require efficient data structures ! a problem has to be solved within the given time and space constraints E.G. collection of records (list. Petrakis Abstract Data Types (ADT) 3 .

bank example: ! start account: a few minutes ! transactions: a few seconds ! close account: overnight ! A solution is efficient if it solves the problem within its space and time constraints ! Cost of solution: amount of resources consumed E.M. Petrakis Abstract Data Types (ADT) 4 .g.Problem Constraints ! Each problem puts constraints on time and space ! e..G.

Petrakis Abstract Data Types (ADT) 5 .M.Goals of this course ! Teach data structures for main memory and disk ! Teach algorithms for different tasks and data structures ! Teach the idea of trade-offs ! there are costs and benefits associated with each data structure and each algorithm ! Teach how to measure effectiveness of each algorithm and data structure E.G.

• e.G. record search. Quantify the constraints for each operation 4. Determine the operations that must be supported • e.Selecting Data Structures 1.g. deletion etc. Petrakis Abstract Data Types (ADT) 6 . insertion. Select data structure that best meet these requirements E.g.M.. search operations must be very fast 3.. Analyze the problem to determine the resource constraints a solution must meet 2.

Costs & Benefits ! Each data structure requires: ! space for each data item it stores ! time to perform each operation ! programming effort to implement it ! Each data structure has costs and benefits ! rarely one data structure is better than another in all situations ! one may permit faster search (or insertion or deletion) operations than another ! are all operations the same important? E.M.G. Petrakis Abstract Data Types (ADT) 7 .

inputs-outputs and ! a set of operations allowed on that data type.M. Petrakis Abstract Data Types (ADT) 8 .Abstract Data Type (ADT) ! ADT: definition of a data type in terms of ! a set of values. ! Each ADT operation is defined by its inputs and outputs ! ADTs hide implementation details ! A data structure is the implementation of an ADT ! operations associated with the ADT are implemented by one or more functions E.G.

post condition : length = len(s). s2): integer. ! ADT function substr (s: string. post condition: concat = s1 + s2. Petrakis Abstract Data Types (ADT) 9 . i.G. precondition … post condition … E.M. • ADT function concat (s1.s2: string): string. 0 < j < len(s) – i + 1 post condition: substr(s. ! ADT function pos (s1.ADT String: Sequence of chars • ADT function length (s: string): integer. precondition: 0 < i < len(s). i. j: integer): string. j).

. Physical form: implementation of the data item ! e. 16 or 32 bit integers E. Petrakis Abstract Data Types (ADT) 10 .Logical and Physical forms ! Data items have both a logical and a physical form 1. - 2.M.g. Logical form: definition of the data item within an ADT ! e.G. integers in mathematical sense: +.g..

M.G. Petrakis Data Items: Logical Form Data Items: Physical Form Abstract Data Types (ADT) 11 .Data Type ADT:Type + Operations Data Structure: Storage Space + functions E.

.What ADT ! Depends on the application ! Different definitions for the same application ! An ADT hides implementation details ! different implementations for the same ADT ! When the ADT is given.M. math libraries in C ! when the implementation changes the programs need not be changed E.g. Petrakis Abstract Data Types (ADT) 12 . string.G. its data type can be used by the programmer ! e.

M. Petrakis Abstract Data Types (ADT) 13 .Algorithms ! The method that solves a problem ! An algorithm takes the input to a problem and transforms it to the output ! a mapping of input to output ! a problem can have many algorithms ! A program is the implementation of an algorithm in some programming language E.G.

code and debug E. Petrakis Abstract Data Types (ADT) 14 .M.Properties of Algorithms ! Effectiveness: the algorithm can be written as a program ! there are problems for which no algorithm exists ! Correctness: finds the correct solution for every input ! Termination: terminates after a finite number of steps ! each step requires a finite amount of time ! Efficiency: makes efficient use of the computer’s resources ! Complexity: it must be easy to implement.G.

M. Petrakis Abstract Data Types (ADT) 15 .Tiling Problem ! The algorithm inputs a finite set T of tiles ! it is assumed that an unlimited number of cards of each type is available ! asks whether any finite area. can be covered using tiles in T so that ! the colors in any two touching edges are the same ! For any algorithm there can be inputs T for which the algorithm never terminates or finds a wrong answer E.G. of any size.

G. Petrakis Abstract Data Types (ADT) 16 .M. David Harel.Tile tile types that can tile any area Tile tile types that cannot tile any area From “Algorithmics”. E.

else n = 3n + 1. return n. } ! No one has been able to prove that the algorithm terminates for any positive n although most people believe that it does!! E.G.M. Petrakis Abstract Data Types (ADT) 17 .A Termination Problem ! An algorithm must terminate with the correct solution for any input int OddEven( int n ) { while ( n > 1 ) if (( n % 2 ) == 0) n = n / 2.

Petrakis Abstract Data Types (ADT) 18 .G.Taxonomy of Algorithms ! An algorithmic problem that admits no algorithm is termed “noncomputable” ! If it is a decision problem it is termed “undecidable” E.M.

M. 4. 2.Disk Model ! T = Taccess + Trotation + Tread ! Block: unit memory size for disk ! size of data transferred in main memory per disk access ! In most cases page=block=track ! e. 8Kbytes E. 1.G.g.. Petrakis Abstract Data Types (ADT) 19 .

) ! Taccess > Trotation > Tread ! increase the amount of data which is transferred to the main memory per disk access ! large blocks.Disk Model (cont.M. data in memory ! in multi-user systems.G. the disk head can be anywhere time distance covered by disk head E. compression. Petrakis Abstract Data Types (ADT) 20 .

- As It Dot Netuploaded byRobert Robertson
- 1-Saphub Abap Basicsuploaded byKIRAN
- Faq 1 vhdluploaded bySIVA KRISHNA PRASAD ARJA
- A Case for Lamport Clocksuploaded bythrw3411
- CS 106syllabusuploaded bygel4i
- Report Best REKHAuploaded bysatyakalyanforu
- MELJUN CORTES MELJUN_Intro_to_C_Programminguploaded byMELJUN CORTES, MBA,MPA
- lec2uploaded bytopherski
- SQL Data Typesuploaded byahtesham999
- Java Methodsuploaded bymfeld1952
- Access Labuploaded byflying_alexutza
- gsjavauploaded byHamdi Belal
- BCA 303 Unit 2 Notesuploaded byVinay Garg
- Ch02 Primitive Data Definite Loopsuploaded byNiha Ch
- Vhdl Design and Synthesisuploaded bykranthi633
- Programming Languageuploaded bylalitprrasadsingh
- 15.GO_NA23_E1_1 GSM Power Control Algorithm-34uploaded byTri Nguyen
- Mcquploaded bySouvik Halder
- 42 45 SeqClustering.psuploaded bynpnbkck
- 70-540-pdf-dumpsuploaded bydeepa.n6213
- Paper Types Transf Reviewuploaded byvthung
- In Touch Clientuploaded byJose Montes
- Dev 401 Guess Paper 1uploaded bypreethiram4
- Validation module main featuresuploaded byHai Do
- LVCore1 CourseManual English Sampleuploaded byAsif Basha
- C Programming Notesuploaded byAnurag Goel
- Oracle Call Interface(OCI)uploaded byDaaray Cheikhoul Xadim
- In Touch Clientuploaded byArun Sharma
- Java Introuploaded bysemamumcu
- A Sequence of Lab Exercises for an Introductory Compiler Construction Courseuploaded byfareehaiftikhar

- Ηλεκτρονική ΙΙ_4uploaded byalexisthe
- ACE201labnotes_2uploaded byalexisthe
- Ηλεκτρονική ΙΙ_3uploaded byalexisthe
- Ηλεκτρονική ΙΙ - 1uploaded byalexisthe
- λογική σχεδίασηuploaded byalexisthe
- ΤΗΛ2uploaded byalexisthe
- στοχαστικές διαδικασίεςuploaded byalexisthe
- λογική σχεδίασηuploaded byalexisthe
- Μπροσουράκι Πανεπιστήμιοuploaded byalexisthe
- Kurdish Folktalesuploaded byalexisthe
- λογική σχεδίασηuploaded byalexisthe
- Ηλεκτρονική ΙΙ_2uploaded byalexisthe
- COMP211slides_13uploaded byalexisthe
- TEL202coursedoc_11uploaded byalexisthe
- COMP211slides_14uploaded byalexisthe
- COMP211slides_9uploaded byalexisthe
- COMP211slides_8uploaded byalexisthe
- COMP211slides_12uploaded byalexisthe
- COMP211slides_4uploaded byalexisthe
- Prob Solved 2ndeditionuploaded byalexisthe
- COMP211slides_5uploaded byalexisthe
- Προκαταρκτική Έκθεση Επιτροπής Αλήθειας Δημοσίου Χρέουςuploaded byalexisthe
- COMP211slides_9uploaded byalexisthe
- COMP211slides_4uploaded byalexisthe
- Αλβάρο Γκαρσία Λινέρα: Για την Αριστερά του 21ου αιώναuploaded byalexisthe
- TEL202coursedoc_11uploaded byalexisthe
- COMP211slides_6uploaded byalexisthe
- COMP211slides_11uploaded byalexisthe
- COMP211slides_10uploaded byalexisthe
- COMP211slides_7uploaded byalexisthe

Close Dialog## Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

Loading