TECHNICAL UNIVERSITY OF CRETE DATA STRUCTURES FILE STRUCTURES



Similar documents
Sources: On the Web: Slides will be available on:

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Physical Data Organization

Class Notes CS Creating and Using a Huffman Code. Ref: Weiss, page 433

Binary Heap Algorithms

Vendor: Crystal Decisions Product: Crystal Reports and Crystal Enterprise

Database 2 Lecture I. Alessandro Artale

Software Engineering Techniques

Chapter 13. Disk Storage, Basic File Structures, and Hashing

Stacks. Linear data structures

Mobile App Design Project #1 Java Boot Camp: Design Model for Chutes and Ladders Board Game

1 Abstract Data Types Information Hiding

A Multi Agent System for MS Windows using Matlab-enabled Agents

Algorithms are the threads that tie together most of the subfields of computer science.

Physical Design. Meeting the needs of the users is the gold standard against which we measure our success in creating a database.

Database Fundamentals

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

CS 111 Classes I 1. Software Organization View to this point:

NCPC 2013 Presentation of solutions

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms

CS 464/564 Introduction to Database Management System Instructor: Abdullah Mueen

Binary Division. Decimal Division. Hardware for Binary Division. Simple 16-bit Divider Circuit

External Sorting. Chapter 13. Database Management Systems 3ed, R. Ramakrishnan and J. Gehrke 1

WESTMORELAND COUNTY PUBLIC SCHOOLS Integrated Instructional Pacing Guide and Checklist Computer Math

APP INVENTOR. Test Review

CS 2112 Spring Instructions. Assignment 3 Data Structures and Web Filtering. 0.1 Grading. 0.2 Partners. 0.3 Restrictions

Ch 7-1. Object-Oriented Programming and Classes

How To Write Portable Programs In C

Model Driven Security: Foundations, Tools, and Practice

4.2 Sorting and Searching

Loop Invariants and Binary Search

Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification:

A Catalogue of the Steiner Triple Systems of Order 19

RN-coding of Numbers: New Insights and Some Applications

ML for the Working Programmer

Topics. Introduction. Java History CS 146. Introduction to Programming and Algorithms Module 1. Module Objectives

NUMBER SYSTEMS. William Stallings

Chapter 7 Event Log. Click the [Alarm (Event Log)] icon, and [Event Log] dialog appears as below:

3 SOFTWARE AND PROGRAMMING LANGUAGES

Section IV.1: Recursive Algorithms and Recursion Trees

External Sorting. Why Sort? 2-Way Sort: Requires 3 Buffers. Chapter 13

TETRIX Add-On Extensions. Encoder Programming Guide (ROBOTC )

Automata and Computability. Solutions to Exercises

MapReduce. MapReduce and SQL Injections. CS 3200 Final Lecture. Introduction. MapReduce. Programming Model. Example

Classification - Examples

Unit Storage Structures 1. Storage Structures. Unit 4.3

CS106A, Stanford Handout #38. Strings and Chars

Unit 5.1 The Database Concept

TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

50 Computer Science MI-SG-FLD050-02

ALLIED PAPER : DISCRETE MATHEMATICS (for B.Sc. Computer Technology & B.Sc. Multimedia and Web Technology)

Principles of Database Management Systems. Overview. Principles of Data Layout. Topic for today. "Executive Summary": here.

Class Overview. CSE 326: Data Structures. Goals. Goals. Data Structures. Goals. Introduction

Report on the Train Ticketing System

Physical DB design and tuning: outline

Data Compression in Blackbaud CRM Databases

1. Relational database accesses data in a sequential form. (Figures 7.1, 7.2)

Efficiency of algorithms. Algorithms. Efficiency of algorithms. Binary search and linear search. Best, worst and average case.

CHAPTER 4 ESSENTIAL DATA STRUCTRURES

Back Propagation Neural Networks User Manual

Logistics. Software Testing. Logistics. Logistics. Plan for this week. Before we begin. Project. Final exam. Questions?

The Tower of Hanoi. Recursion Solution. Recursive Function. Time Complexity. Recursive Thinking. Why Recursion? n! = n* (n-1)!

Chapter 13 Disk Storage, Basic File Structures, and Hashing.

5. A full binary tree with n leaves contains [A] n nodes. [B] log n 2 nodes. [C] 2n 1 nodes. [D] n 2 nodes.

- Easy to insert & delete in O(1) time - Don t need to estimate total memory needed. - Hard to search in less than O(n) time

COMPUTER SCIENCE 1999 (Delhi Board)

Chapter 6: Physical Database Design and Performance. Database Development Process. Physical Design Process. Physical Database Design

The programming language C. sws1 1

Informatica e Sistemi in Tempo Reale

Database Management Systems Comparative Study: Performances of Microsoft SQL Server Versus Oracle

#820 Computer Programming 1A

Discrete Mathematics Problems

Sequential Program Execution

Fact Sheet In-Memory Analysis

First Bytes Programming Lab 2

How to Reduce the Disk Space Required by a SAS Data Set

Output: struct treenode{ int data; struct treenode *left, *right; } struct treenode *tree_ptr;

An Introduction to Computer Science and Computer Organization Comp 150 Fall 2008

Data Structure and Algorithm I Midterm Examination 120 points Time: 9:10am-12:10pm (180 minutes), Friday, November 12, 2010

CS104: Data Structures and Object-Oriented Design (Fall 2013) October 24, 2013: Priority Queues Scribes: CS 104 Teaching Team

Bachelor of Games and Virtual Worlds (Programming) Subject and Course Summaries

The Clean programming language. Group 25, Jingui Li, Daren Tuzi

Binary Number System. 16. Binary Numbers. Base 10 digits: Base 2 digits: 0 1

Introduction to IR Systems: Supporting Boolean Text Search. Information Retrieval. IR vs. DBMS. Chapter 27, Part A

Lecture 10: Dynamic Memory Allocation 1: Into the jaws of malloc()

The Model Checker SPIN

Designing a Schematic and Layout in PCB Artist

Software documentation systems

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Application Development for Mobile and Ubiquitous Computing

There are five fields or columns, with names and types as shown above.

Introduction to Data Structures

7-1. This chapter explains how to set and use Event Log Overview Event Log Management Creating a New Event Log...

Outline BST Operations Worst case Average case Balancing AVL Red-black B-trees. Binary Search Trees. Lecturer: Georgy Gimel farb

AP Computer Science AB Syllabus 1

Recovery System C H A P T E R16. Practice Exercises

Transcription:

TECHNICAL UNIVERSITY OF CRETE DEPT OF ELECTRONIC AND COMPUTER ENGINEERING DATA STRUCTURES AND FILE STRUCTURES Euripides G.M. Petrakis http://www.intelligence.tuc.gr/~petrakis Chania, 2007 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

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

Problem Constraints Each problem puts constraints on time and space e.g., 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.G.M. Petrakis Abstract Data Types (ADT) 4

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.M. Petrakis Abstract Data Types (ADT) 5

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

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.G.M. Petrakis Abstract Data Types (ADT) 7

Abstract Data Type (ADT) ADT: definition of a data type in terms of a set of values and a set of operations allowed on that data type. 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.M. Petrakis Abstract Data Types (ADT) 8

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

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

ADT String: Sequence of chars ADT function length (s: string): integer; post condition : length = len(s); ADT function concat (s 1,s 2 : string): string; post condition: concat = s 1 + s 2 ; ADT function substr (s: string, i, j: integer): string; precondition: 0 < i < len(s), 0 < j < len(s) i + 1 post condition: substr(s, i, j); ADT function pos (s 1, s 2 ): integer; precondition post condition E.G.M. Petrakis Abstract Data Types (ADT) 11

Definition of an 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, its data type can be used by the programmer e.g., string, math libraries in C when the implementation changes the programs need not be changed E.G.M. Petrakis Abstract Data Types (ADT) 12

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.M. Petrakis Abstract Data Types (ADT) 13

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, code and debug E.G.M. Petrakis Abstract Data Types (ADT) 14

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, of any size, 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.M. Petrakis Abstract Data Types (ADT) 15

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

A Termination Problem An algorithm must terminate with the correct solution for any input int OddEven( int n ) { while ( > 1 ) if (( n % 2 ) == 0) n = n / 2; 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

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

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.g., 1, 2, 4, 8Kbytes E.G.M. Petrakis Abstract Data Types (ADT) 19

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