SlideShare a Scribd company logo
4
Most read
5
Most read
6
Most read
Elementary of
Data Structure &
Algorithms
B. MANDAL
Basic Terminology
A good program is that
 Runs correctly
 Easy to read & understand
 Easy to debug
 Easy to modify
A program should undoubtedly
 Gives correct result &
 Efficiently
To write efficient programs – we need to
enforce certain data management concepts
 A group of data elements that put together under one
name.
 Data Structure is a way of storing and organizing
data in computer system.
 Logically &
 Mathematically
 Purpose :– For efficient access of stored data
Data Structure
 Data: a value or set of values
 Record: collection of data items
 E.g. name, address & subject for a particular student
 File: collection of related records [Dictionary]
 Key: one or more data item(s) which will uniquely
identify each records form a file.
Data Structure – Elementary
 Primitive: atomic, fundamental data types (e.g. integer,
real, Boolean)
 Non-primitive: derived from primitive DS (e.g. array,
structure)
 Linear: elements are stored in linear or sequential manner.
 Linear memory allocations
 Linear relationship between elements
 E.g. Array, linked list, Stack, Queue …
 Non-Linear: elements are not stored in linear manner.
 E.g. Graph, Tree
Classification of Data Structure
 Traversing: Accessing each data item exactly once
 Searching: Finding location of one/more data items
 Inserting: Add new data items
 Deleting: Removing data
 Sorting: Arranging data
 Merging: Combining set of data
Operations on Data Structure
 Way we look at a Data Structure
 Focusing on what it dose
 Ignoring implementation details
 E.g. List, Stack, Queue …
 Real world problem solving
Abstract Data Type (ADT)
 Any well-defined computational procedure
 Takes some value, or set of values, as input
 produces some value, or set of values, as output
An algorithm is a sequence of computational steps that
transform the input into the output.
 For a particular problem – we may have several
algorithms
 One algorithm may not fit for other problems
Algorithm
 Ex. Searching an element from a list
Algo: Search(A, key, N)
{
For i=0 to N
if( A[i] == key )
RETURN (i)
RETURN (-1)
}
 Ex. GCD of two number
Al go rith m: G CD(a, b)
{
wh il e (a ≠ b)
{
if a > b
a ← a – b
el se
b ← b – a
}
R ETU R N (a)
}
 Ex. Factorial of positive integer
Algorithm: Factorial(n)
{
Fact ← 1
If n = 1
return (1)
else
Fact ← n * Factorial(n - 1)
return (Fact)
}
 Collection of similar data item
 Referred by a common name
 Contiguous memory allocation
 E.g. int Student[10];
Array
2-Dimentional Array
 E.g. char matrix[5] [4];

 E.g. char matrix[6] [12];
 Will not fit

 2-dimensional array mapped to 1-dimensional array
 Special way to access
 E.g.
char A[3][4];
A ⇒ 0 1 2 3
0
1
2
A´ ⇒
Representation in Memory
a b c d
e f g h
i j k l
a b c d e f g h i j k l
0 1 2 3 4 5 6 7 8 9 10 11
A [row][col] = A´ [row * m + col]
m  # columns
Dynamic Memory Allocation
 Calloc – contiguous memory allocation
 Arr = (int *) calloc(n, sizeof(int))
 Malloc – block of memory allocation
 Arr = (int *) malloc(n * sizeof(int))
 Free: release memory
 free(Arr)
 **Arr is a pointer to integer
Thank You 

More Related Content

PPTX
Operators and expressions in C++
PPTX
Subroutines
PPTX
Control Flow Statements
PDF
Introduction to c++ ppt 1
PDF
Lecture 01 introduction to compiler
PPT
Character generation
PPTX
Software Engineering unit 3
PPTX
Conditional statements
Operators and expressions in C++
Subroutines
Control Flow Statements
Introduction to c++ ppt 1
Lecture 01 introduction to compiler
Character generation
Software Engineering unit 3
Conditional statements

What's hot (20)

PDF
10. switch case
PPTX
Union in C programming
PPSX
Break and continue
PPT
Introduction to Compiler design
PPTX
Types of Compilers
PPTX
Floating point representation
PPTX
Data types in C
PPT
structure and union
PPTX
Code Generation
PPTX
Decision making and branching in c programming
DOCX
Behavioural modelling
PPT
Branching in C
PDF
Object oriented programming c++
PDF
Algorithms Lecture 1: Introduction to Algorithms
PPTX
Object Oriented Programming
PPSX
Type conversion
PPTX
Software myths | Software Engineering Notes
PPTX
classes and objects in C++
PPTX
Data types in c++
10. switch case
Union in C programming
Break and continue
Introduction to Compiler design
Types of Compilers
Floating point representation
Data types in C
structure and union
Code Generation
Decision making and branching in c programming
Behavioural modelling
Branching in C
Object oriented programming c++
Algorithms Lecture 1: Introduction to Algorithms
Object Oriented Programming
Type conversion
Software myths | Software Engineering Notes
classes and objects in C++
Data types in c++
Ad

Similar to Elementary data structure (20)

PDF
DS Complete notes for Computer science and Engineering
PPTX
Datastructures using c++
PPTX
Bsc cs ii dfs u-1 introduction to data structure
PPTX
Mca ii dfs u-1 introduction to data structure
PPTX
Bca ii dfs u-1 introduction to data structure
DOCX
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
PDF
Unit-I-DAA.pdf
PPT
PDF
DATA STRUCTURES USING C -ENGGDIGEST
PPTX
Data structures in c#
PPTX
Data Structure Introduction for Beginners
PPT
Lect4
PPTX
Introduction to data structures using c/c++.pptx
PPT
Data structures
PPTX
Data structure.pptx
PPTX
Introduction to Data Structure part 1
PPTX
Unit 3_Numpy_VP.pptx
PPTX
data structure unit -1_170434dd7400.pptx
PPTX
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
PPTX
Manipulation and Python Tools-fundamantals of data science
DS Complete notes for Computer science and Engineering
Datastructures using c++
Bsc cs ii dfs u-1 introduction to data structure
Mca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Unit-I-DAA.pdf
DATA STRUCTURES USING C -ENGGDIGEST
Data structures in c#
Data Structure Introduction for Beginners
Lect4
Introduction to data structures using c/c++.pptx
Data structures
Data structure.pptx
Introduction to Data Structure part 1
Unit 3_Numpy_VP.pptx
data structure unit -1_170434dd7400.pptx
DATA STRUCTURE CLASS 12 COMPUTER SCIENCE
Manipulation and Python Tools-fundamantals of data science
Ad

Recently uploaded (20)

PPTX
Internet of Things (IOT) - A guide to understanding
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
OOP with Java - Java Introduction (Basics)
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PPTX
web development for engineering and engineering
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
PPTX
Safety Seminar civil to be ensured for safe working.
PPTX
Construction Project Organization Group 2.pptx
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
composite construction of structures.pdf
PDF
737-MAX_SRG.pdf student reference guides
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
PPT
Project quality management in manufacturing
Internet of Things (IOT) - A guide to understanding
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
OOP with Java - Java Introduction (Basics)
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Fundamentals of safety and accident prevention -final (1).pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
web development for engineering and engineering
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
BMEC211 - INTRODUCTION TO MECHATRONICS-1.pdf
Safety Seminar civil to be ensured for safe working.
Construction Project Organization Group 2.pptx
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
UNIT-1 - COAL BASED THERMAL POWER PLANTS
composite construction of structures.pdf
737-MAX_SRG.pdf student reference guides
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Unit I ESSENTIAL OF DIGITAL MARKETING.pdf
Project quality management in manufacturing

Elementary data structure

  • 1. Elementary of Data Structure & Algorithms B. MANDAL
  • 2. Basic Terminology A good program is that  Runs correctly  Easy to read & understand  Easy to debug  Easy to modify A program should undoubtedly  Gives correct result &  Efficiently To write efficient programs – we need to enforce certain data management concepts
  • 3.  A group of data elements that put together under one name.  Data Structure is a way of storing and organizing data in computer system.  Logically &  Mathematically  Purpose :– For efficient access of stored data Data Structure
  • 4.  Data: a value or set of values  Record: collection of data items  E.g. name, address & subject for a particular student  File: collection of related records [Dictionary]  Key: one or more data item(s) which will uniquely identify each records form a file. Data Structure – Elementary
  • 5.  Primitive: atomic, fundamental data types (e.g. integer, real, Boolean)  Non-primitive: derived from primitive DS (e.g. array, structure)  Linear: elements are stored in linear or sequential manner.  Linear memory allocations  Linear relationship between elements  E.g. Array, linked list, Stack, Queue …  Non-Linear: elements are not stored in linear manner.  E.g. Graph, Tree Classification of Data Structure
  • 6.  Traversing: Accessing each data item exactly once  Searching: Finding location of one/more data items  Inserting: Add new data items  Deleting: Removing data  Sorting: Arranging data  Merging: Combining set of data Operations on Data Structure
  • 7.  Way we look at a Data Structure  Focusing on what it dose  Ignoring implementation details  E.g. List, Stack, Queue …  Real world problem solving Abstract Data Type (ADT)
  • 8.  Any well-defined computational procedure  Takes some value, or set of values, as input  produces some value, or set of values, as output An algorithm is a sequence of computational steps that transform the input into the output.  For a particular problem – we may have several algorithms  One algorithm may not fit for other problems Algorithm
  • 9.  Ex. Searching an element from a list Algo: Search(A, key, N) { For i=0 to N if( A[i] == key ) RETURN (i) RETURN (-1) }
  • 10.  Ex. GCD of two number Al go rith m: G CD(a, b) { wh il e (a ≠ b) { if a > b a ← a – b el se b ← b – a } R ETU R N (a) }
  • 11.  Ex. Factorial of positive integer Algorithm: Factorial(n) { Fact ← 1 If n = 1 return (1) else Fact ← n * Factorial(n - 1) return (Fact) }
  • 12.  Collection of similar data item  Referred by a common name  Contiguous memory allocation  E.g. int Student[10]; Array
  • 13. 2-Dimentional Array  E.g. char matrix[5] [4]; 
  • 14.  E.g. char matrix[6] [12];  Will not fit 
  • 15.  2-dimensional array mapped to 1-dimensional array  Special way to access  E.g. char A[3][4]; A ⇒ 0 1 2 3 0 1 2 A´ ⇒ Representation in Memory a b c d e f g h i j k l a b c d e f g h i j k l 0 1 2 3 4 5 6 7 8 9 10 11 A [row][col] = A´ [row * m + col] m  # columns
  • 16. Dynamic Memory Allocation  Calloc – contiguous memory allocation  Arr = (int *) calloc(n, sizeof(int))  Malloc – block of memory allocation  Arr = (int *) malloc(n * sizeof(int))  Free: release memory  free(Arr)  **Arr is a pointer to integer