SlideShare a Scribd company logo
1 of 20
Data Structures
Introduction
What is Data Structure?
• The Logical or Mathematical model of a
particular organization of data.
• Data Structures may be divided into two
types:-
1. Linear Data Structures
2. Non Linear Data Structures
Linear Data Structures
• If the elements of a data structure are
stored sequentially. e.g.
1. Arrays
2. Linked Lists
3. Stacks
4. Queues
Non Linear Data Structures
• If the elements of a data structure are not
stored in a sequential order. e.g.
1. Trees
– Represent Hierarchical relationship between
nodes
2. Graphs
– Represent relationship between pairs of
elements which is not necessarily
hierarchical in nature
Data Structure Operations
1. Traversing
– Accessing each record exactly once so that
certain items in the record may be
processed
2. Searching
– Finding the location of the record with the
given key value
3. Inserting:- Adding a new record
4. Deleting:- Removing a record
Abstract Data Types
• A useful tool for specifying the logical
properties of a data type is the ADT
• It is the way we look at a data structure,
focusing on what it does and ignoring how
it does its job.
• Abstract means considered apart from
the detailed specification or
implementation
• Data Type is a collection of values and a
set of operations on those values
Abstract Data Types (contd..)
• ADT can be a structure considered without
regard to its implementation
OR
• It can be thought of as a description of the
data in the structure with a list of
operations that can be performed on the
data within the structure
• e.g. stack.h file has been provided for
performing the operations over stack
Specifying an ADT
• An ADT consists of two parts:
– a value definition and
– An operator definition
• The value definition defines the collection
of values for the ADT and consists of two
parts: 1. a definition clause 2. a condition
clause
• Each operator is defined as abstract
function with three parts: 1. a header 2.
optional preconditions 3. postconditions
Specifying an ADT (Example)
• To illustrate the concept of an ADT and our
specification method, consider the ADT
RATIONAL, corresponds to Rational Number.
/* value definition */
abstract typedef <integer, integer> RATIONAL;
Condition RATIONAL[1] <> 0;
/* operator definition */
abstract RATIONAL mult (a, b) /* written a*b */
RATIONAL a,b;
Postcondition mult[0] == a[0]*b[0];
mult[1] == a[1]*b[1];
Similarily, other operators definition come here
Static Implementation of Data
Structures
• Implementation of Data Structures at
compile time is known as Static
Implementation
• The memory to be allocated to the variable
is fixed and is determined by the Compiler
at the compile time.
• e.g. Array
int a[5];
• Five memory locations will be allotted
(each of 2 bytes for integer)
Problems of Static Implementation
1. There is no bound checking in C for
array boundaries.
2. If you store less number of elements
than the number of elements for which
you have declared memory, Then the
rest of the memory will be wasted
Dynamic Implementation of Data
Structures
• Implementation of Data Structures at
Run time is known as Dynamic
Implementation
• Problems of Arrays can be removed here
• We need not to know in advance, the
size of memory required
• C provides following functions:
1. malloc( )
2. calloc( )
3. free( )
4. realloc( )
Dynamic Implementation of Data
Structures (contd..)
1. malloc( ): It allocates a block of memory
in bytes. It acts as a request to RAM for
allocation of memory. If request is
granted then it returns a pointer to the
first block of that memory. The syntax is:
malloc(number of elements * size of each element);
e.g.
int *ptr;
ptr = malloc(10 * sizeof (int) );
Dynamic Implementation of Data
Structures (contd..)
2. calloc( ): This function works exactly similar to
malloc( ) function except for the fact that it
needs two arguments as against one argument
by malloc( )
e.g.
int *ptr;
ptr = (int *) calloc (10,2);
• (int *) is the casting operator that will change
the void to int type pointer.
• Memory allocated by malloc( ) contains
Garbage value, Whereas, Memory allocated
by calloc( ) contains all zeros.
Dynamic Implementation of Data
Structures (contd..)
3. Free( ): It is used to de-allocate the
previously allocated memory using
malloc( ) or calloc( ) functions. The
syntax is:
free ( ptr_var);
Dynamic Implementation of Data
Structures (contd..)
4. realloc( ): It is used to resize the size of
memory block which is already allocated.
It found use of in two situations:
1. If the allocated memory block is insufficient
for current application
2. If the allocated memory is much more than
what is required by the current application
The Syntax of this function:
ptr_var = realloc(ptr_var, new_size);
Real Life Applications
1. 2-D Array for record keeping
2. Stack of plates in a function/party
3. Queue for bus at bus stand
4. Queue for buying tickets at ticket counter
5. Tree for representing the family relations
6. Graph for traveling in a number of cities
Built-in & User defined data
structures
Data Structures
Primitive/Built-in
Data Structures
Non-Primitive/ User
Defined Data Structures
Integer Float PointerCharacter Arrays FilesLists
Linear Lists
Stacks Queues
Non Linear Lists
Graphs Trees
Ordered List
• An ordered list is one which is maintained in some
predefined order such as alphabetical or numerical
order. It is also known as Linear List
• For ordered list…
the sequence is as follows:
X1<=X2<=X3………….<=Xn
• Can be implemented in 1-D Array e.g.
(1,2,3,4,5,6,7,8,9,10)
OR
(MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY, SUNDAY)
Operations on Ordered List
• Find the length of the list
• Traversing: Read the list from left to right
(OR right to left)
• Searching: Retrieve the i-th element
• Updation: Store a new value in the i-th
position
• Insertion: Insert a new element at position i
• Deletion: Delete an element from position i

More Related Content

What's hot

Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data StructureA. N. M. Jubaer
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithmsiqbalphy1
 
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Data structure,abstraction,abstract data type,static and dynamic,time and spa...Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Data structure,abstraction,abstract data type,static and dynamic,time and spa...Hassan Ahmed
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure pptNalinNishant3
 
introduction to Data Structure and classification
 introduction to Data Structure and classification introduction to Data Structure and classification
introduction to Data Structure and classificationchauhankapil
 
Data Structure # vpmp polytechnic
Data Structure # vpmp polytechnicData Structure # vpmp polytechnic
Data Structure # vpmp polytechniclavparmar007
 
Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.Education Front
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structureadeel hamid
 
Data structures Basics
Data structures BasicsData structures Basics
Data structures BasicsDurgaDeviCbit
 
Introduction of Data Structures and Algorithms by GOWRU BHARATH KUMAR
Introduction of Data Structures and Algorithms by GOWRU BHARATH KUMARIntroduction of Data Structures and Algorithms by GOWRU BHARATH KUMAR
Introduction of Data Structures and Algorithms by GOWRU BHARATH KUMARBHARATH KUMAR
 
Data structure &amp; algorithms introduction
Data structure &amp; algorithms introductionData structure &amp; algorithms introduction
Data structure &amp; algorithms introductionSugandh Wafai
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsAakash deep Singhal
 
Introduction to data_structure
Introduction to data_structureIntroduction to data_structure
Introduction to data_structureAshim Lamichhane
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its typesRameesha Sadaqat
 

What's hot (20)

Data structures
Data structuresData structures
Data structures
 
Presentation on Data Structure
Presentation on Data StructurePresentation on Data Structure
Presentation on Data Structure
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Data structure,abstraction,abstract data type,static and dynamic,time and spa...Data structure,abstraction,abstract data type,static and dynamic,time and spa...
Data structure,abstraction,abstract data type,static and dynamic,time and spa...
 
Introduction to data structure ppt
Introduction to data structure pptIntroduction to data structure ppt
Introduction to data structure ppt
 
introduction to Data Structure and classification
 introduction to Data Structure and classification introduction to Data Structure and classification
introduction to Data Structure and classification
 
Data Structure # vpmp polytechnic
Data Structure # vpmp polytechnicData Structure # vpmp polytechnic
Data Structure # vpmp polytechnic
 
Linked List
Linked ListLinked List
Linked List
 
Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Data structures Basics
Data structures BasicsData structures Basics
Data structures Basics
 
Introduction of Data Structures and Algorithms by GOWRU BHARATH KUMAR
Introduction of Data Structures and Algorithms by GOWRU BHARATH KUMARIntroduction of Data Structures and Algorithms by GOWRU BHARATH KUMAR
Introduction of Data Structures and Algorithms by GOWRU BHARATH KUMAR
 
Data structure &amp; algorithms introduction
Data structure &amp; algorithms introductionData structure &amp; algorithms introduction
Data structure &amp; algorithms introduction
 
Data structure
Data structureData structure
Data structure
 
L6 structure
L6 structureL6 structure
L6 structure
 
Data structures project
Data structures projectData structures project
Data structures project
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Introduction to data_structure
Introduction to data_structureIntroduction to data_structure
Introduction to data_structure
 
Data structure & its types
Data structure & its typesData structure & its types
Data structure & its types
 

Similar to 1. Data structures introduction

Chapter 1 - Introduction to Data Structure.ppt
Chapter 1 - Introduction to Data Structure.pptChapter 1 - Introduction to Data Structure.ppt
Chapter 1 - Introduction to Data Structure.pptNORSHADILAAHMADBADEL
 
DS-UNIT 1 FINAL (2).pptx
DS-UNIT 1 FINAL (2).pptxDS-UNIT 1 FINAL (2).pptx
DS-UNIT 1 FINAL (2).pptxprakashvs7
 
Data Structures_Introduction
Data Structures_IntroductionData Structures_Introduction
Data Structures_IntroductionThenmozhiK5
 
Introduction to DS.pptx
Introduction to DS.pptxIntroduction to DS.pptx
Introduction to DS.pptxOnkarModhave
 
CHAPTER-1- Introduction to data structure.pptx
CHAPTER-1- Introduction to data structure.pptxCHAPTER-1- Introduction to data structure.pptx
CHAPTER-1- Introduction to data structure.pptxOnkarModhave
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptxclassall
 
b,Sc it data structure.ppt
b,Sc it data structure.pptb,Sc it data structure.ppt
b,Sc it data structure.pptclassall
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptxclassall
 
II B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptxII B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptxsabithabanu83
 
Data Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptxData Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptxGIRISHKUMARBC1
 
Data Structure & Algorithm.pptx
Data Structure & Algorithm.pptxData Structure & Algorithm.pptx
Data Structure & Algorithm.pptxMumtaz
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfAxmedcarb
 
Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)MUHAMMAD AAMIR
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxsarala9
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxSaralaT3
 
DataStructurePpt.pptx
DataStructurePpt.pptxDataStructurePpt.pptx
DataStructurePpt.pptxssuser031f35
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structuresunilchute1
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structuresunilchute1
 

Similar to 1. Data structures introduction (20)

Chapter 1 - Introduction to Data Structure.ppt
Chapter 1 - Introduction to Data Structure.pptChapter 1 - Introduction to Data Structure.ppt
Chapter 1 - Introduction to Data Structure.ppt
 
DS-UNIT 1 FINAL (2).pptx
DS-UNIT 1 FINAL (2).pptxDS-UNIT 1 FINAL (2).pptx
DS-UNIT 1 FINAL (2).pptx
 
Data Structures_Introduction
Data Structures_IntroductionData Structures_Introduction
Data Structures_Introduction
 
Introduction to DS.pptx
Introduction to DS.pptxIntroduction to DS.pptx
Introduction to DS.pptx
 
CHAPTER-1- Introduction to data structure.pptx
CHAPTER-1- Introduction to data structure.pptxCHAPTER-1- Introduction to data structure.pptx
CHAPTER-1- Introduction to data structure.pptx
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
 
b,Sc it data structure.ppt
b,Sc it data structure.pptb,Sc it data structure.ppt
b,Sc it data structure.ppt
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
 
II B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptxII B.Sc IT DATA STRUCTURES.pptx
II B.Sc IT DATA STRUCTURES.pptx
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Data Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptxData Structure & aaplications_Module-1.pptx
Data Structure & aaplications_Module-1.pptx
 
Data Structure & Algorithm.pptx
Data Structure & Algorithm.pptxData Structure & Algorithm.pptx
Data Structure & Algorithm.pptx
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
U nit i data structure-converted
U nit   i data structure-convertedU nit   i data structure-converted
U nit i data structure-converted
 
DataStructurePpt.pptx
DataStructurePpt.pptxDataStructurePpt.pptx
DataStructurePpt.pptx
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 

More from Mandeep Singh

9.Sorting & Searching
9.Sorting & Searching9.Sorting & Searching
9.Sorting & SearchingMandeep Singh
 
4. Queues in Data Structure
4. Queues in Data Structure4. Queues in Data Structure
4. Queues in Data StructureMandeep Singh
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTUREMandeep Singh
 
2. Array in Data Structure
2. Array in Data Structure2. Array in Data Structure
2. Array in Data StructureMandeep Singh
 
Standard Template Library (STL) in Object Oriented Programming
Standard Template Library (STL) in Object Oriented ProgrammingStandard Template Library (STL) in Object Oriented Programming
Standard Template Library (STL) in Object Oriented ProgrammingMandeep Singh
 

More from Mandeep Singh (11)

9.Sorting & Searching
9.Sorting & Searching9.Sorting & Searching
9.Sorting & Searching
 
8. Hash table
8. Hash table8. Hash table
8. Hash table
 
7. Spanning trees
7. Spanning trees7. Spanning trees
7. Spanning trees
 
6. Graphs
6. Graphs6. Graphs
6. Graphs
 
5.Linked list
5.Linked list 5.Linked list
5.Linked list
 
4. Queues in Data Structure
4. Queues in Data Structure4. Queues in Data Structure
4. Queues in Data Structure
 
Stacks in DATA STRUCTURE
Stacks in DATA STRUCTUREStacks in DATA STRUCTURE
Stacks in DATA STRUCTURE
 
2. Array in Data Structure
2. Array in Data Structure2. Array in Data Structure
2. Array in Data Structure
 
Standard Template Library (STL) in Object Oriented Programming
Standard Template Library (STL) in Object Oriented ProgrammingStandard Template Library (STL) in Object Oriented Programming
Standard Template Library (STL) in Object Oriented Programming
 
Ip6 tables in linux
Ip6 tables in linuxIp6 tables in linux
Ip6 tables in linux
 
Iptables in linux
Iptables in linuxIptables in linux
Iptables in linux
 

Recently uploaded

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxKartikeyaDwivedi3
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 

Recently uploaded (20)

Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Concrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptxConcrete Mix Design - IS 10262-2019 - .pptx
Concrete Mix Design - IS 10262-2019 - .pptx
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 

1. Data structures introduction

  • 2. What is Data Structure? • The Logical or Mathematical model of a particular organization of data. • Data Structures may be divided into two types:- 1. Linear Data Structures 2. Non Linear Data Structures
  • 3. Linear Data Structures • If the elements of a data structure are stored sequentially. e.g. 1. Arrays 2. Linked Lists 3. Stacks 4. Queues
  • 4. Non Linear Data Structures • If the elements of a data structure are not stored in a sequential order. e.g. 1. Trees – Represent Hierarchical relationship between nodes 2. Graphs – Represent relationship between pairs of elements which is not necessarily hierarchical in nature
  • 5. Data Structure Operations 1. Traversing – Accessing each record exactly once so that certain items in the record may be processed 2. Searching – Finding the location of the record with the given key value 3. Inserting:- Adding a new record 4. Deleting:- Removing a record
  • 6. Abstract Data Types • A useful tool for specifying the logical properties of a data type is the ADT • It is the way we look at a data structure, focusing on what it does and ignoring how it does its job. • Abstract means considered apart from the detailed specification or implementation • Data Type is a collection of values and a set of operations on those values
  • 7. Abstract Data Types (contd..) • ADT can be a structure considered without regard to its implementation OR • It can be thought of as a description of the data in the structure with a list of operations that can be performed on the data within the structure • e.g. stack.h file has been provided for performing the operations over stack
  • 8. Specifying an ADT • An ADT consists of two parts: – a value definition and – An operator definition • The value definition defines the collection of values for the ADT and consists of two parts: 1. a definition clause 2. a condition clause • Each operator is defined as abstract function with three parts: 1. a header 2. optional preconditions 3. postconditions
  • 9. Specifying an ADT (Example) • To illustrate the concept of an ADT and our specification method, consider the ADT RATIONAL, corresponds to Rational Number. /* value definition */ abstract typedef <integer, integer> RATIONAL; Condition RATIONAL[1] <> 0; /* operator definition */ abstract RATIONAL mult (a, b) /* written a*b */ RATIONAL a,b; Postcondition mult[0] == a[0]*b[0]; mult[1] == a[1]*b[1]; Similarily, other operators definition come here
  • 10. Static Implementation of Data Structures • Implementation of Data Structures at compile time is known as Static Implementation • The memory to be allocated to the variable is fixed and is determined by the Compiler at the compile time. • e.g. Array int a[5]; • Five memory locations will be allotted (each of 2 bytes for integer)
  • 11. Problems of Static Implementation 1. There is no bound checking in C for array boundaries. 2. If you store less number of elements than the number of elements for which you have declared memory, Then the rest of the memory will be wasted
  • 12. Dynamic Implementation of Data Structures • Implementation of Data Structures at Run time is known as Dynamic Implementation • Problems of Arrays can be removed here • We need not to know in advance, the size of memory required • C provides following functions: 1. malloc( ) 2. calloc( ) 3. free( ) 4. realloc( )
  • 13. Dynamic Implementation of Data Structures (contd..) 1. malloc( ): It allocates a block of memory in bytes. It acts as a request to RAM for allocation of memory. If request is granted then it returns a pointer to the first block of that memory. The syntax is: malloc(number of elements * size of each element); e.g. int *ptr; ptr = malloc(10 * sizeof (int) );
  • 14. Dynamic Implementation of Data Structures (contd..) 2. calloc( ): This function works exactly similar to malloc( ) function except for the fact that it needs two arguments as against one argument by malloc( ) e.g. int *ptr; ptr = (int *) calloc (10,2); • (int *) is the casting operator that will change the void to int type pointer. • Memory allocated by malloc( ) contains Garbage value, Whereas, Memory allocated by calloc( ) contains all zeros.
  • 15. Dynamic Implementation of Data Structures (contd..) 3. Free( ): It is used to de-allocate the previously allocated memory using malloc( ) or calloc( ) functions. The syntax is: free ( ptr_var);
  • 16. Dynamic Implementation of Data Structures (contd..) 4. realloc( ): It is used to resize the size of memory block which is already allocated. It found use of in two situations: 1. If the allocated memory block is insufficient for current application 2. If the allocated memory is much more than what is required by the current application The Syntax of this function: ptr_var = realloc(ptr_var, new_size);
  • 17. Real Life Applications 1. 2-D Array for record keeping 2. Stack of plates in a function/party 3. Queue for bus at bus stand 4. Queue for buying tickets at ticket counter 5. Tree for representing the family relations 6. Graph for traveling in a number of cities
  • 18. Built-in & User defined data structures Data Structures Primitive/Built-in Data Structures Non-Primitive/ User Defined Data Structures Integer Float PointerCharacter Arrays FilesLists Linear Lists Stacks Queues Non Linear Lists Graphs Trees
  • 19. Ordered List • An ordered list is one which is maintained in some predefined order such as alphabetical or numerical order. It is also known as Linear List • For ordered list… the sequence is as follows: X1<=X2<=X3………….<=Xn • Can be implemented in 1-D Array e.g. (1,2,3,4,5,6,7,8,9,10) OR (MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURDAY, SUNDAY)
  • 20. Operations on Ordered List • Find the length of the list • Traversing: Read the list from left to right (OR right to left) • Searching: Retrieve the i-th element • Updation: Store a new value in the i-th position • Insertion: Insert a new element at position i • Deletion: Delete an element from position i