Dr. Engr. Sami ur Rahman Assistant Professor Department of Computer Science University of Malakand Data Structure: Introduction.

Slides:



Advertisements
Similar presentations
Data Structures Static and Dynamic.
Advertisements

EC-111 Algorithms & Computing Lecture #7 Instructor: Jahan Zeb Department of Computer Engineering (DCE) College of E&ME NUST.
Dynamic Memory Allocation (also see pointers lectures) -L. Grewe.
Programming and Data Structure
Dr. Engr. Sami ur Rahman Assistant Professor Department of Computer Science University of Malakand Medical Imaging Principle of 3D Image acquisition.
Chapter 1 Object Oriented Programming. OOP revolves around the concept of an objects. Objects are crated using the class definition. Programming techniques.
Lecture - 1 on Data Structures. Prepared by, Jesmin Akhter, Lecturer, IIT,JU Data Type and Data Structure Data type Set of possible values for variables.
Arrays Applications of Computer Programming in Earth Sciences Instructor: Dr. Cheng-Chien LiuCheng-Chien Liu Department of Earth Sciences National Cheng.
1 1 Lecture 4 Structure – Array, Records and Alignment Memory- How to allocate memory to speed up operation Structure – Array, Records and Alignment Memory-
CIS 101: Computer Programming and Problem Solving Lecture 9 Usman Roshan Department of Computer Science NJIT.
Abstract Data Types (ADT)
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Coursenotes CS3114: Data Structures and Algorithms Clifford A. Shaffer Yang Cao Department of Computer Science Virginia Tech Copyright ©
HORSEED International University
Introduction - The Need for Data Structures Data structures organize data –This gives more efficient programs. More powerful computers encourage more complex.
1 A Introduction to Data Structures and Algorithm Analysis Data Structures Asst. Professor Kiran Soni.
DATA STRUCTURE Subject Code -14B11CI211.
Data Structures Lecture-1:Introduction
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.
Lecture No.01 Data Structures Dr. Sohail Aslam
Dr. Engr. Sami ur Rahman Assistant Professor Department of Computer Science University of Malakand Data Structure: List.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Lucas Bang Lecture 15: Linked data structures.
Research Methods in Computer Science Lecture: Quantitative and Qualitative Data Analysis | Department of Science | Interactive Graphics System.
ITEC 2620A Introduction to Data Structures
CSC 211 Data Structures Lecture 7
1 MT258 Computer Programming and Problem Solving Unit 7.
Chapter 5: Programming Languages and Constructs by Ravi Sethi Activation Records Dolores Zage.
Comp 245 Data Structures Linked Lists. An Array Based List Usually is statically allocated; may not use memory efficiently Direct access to data; faster.
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
DATA STRUCTURES (CS212D) Week # 1: Overview & Review.
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.
Computer Science and Software Engineering University of Wisconsin - Platteville 2. Pointer Yan Shi CS/SE2630 Lecture Notes.
1 CS 350 Data Structures Chaminade University of Honolulu.
Overview of Course Java Review 1. This Course Covers, using Java Abstract data types Design, what you want them to do (OOD) Techniques, used in implementation.
1 Writing a Good Program 8. Elementary Data Structure.
Chapter 1 Data Structures and Algorithms. Primary Goals Present commonly used data structures Present commonly used data structures Introduce the idea.
Data Structures and Algorithms Lecture 1 Instructor: Quratulain Date: 1 st Sep, 2009.
Data Structures Lecture 1: Introduction. Course Contents Data Types   Overview, Introductory concepts   Data Types, meaning and implementation  
Data Structures Types of Data Structure Data Structure Operations Examples Choosing Data Structures Data Structures in Alice.
Lecture by: Prof. Pooja Vaishnav.  Language Processor implementations are highly influenced by the kind of storage structure used for program variables.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
1 Classes II Chapter 7 2 Introduction Continued study of –classes –data abstraction Prepare for operator overloading in next chapter Work with strings.
Dale Roberts Department of Computer and Information Science, School of Science, IUPUI CSCI 240 Elementary Data Structures Array Lists Array Lists Dale.
REEM ALMOTIRI Information Technology Department Majmaah University.
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
1 A Practical Introduction to Data Structures and Algorithm Analysis Chaminade University of Honolulu Department of Computer Science Text by Clifford Shaffer.
Data Structure and Algorithms
Pointers 1. Introduction Declaring pointer variables Pointer operators Pointer arithmetic 2 Topics to be Covered.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To introduce the basic concepts of linked lists ❏ To introduce the basic concepts.
ARRAYS IN C/C++ (1-Dimensional & 2-Dimensional) Introduction 1-D 2-D Applications Operations Limitations Conclusion Bibliography.
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
Sections Basic Data Structures. 1.5 Data Structures The way you view and structure the data that your programs manipulate greatly influences your.
13 Arrays CE : Fundamental Programming Techniques June 161.
UNIT-II Topics to be covered Singly linked list Circular linked list
Maitrayee Mukerji. INPUT MEMORY PROCESS OUTPUT DATA INFO.
Lecture 1 Data Structures Aamir Zia. Introduction Course outline Rules and regulations Course contents Good Programming Practices Data Types and Data.
Lecture 1 Data Structures & Algorithm CS-102 Lecturer: Syeda Nazia Ashraf 1.
Mohammed I DAABO COURSE CODE: CSC 355 COURSE TITLE: Data Structures.
Advanced Data Structures Lecture 1
Introduction toData structures and Algorithms
CSCI-255 LinkedList.
Data Structure Interview Question and Answers
Data Structures: Introductory lecture
ITEC 2620M Introduction to Data Structures
Arrays Week 2.
By Yogesh Neopaney Assistant Professor Department of Computer Science
C Programming Pointers
Data Structures & Algorithms
SPL – PS2 C++ Memory Handling.
Presentation transcript:

Dr. Engr. Sami ur Rahman Assistant Professor Department of Computer Science University of Malakand Data Structure: Introduction

Instructor: Dr. Engr. Sami ur Rahman o PhD: University of Technology Darmstadt, Germany o MS: Freiburg University Germany o M.Sc: University of Peshawar Professional Experience o May till date: Assistant Professor,UoM. o Apr Sep 2012: Research Associate, University of Technology Darmstadt, Germany. Feb 2003– Sep 2006: Lecturer, University of Malakand. o Jan Mar 2003: Lecturer, UET Peshawar. o Sep Jan 2003: Lecturer, Qurtuba University. o Aug Oct 2001: Lecturer,CECOS University. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 2

Motivation Chairs placement in the class (Demo) Array, stack example University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 3

Data Structures  This course covers well-known data structures such as dynamic arrays, linked lists, stacks, queues, tree and graphs.  Implement data structures in C++ University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 4

Need for Data Structures  Data structures organize data  more efficient programs.  More powerful computers  more complex applications.  More complex applications demand more calculations. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 5

Organizing Data  Any organization for a collection of records that can be searched, processed in any order, or modified.  The choice of data structure and algorithm can make the difference between a program running in a few seconds or many days. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 6

Efficiency  A solution is said to be efficient if it solves the problem within its resource constraints.  Space  Time  The cost of a solution is the amount of resources that the solution consumes. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 7

Selecting a Data Structure Select a data structure as follows: 1.Analyze the problem to determine the resource constraints a solution must meet. 2.Determine the basic operations that must be supported. Quantify the resource constraints for each operation. 3.Select the data structure that best meets these requirements. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 8

Data Structure Philosophy  Each data structure has costs and benefits.  Rarely is one data structure better than another in all situations.  A data structure requires:  space for each data item it stores,  time to perform each basic operation,  programming effort. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 9

Goals of this Course 1.Reinforce the concept that costs and benefits exist for every data structure. 2.Learn the commonly used data structures.  These form a programmer's basic data structure “toolkit.” 3.Understand how to measure the cost of a data structure or program.  These techniques also allow you to judge the merits of new data structures that you or others might invent. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 10

Arrays  Elementary data structure that exists as built-in in most programming languages. main( int argc, char** argv ) { int x[6]; int j; for(j=0; j < 6; j++) x[j] = 2*j; } University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 11

Arrays  Array declaration: int x[6];  An array is collection of cells of the same type.  The collection has the name ‘x’.  The cells are numbered with consecutive integers.  To access a cell, use the array name and an index: x[0], x[1], x[2], x[3], x[4], x[5] University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 12

Array Layout x[1] x[2] x[3] x[4] x[5] x[0] Array cells are contiguous in computer memory The memory can be thought of as an array University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 13

What is Array Name?  int x[6];  ‘x’ is an array name. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 14

Array Name  ‘x’ is not an lvalue int x[6]; int n; x[0] = 5; x[1] = 2; x = 3;// not allowed x = a + b;// not allowed x = &n;// not allowed University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 15

Dynamic Arrays  You would like to use an array data structure but you do not know the size of the array at compile time.  You find out when the program executes that you need an integer array of size n=20.  Allocate an array using the new operator: int* y = new int[20]; // or int* y = new int[n] y[0] = 10; y[1] = 15;// use is the same University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 16

Dynamic Arrays  You would like to use an array data structure but you do not know the size of the array at compile time.  You find out when the program executes that you need an integer array of size n=20.  Allocate an array using the new operator: int* y = new int[20]; // or int* y = new int[n] y[0] = 10; y[1] = 15;// use is the same University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 17

Dynamic Arrays  You would like to use an array data structure but you do not know the size of the array at compile time.  You find out when the program executes that you need an integer array of size n=20.  Allocate an array using the new operator: int* y = new int[20]; // or int* y = new int[n] y[0] = 10; y[1] = 15;// use is the same University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 18

Dynamic Arrays  ‘y’ is a lvalue; it is a pointer that holds the address of 20 consecutive cells in memory.  It can be assigned a value. The new operator returns as address that is stored in y.  We can write: y = &x[0]; y = x;// x can appear on the right // y gets the address of the // first cell of the x array University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 19

Dynamic Arrays  ‘y’ is a lvalue; it is a pointer that holds the address of 20 consecutive cells in memory.  It can be assigned a value. The new operator returns as address that is stored in y.  We can write: y = &x[0]; y = x;// x can appear on the right // y gets the address of the // first cell of the x array University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 20

Dynamic Arrays  ‘y’ is a lvalue; it is a pointer that holds the address of 20 consecutive cells in memory.  It can be assigned a value. The new operator returns as address that is stored in y.  We can write: y = &x[0]; y = x;// x can appear on the right // y gets the address of the // first cell of the x array University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 21

Dynamic Arrays  We must free the memory we got using the new operator once we are done with the y array. delete[ ] y;  We would not do this to the x array because we did not use new to create it. University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 22

Questions University Of Malakand | Department of Computer Science | Visual Computing Research Group | Dr. Engr.Sami ur Rahman | 23