data structure introduction n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
Data Structure: Introduction PowerPoint Presentation
Download Presentation
Data Structure: Introduction

Loading in 2 Seconds...

play fullscreen
1 / 23

Data Structure: Introduction - PowerPoint PPT Presentation


  • 98 Views
  • Uploaded on

Data Structure: Introduction. Instructor: Dr. Engr. Sami ur Rahman. PhD: University of Technology Darmstadt, Germany MS: Freiburg University Germany M.Sc : University of Peshawar Professional Experience May 2013 - till date: Assistant Professor , UoM . 

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Data Structure: Introduction' - lillian-griffith


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
instructor dr engr sami ur rahman
Instructor: Dr. Engr. Sami ur Rahman
  • PhD: University of Technology Darmstadt, Germany
  • MS: Freiburg University Germany
  • M.Sc: University of Peshawar

Professional Experience

  • May 2013 - till date: Assistant Professor ,UoM. 
  • Apr 2009 - Sep 2012: Research Associate, University of Technology Darmstadt, Germany.  Feb 2003– Sep 2006: Lecturer, University of Malakand. 
  • Jan 2003 - Mar 2003: Lecturer, UET Peshawar.
  • Sep 2002 - Jan 2003: Lecturer, Qurtuba University. 
  • Aug 2001 - Oct 2001: Lecturer ,CECOS University. 

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

motivation
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
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
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
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
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
Selecting a Data Structure

Select a data structure as follows:

  • Analyze the problem to determine the resource constraints a solution must meet.
  • Determine the basic operations that must be supported. Quantify the resource constraints for each operation.
  • 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
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
Goals of this Course
  • Reinforce the concept that costs and benefits exist for every data structure.
  • Learn the commonly used data structures.
    • These form a programmer's basic data structure “toolkit.”
  • 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
Arrays
  • Elementary data structure that exists as built-in in most programming languages.

main( intargc, 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

arrays1
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
Array Layout

x[0]

Array cells are contiguous in computer memory

The memory can be thought of as an array

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 | 13

what is array name
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
Array Name
  • ‘x’ is not an lvalueint 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
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 arrays1
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 arrays2
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 arrays3
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 arrays4
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 arrays5
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 arrays6
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

slide23

Questions

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