1
Basics of
Data
Structure
DS 2
PROGRAMMING
METHODOLOGY
DS 3
 Data Structure is structural representation of logical relationship between
elements of Data.
 DS is used for utilizing the maximum efficiency of Memory
 Organized Data + Operation = Data Structure
 Algorithm + Data Structure = Program.
 ALGORITHM : It’s a step by step finite sequence of instruction to solve a well
defined computational problem.
 Optimization of program is directly concerned with the algorithm design.
 Representation of DS in memory of a computer is called storage structure.
 A Storage structure stored in auxiliary memory is known as File Structure.
TERMINOLOGY
DS 4
Informal
Algorithm
Mathematical
Model
Psedo–
Language
Program
Formal
Language
C / C++
Program
Data
Structure
STEP WISE REFINEMENT
DS 5
 Modular Programming is an act of writing programs as functions, that each
one perform a single well defined task, and which have minimum interaction
between them.
 High cohesion : Related with specific task only.
 Low Coupling : Independent from each other.
 Two Methods:
(i). TOP – DOWN Methodology (eg. C, C++ Programming)
(ii). BOTTOM – UP Methodology (eg. VB Project implementation)
MODULAR PROGRAMMING
DS 6
Main
Function 1 Function 2 Function 3
Function a Function b Function c Function c Function b Function d
Functions called By Function 1 Functions called By Function 3
Functions called
By Function 1
PROGRAMMING APPROCH
DS 7
 Sequence of sequentially executed statements
 Conditional Execution (if)
 Looping or iteration (for, while, do-while)
 Structured Subroutine (Function)
STRUCTURED PROGRAMMING
DS 8
ARRAYS
 An array is a collection of homogeneous
data elements described by a single name.
 Insertion and Deletion can not be made.
i. 1-D Array
ii. 2-D Array
iii. M-D Array
iv. Sparse Arrays
VECTOR
 1-D ordered collection of number
i. Row Vector
ii. Column Vector
LISTS
 A list is an ordered set consisting of a varying
number of elements to which insertion and
deletion can be made
12
52
35
10 11
12
13
14
15
START
11 12 13 14 15
SOME D.S.
DS 9
FILES & RECORDS
 File is typically large list that is stored in the
external memory of computer.
 A record is collection of information about some
particular entity.
 Record may be collection of heterogeneous data.
 File is collection of such a records.
CHARECTERISTICS
OF STRING
 Fixed length string
 Variable length string
 Linear list (Linked List)
DS 10
Data
Structure
Primitive
Data Structure
Non-Primitive
Data Structure
int char float pointer
Linear
list
Graph Tree
list
Array File
Non - Linear
list
Stack Queue
CLASSIFICATION OF D.S.
DS 11
 malloc ()
 Allocates 1 block of memory
ptr=(Data_Type *)malloc(n * sizeof(Data_Type));
 callloc ()
 Allocates n block of memory
ptr=(Data_Type *)calloc(n , sizeof(Data_Type));
 realloc ()
 Resize the original block of memory
ptr=realloc(ptr, NewSize);
 free ()
 Free up the memory block
free (ptr);
 Dynamic or Run Time memory
allocation (Linked list)
 Static or Compile Time
memory allocation (Array)
int a, array[10];
char str[80];
Dynamic memory
allocation in C++
int *var1 = new int;
float *var2 = new float;
delete var1;
delete var2;
MEMORY MANAGEMENT
DS 12
 Free Storage List
 Garbage Collection
 Dangling Reference
 Reference Counter
MEMORY MANAGEMENT
DS 13

00. Basics of Data Structures.ppt

  • 1.
  • 2.
  • 3.
    DS 3  DataStructure is structural representation of logical relationship between elements of Data.  DS is used for utilizing the maximum efficiency of Memory  Organized Data + Operation = Data Structure  Algorithm + Data Structure = Program.  ALGORITHM : It’s a step by step finite sequence of instruction to solve a well defined computational problem.  Optimization of program is directly concerned with the algorithm design.  Representation of DS in memory of a computer is called storage structure.  A Storage structure stored in auxiliary memory is known as File Structure. TERMINOLOGY
  • 4.
  • 5.
    DS 5  ModularProgramming is an act of writing programs as functions, that each one perform a single well defined task, and which have minimum interaction between them.  High cohesion : Related with specific task only.  Low Coupling : Independent from each other.  Two Methods: (i). TOP – DOWN Methodology (eg. C, C++ Programming) (ii). BOTTOM – UP Methodology (eg. VB Project implementation) MODULAR PROGRAMMING
  • 6.
    DS 6 Main Function 1Function 2 Function 3 Function a Function b Function c Function c Function b Function d Functions called By Function 1 Functions called By Function 3 Functions called By Function 1 PROGRAMMING APPROCH
  • 7.
    DS 7  Sequenceof sequentially executed statements  Conditional Execution (if)  Looping or iteration (for, while, do-while)  Structured Subroutine (Function) STRUCTURED PROGRAMMING
  • 8.
    DS 8 ARRAYS  Anarray is a collection of homogeneous data elements described by a single name.  Insertion and Deletion can not be made. i. 1-D Array ii. 2-D Array iii. M-D Array iv. Sparse Arrays VECTOR  1-D ordered collection of number i. Row Vector ii. Column Vector LISTS  A list is an ordered set consisting of a varying number of elements to which insertion and deletion can be made 12 52 35 10 11 12 13 14 15 START 11 12 13 14 15 SOME D.S.
  • 9.
    DS 9 FILES &RECORDS  File is typically large list that is stored in the external memory of computer.  A record is collection of information about some particular entity.  Record may be collection of heterogeneous data.  File is collection of such a records. CHARECTERISTICS OF STRING  Fixed length string  Variable length string  Linear list (Linked List)
  • 10.
    DS 10 Data Structure Primitive Data Structure Non-Primitive DataStructure int char float pointer Linear list Graph Tree list Array File Non - Linear list Stack Queue CLASSIFICATION OF D.S.
  • 11.
    DS 11  malloc()  Allocates 1 block of memory ptr=(Data_Type *)malloc(n * sizeof(Data_Type));  callloc ()  Allocates n block of memory ptr=(Data_Type *)calloc(n , sizeof(Data_Type));  realloc ()  Resize the original block of memory ptr=realloc(ptr, NewSize);  free ()  Free up the memory block free (ptr);  Dynamic or Run Time memory allocation (Linked list)  Static or Compile Time memory allocation (Array) int a, array[10]; char str[80]; Dynamic memory allocation in C++ int *var1 = new int; float *var2 = new float; delete var1; delete var2; MEMORY MANAGEMENT
  • 12.
    DS 12  FreeStorage List  Garbage Collection  Dangling Reference  Reference Counter MEMORY MANAGEMENT
  • 13.