Data Structures and Algorithms Lecture 3 Instructor: Quratulain Date: 8 th September, 2009.

Slides:



Advertisements
Similar presentations
Chapter 1: INTRODUCTION TO DATA STRUCTURE
Advertisements

One Dimensional Arrays
CSCI 311 – Algortihms and Data Structures Steve Guattery Dana 335a (department office) x7-3828
Programming Languages Marjan Sirjani 2 2. Language Design Issues Design to Run efficiently : early languages Easy to write correctly : new languages.
HST 952 Computing for Biomedical Scientists Lecture 10.
Lecture # 02 07/02/2013Dr. Muhammad Umair 1. 07/02/2013Dr. Muhammad Umair 2  Numeric  Integer Numbers  0,10,15,4563 etc.  Fractional Number  10.5,
CHAPTER 3 COLLECTIONS Abstract Data Types. 2 A data type consists of a set of values or elements, called its domain, and a set of operators acting on.
Abstract Data Types (ADT)
Data Structures Introduction. What is data? (Latin) Plural of datum = something given.
Chapter 1 Program Design
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
The Design and Analysis of Algorithms
Introduction - The Need for Data Structures Data structures organize data –This gives more efficient programs. More powerful computers encourage more complex.
DATA STRUCTURE Subject Code -14B11CI211.
Chapter 3 Data Structures and Abstract Data Type Dr. Bernard Chen Ph.D. University of Central Arkansas Fall 2008.
Data Structures 1- Course Syllabus. 2- Introduction about Data Structures.
C o n f i d e n t i a l Developed By Nitendra NextHome Subject Name: Data Structure Using C Title: Overview of Data Structure.
Data Structures CS231 Instructor: Dr. Hammad Majeed Office: Academic Block 4 First Floor.
Addressing Modes Chapter 11 S. Dandamudi To be used with S. Dandamudi, “Fundamentals of Computer Organization and Design,” Springer,  S.
Object Oriented Data Structures
Abstract Data Types (ADTs) and data structures: terminology and definitions A type is a collection of values. For example, the boolean type consists of.
Data Structures and Algorithms. 2 3 Outline What is a data structure Examples –elementary data structures –hash tables Computer capabilities What is.
Data Structures Winter What is a Data Structure? A data structure is a method of organizing data. The study of data structures is particularly important.
Data Structures Lecture 1: Introduction Azhar Maqsood NUST Institute of Information Technology (NIIT)
Chapter 8 Data Abstractions. 2 Chapter 8: Data Abstractions 8.1 Data Structure Fundamentals 8.2 Implementing Data Structures 8.3 A Short Case Study 8.4.
COP1220/CGS2423 Introduction to C++/ C for Engineers Professor: Dr. Miguel Alonso Jr. Fall 2008.
Copyright © 2012 Pearson Education, Inc. Chapter 8 Two Dimensional Arrays.
CS212: DATA STRUCTURES Lecture 1: Introduction. What is this course is about ?  Data structures : conceptual and concrete ways to organize data for efficient.
Prepared By Ms.R.K.Dharme Head Computer Department.
 DATA STRUCTURE DATA STRUCTURE  DATA STRUCTURE OPERATIONS DATA STRUCTURE OPERATIONS  BIG-O NOTATION BIG-O NOTATION  TYPES OF DATA STRUCTURE TYPES.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Lecture 16: Working with Complex Data Arrays. Double-Subscripted Arrays Commonly used to represent tables of values consisting of information arranged.
Chapter 8 Data Abstractions. © 2005 Pearson Addison-Wesley. All rights reserved 8-2 Chapter 8: Data Abstractions 8.1 Data Structure Fundamentals 8.2 Implementing.
1 Data Structures CSCI 132, Spring 2014 Lecture 32 Tables I.
Computer Science: A Structured Programming Approach Using C1 8-7 Two-Dimensional Arrays The arrays we have discussed so far are known as one- dimensional.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
Data Structure Introduction.
Data Structures Lecture 1: Introduction. Course Contents Data Types   Overview, Introductory concepts   Data Types, meaning and implementation  
ELEN 033 Lecture #1 Tokunbo Ogunfunmi Santa Clara University.
Lecture 11 Data Structures, Algorithms & Complexity Introduction Dr Kevin Casey BSc, MSc, PhD GRIFFITH COLLEGE DUBLIN.
Data Abstaraction Chapter 10.
An Introduction to Programming with C++ Fifth Edition Chapter 11 Arrays.
Addressing Modes Chapter 6 S. Dandamudi To be used with S. Dandamudi, “Introduction to Assembly Language Programming,” Second Edition, Springer,
Views of Data Data – nouns of programming world the objects that are manipulated information that is processed Humans like to group information Classes,
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Elementary Data Organization. Outline  Data, Entity and Information  Primitive data types  Non primitive data Types  Data structure  Definition 
Concurrency Properties. Correctness In sequential programs, rerunning a program with the same input will always give the same result, so it makes sense.
Data Structures - Part I CS 215 Lecture 7. Motivation  Real programs use abstractions like lists, trees, stacks, and queues.  The data associated with.
MT311 Java Application Development and Programming Languages Li Tak Sing ( 李德成 )
Computer Science: A Structured Programming Approach Using C1 8-7 Two-Dimensional Arrays The arrays we have discussed so far are known as one- dimensional.
Data Structure and Algorithm: CIT231 Lecture 3: Arrays and ADT DeSiaMore DeSiaMorewww.desiamore.com/ifm1.
1. 2  Introduction  Array Operations  Number of Elements in an array One-dimensional array Two dimensional array Multi-dimensional arrays Representation.
Arrays in MIPS Assembly Computer Organization and Assembly Language: Module 6.
REEM ALMOTIRI Information Technology Department Majmaah University.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
Introduction to Computer Programming using Fortran 77.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture3.
C Programming Lecture 15 Two Dimensional Arrays. Two-Dimensional Arrays b The C language allows arrays of any type, including arrays of arrays. With two.
Lecture 1 Data Structures Aamir Zia. Introduction Course outline Rules and regulations Course contents Good Programming Practices Data Types and Data.
Introduction toData structures and Algorithms
Data Structures and Algorithms
GC211Data Structure Lecture2 Sara Alhajjam.
Introduction to Data Structure
CIS16 Application Development and Programming using Visual Basic.net
Introduction to Data Structures
Introduction to Data Structure
Abstract Data Types, Elementary Data Structures and Arrays
A type is a collection of values
Presentation transcript:

Data Structures and Algorithms Lecture 3 Instructor: Quratulain Date: 8 th September, 2009

Introduction Algorithms ◦ Outline the computational procedure, step by step instructions. Include search, delete, sort etc. Program ◦ Implementation of algorithm in some programming language Data Structures ◦ Organization of data need to solve the problem CSE 246 Data Structures and Algorithms Fall2009 Quratulain2

Data Structures There are a number of facets to good programs: they must run correctly run efficiently be easy to read and understand be easy to debug and be easy to modify. This course will focus on solving problems efficiently: you will be introduced to a number of fundamental data structures and algorithms for manipulating them. CSE 246 Data Structures and Algorithms Fall2009 Quratulain3

Information and Meaning CSE 246 Data Structures and Algorithms Fall2009 Quratulain4

Abstract Data Type A data type whose properties (domain and operations) are specified independently of any particular implementation. ADT is a mathematical model which gives the a set of utilities available to the user but never states the details of its implementation. Focusing on what it does and ignoring how it does its job In OO-Programming a Class is an ADT 5CSE 246 Data Structures and Algorithms Fall2009 Quratulain

A Real Life Example: why data structures? Electronic Phone Book Contains different DATA: - names - phone number - addresses Need to perform certain OPERATIONS: - add - delete - look for a phone number - look for an address How to organize the data so to optimize the efficiency of the operations. ADT is Phone Book CSE 246 Data Structures and Algorithms Fall2009 Quratulain6

ADT 7 When we use abstract datatypes, our programs divide into two pieces: The Application: The part that uses the abstract datatype. The Implementation: The part that implements the abstract datatype.

Abstract Data Type A type is a collection of values. For example, the boolean type consists of two values, true and false; the byte type consists of all integers between -127 and A data type is a type + a set of operations on data of the type. For example, integers of type byte plus {+, -, *, /} comprise the data type byte. An integer array is a data type which has assign and search operations associated with it. An abstract data type is a data type solely defined in terms of a type and a set of operations on that type. Each operation is defined in terms of its input and output without specifying how the data type is implemented. A stack is an example of an ADT, defined in terms of push and pop operations. A data structure is an implementation of an ADT. The Stack ADT, for example, an be implemented by means of an array. CSE 246 Data Structures and Algorithms Fall2009 Quratulain8

Levels of abstraction in data specification Any data can be defined in two formats: logical and physical. An ADT defines data in a logical format -- as a conceptual model, which is completely independent of its implementation. Consider, for example, a matrix of integers. At a logical level, we are not interested in how this matrix is implemented. The only items of interest are what type of data this matrix consists of, and what operations will be performed on this data. At a physical level, the associated data structure representing the Matrix ADT can be implemented with a different degree of abstraction by means of: ◦ a high level language, in which case the Matrix ADT can be defined as an array of integers. ◦ in assembly language (or byte code) it is represented as a sequence of words in computer memory. ◦ in machine language it is represented as a sequence of electronic bits. CSE 246 Data Structures and Algorithms Fall2009 Quratulain9

The Matrix example (cont.) The ADT Matrix, in more formal terms, can de defined as a collection of data items of type MatrixData arranged as a rectangular grid, and associated with the following set of operations: ◦ Retrieve (M, row#, col#) ◦ Assign (M, row#, col#, value) To implement the ADT matrix, we can use a two-dimensional array. For example: int[ ][ ] M = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}} The retrieve and assign operations can be implemented as follows: item = M[1][2] M[2][3] = item CSE 246 Data Structures and Algorithms Fall2009 Quratulain10

Representation of Multi-dimensional arrays in computer memory Computer memory is a linear sequence of memory cells. There are two ways to translate a two-dimensional array into a linear sequence: 1. Row by row (this is called the row-major form). To implement assign and retrieve operations, we must be able to find a particular entry. This can be done by means of the following formula (called a mapping function): (# of columns * (i - 1) + j), where i is the specified row#, and j is the specified col#. 2. Column by column (this is called the column-major form) in which case the mapping function is (# of rows * (j - 1) + i). CSE 246 Data Structures and Algorithms Fall2009 Quratulain11

Row Major Ordering CSE 246 Data Structures and Algorithms Fall2009 Quratulain12 Another view For a three-dimensional array, the formula to compute the offset into memory is the following: Address = Base + ((depthindex*col_size+colindex) * row_size + rowindex) * Element_Size For a two-dimension row major ordered array declared in Pascal as "A:array [0..3,0..3] of integer" is Element_Address = Base_Address + (colindex * row_size + rowindex) * Element_Size For a four dimensional array, the formula for computing the address of an array element is Address = Base + (((LeftIndex * depth_size + depthindex)*col_size+colindex) * row_size + rowindex) * Element_Size

Column Major Ordering CSE 246 Data Structures and Algorithms Fall2009 Quratulain13 For a two-dimension column major array: Element_Address = Base_Address + (rowindex * col_size + colindex) * Element_Size For a three-dimension column major array: Address = Base + ((rowindex*col_size+colindex) * depth_size + depthindex) * Element_Size For a four-dimension column major array: Address = Base + (((rowindex * col_size + colindex)*depth_size + depthindex) * Left_size + Leftindex) * Element_Size