SlideShare a Scribd company logo
1 of 25
I N T R O D U C T I O N T O D ATA
S T R U C T U R E S
N U R J A H A N N I PA
L E C T U R E R , D E P T O F I C T, B D U
LECTURE OUTLINES
• Basic Terminology
• Definition of data structure
• Types of data structures
• Data Structure Operations
• Algorithm
BASIC TERMINOLOGY
Data “Raw” facts, such as a telephone number, a birth date, a
customer name, and phone number. Data have little
meaning unless they have been organized in some
logical manner
Information Processed data. Information is used to reveal the
meaning of data.
Accurate, relevant, and timely information is the key to
good decision making.
Group Item Data items which have subordinate data items are
called Group item, for example, name of a student can
have first name and the last name.
Field Field is a smaller entity of the table which contains specific
information about every record in the table. In the example,
No, time, Temperature, difference, Measurement accuracy is
the field of that table.
Record A row of a table is also called record. It contains the specific
information of each individual entry in the table. It is a
horizontal entity in the table. For example, the fields 1,13.33,
29.30, 29.7, 0.40, 98.65 are the part of a record.
File A collection of related records. For example, a file might
contain data about the students currently enrolled at BDU.
Prepared By: Nurjahan Nipa 4
WHAT IS DATA STRUCTURE
• Data can be organized in many different ways; the logical or mathematical model of a
particular organization of data is called a data structure.
• Data structure is a method of organizing a large amount of data more efficiently so
that any operation on that data becomes easy.
• A data structure is a particular way of storing and organizing data either in computer’s
memory or on the disk storage so that it can be used efficiently.
• Data Structures are widely used in almost every aspect of Computer Science i.e. DBMS,
Operating System, Compiler Design, Artificial intelligence, Graphics and many more.
CHOICE OF PARTICULAR DATA MODEL
First, it must be rich enough in structure to mirror the actual relationships of the data
in real world.
On the other hand, the structure should be simple enough that one can effectively
process the data when necessary.
TYPES OF DATA STRUCTURE
1. Primitive Data structure: The primitive data structures are fundamental data types
that are supported by a programming language. The primitive data structure are also
called simple data structures. For example, integer, float, character, and Boolean are all
primitive data types.
2. Non-Primitive Data structure: Non-primitive data types are not defined by the
programming language, but are instead created by the programmer. The non-primitive
data types are used to store the group of values. Examples of the non-primitive data
types are Array, linked list, stacks, queue, tree, graphs etc.
TYPES OF DATA STRUCTURES
LINEAR AND NON LINEAR STRUCTURES
• Linear Data Structure: If the elements of a data structure are stored in a linear or
sequential order, then it is a linear data structure. Examples- Arrays, Linked Links,
Stacks, Queues.
• Non-Linear Data Structure: If the elements of a data structure are not stored in
sequential order, then it is a non-linear data structure. Examples- Trees and graphs.
GRAPH GRAPH TREE
STACK
QUEUE
ARRAY
An array is a collection of items stored at contiguous memory locations. The idea is to
store multiple items of the same type together.
Arrays are of fixed size.
Data elements are stored in contiguous memory locations which may not be always
available.
Insertion and deletion of elements can be problematic because of shifting of elements
from
their positions.
Uses in Real life applications:
• 2D Arrays, generally called Matrices are mainly used in Image processing
• RGB image is a n*n*3 array
LINKED LISTS
Like arrays, Linked List is a linear data structure. Unlike arrays, linked list elements are not
stored at a contiguous location; the elements are linked using pointers.
• Music player- Songs in music player are linked to previous and next song.
• Previous and next page in web browser.
• Image viewer- Previous and next images are linked.
STACK
A stack is a linear data structure in which insertion and
deletion of elements are done at only ne end, which is known
as the top of the stack. Stack follows LIFO semantics i.e. the
last element which is added to the stack is the first element
which is deleted from the stack.
 Push: This term is used to insert an element into a stack.
 Pull: This term is used to delete an element into a stack.
Uses:
 Need to store undo/redo operation in a word process.
 Recursion
QUEUE
• A Queue is a linear list of elements in
which deletions can take place only at one
end, called the front, and insertions can
take place only at the other end, called the
rear.
• It is also called first-in-first-out (FIFO)
system.
Uses:
 To implement printer spooler.
TREE
• A tree is a non-linear data structure
which consists of a collection of nodes
arranged in a hierarchical order.
Examples of Real Life:
• Family tree
• Table of contents of a book
• Computer file system
GRAPH
• A graph is a non-linear data structure which is a
collection of vertices (also called nodes) and edges
that connect these vertices.
Real life uses of graph:
 Google Map
 Facebook
 World Wide Web
 Course Pre-requisite
 Circuit
 Computer Networks
OPERATIONS PERFORMED ON DATA
STRUCTURE
Operations Description
Insertion Adding a new record to the structure.
Deletion Removing an item from the structure.
Traversing Accessing and processing each data item of the data structure exactly once
Searching Find the location of the key value within the data structure.
Sorting Arranging all the data items in a data structure either in ascending or in
descending order or in lexicographical order (for Strings).
Merging Combining the data items of two different sorted lists into a single sorted list.
WHAT IS ALGORITHM
• An algorithm is a set of well-defined instructions in sequence to solve a problem. Algorithms
are generally created independent of underlying languages, i.e. an algorithm can be
implemented in more than one programming language.
Each algorithm should have five characteristics:
• Input: The algorithm must take zero or more input.
• Output: The algorithm may produce one or more outputs.
• Definiteness: Each step of algorithm must be defined unambiguously.
• Effectiveness: A human should be able to calculate the exact values involved in the
procedure of the algorithm using paper & pencil. It must be possible to perform each step
of the algorithm correctly and a finite amount of time. It is not enough that each step is
definite, but it must also be feasible.
• Termination: An algorithm may terminate after a finite number of steps
AN ALGORITHM FOR MAKING A CUP
OF TEA.
• Put the teabag in a cup.
• Fill the kettle with water.
• Boil the water in the kettle.
• Pour some of the boiled water into the cup.
• Add milk to the cup.
• Add sugar to the cup.
• Stir the tea.
• Drink the tea.
DESIGN AN ALGORITHM TO ADD TWO
NUMBERS AND DISPLAY THE RESULT
TIME & SPACE COMPLEXITY
The performance of an algorithm is measured on the basis of following properties :
• Time Complexity- Time complexity of an algorithm quantifies the amount of time
taken by an algorithm to run as a function of the length of the input.
• Space Complexity-Space complexity of an algorithm quantifies the amount of space or
memory taken by an algorithm to run as a function of the length of the input.
THANK YOU!
#include<stdio.h>
void function1(void);
void function2(void);
main()
{
int m=1000;
function2();
printf("%dn", m);
}
void function1(void)
{
int m=10;
printf("%dn", m);
}
void function2(void)
{
int m=100;
function1();
printf("%dn", m);
}

More Related Content

What's hot

Data structures (introduction)
 Data structures (introduction) Data structures (introduction)
Data structures (introduction)
Arvind Devaraj
 
Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, Queue
Ghaffar Khan
 
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 of data structure
Introduction of data structureIntroduction of data structure
Introduction of data structure
eShikshak
 

What's hot (20)

Data structure
Data structureData structure
Data structure
 
Data structures using C
Data structures using CData structures using C
Data structures using C
 
Data structure ppt
Data structure pptData structure ppt
Data structure ppt
 
Data structures (introduction)
 Data structures (introduction) Data structures (introduction)
Data structures (introduction)
 
Data Structure and Algorithms
Data Structure and AlgorithmsData Structure and Algorithms
Data Structure and Algorithms
 
Introductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, QueueIntroductiont To Aray,Tree,Stack, Queue
Introductiont To Aray,Tree,Stack, Queue
 
Data structures & algorithms lecture 3
Data structures & algorithms lecture 3Data structures & algorithms lecture 3
Data structures & algorithms lecture 3
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
data structure
data structuredata structure
data structure
 
Data structure power point presentation
Data structure power point presentation Data structure power point presentation
Data structure power point presentation
 
Data Structures (CS8391)
Data Structures (CS8391)Data Structures (CS8391)
Data Structures (CS8391)
 
Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To Data Structures.
 
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 of data structure
Introduction of data structureIntroduction of data structure
Introduction of data structure
 
2nd puc computer science chapter 3 data structures 1
2nd puc computer science chapter 3 data structures 12nd puc computer science chapter 3 data structures 1
2nd puc computer science chapter 3 data structures 1
 
Data structures using c
Data structures using cData structures using c
Data structures using c
 
Data Structure Basics
Data Structure BasicsData Structure Basics
Data Structure Basics
 
Data Structures
Data StructuresData Structures
Data Structures
 
Bca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structureBca ii dfs u-1 introduction to data structure
Bca ii dfs u-1 introduction to data structure
 

Similar to Lecture 01 Intro to DSA

Data structure chapter 1.pptx
Data structure chapter 1.pptxData structure chapter 1.pptx
Data structure chapter 1.pptx
Kami503928
 
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
OnkarModhave
 
Lecture 1. Data Structure & Algorithm.pptx
Lecture 1. Data Structure & Algorithm.pptxLecture 1. Data Structure & Algorithm.pptx
Lecture 1. Data Structure & Algorithm.pptx
ArifKamal36
 

Similar to Lecture 01 Intro to DSA (20)

Data structure chapter 1.pptx
Data structure chapter 1.pptxData structure chapter 1.pptx
Data structure chapter 1.pptx
 
Introduction to data structures (ss)
Introduction to data structures (ss)Introduction to data structures (ss)
Introduction to data structures (ss)
 
dsa.pptx
dsa.pptxdsa.pptx
dsa.pptx
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Data Structures - Lecture 2 [Introduction to Data Structures]
Data Structures - Lecture 2 [Introduction to Data Structures]Data Structures - Lecture 2 [Introduction to Data Structures]
Data Structures - Lecture 2 [Introduction to Data Structures]
 
Introduction to Data Structures
Introduction to Data StructuresIntroduction to Data Structures
Introduction to Data Structures
 
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
 
Unit 1.ppt
Unit 1.pptUnit 1.ppt
Unit 1.ppt
 
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
 
Lecture 2 Data Structure Introduction
Lecture 2 Data Structure IntroductionLecture 2 Data Structure Introduction
Lecture 2 Data Structure Introduction
 
b,Sc it data structure.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
 
Data structures
Data structuresData structures
Data structures
 
1. Introduction to Data Structure.pptx
1. Introduction to Data Structure.pptx1. Introduction to Data Structure.pptx
1. Introduction to Data Structure.pptx
 
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHIBCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
BCA DATA STRUCTURES INTRODUCTION AND OVERVIEW SOWMYA JYOTHI
 
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
 
ds bridge.pptx
ds bridge.pptxds bridge.pptx
ds bridge.pptx
 
Lecture 1. Data Structure & Algorithm.pptx
Lecture 1. Data Structure & Algorithm.pptxLecture 1. Data Structure & Algorithm.pptx
Lecture 1. Data Structure & Algorithm.pptx
 
Unit-1 DataStructure Intro.pptx
Unit-1 DataStructure Intro.pptxUnit-1 DataStructure Intro.pptx
Unit-1 DataStructure Intro.pptx
 

Recently uploaded

Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Christo Ananth
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
dharasingh5698
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
MsecMca
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Christo Ananth
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
amitlee9823
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ssuser89054b
 

Recently uploaded (20)

Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Thermal Engineering Unit - I & II . ppt
Thermal Engineering  Unit - I & II . pptThermal Engineering  Unit - I & II . ppt
Thermal Engineering Unit - I & II . ppt
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance BookingCall Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
Call Girls Wakad Call Me 7737669865 Budget Friendly No Advance Booking
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...Bhosari ( Call Girls ) Pune  6297143586  Hot Model With Sexy Bhabi Ready For ...
Bhosari ( Call Girls ) Pune 6297143586 Hot Model With Sexy Bhabi Ready For ...
 
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
VIP Model Call Girls Kothrud ( Pune ) Call ON 8005736733 Starting From 5K to ...
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar  ≼🔝 Delhi door step de...
Call Now ≽ 9953056974 ≼🔝 Call Girls In New Ashok Nagar ≼🔝 Delhi door step de...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELLPVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
PVC VS. FIBERGLASS (FRP) GRAVITY SEWER - UNI BELL
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 

Lecture 01 Intro to DSA

  • 1. I N T R O D U C T I O N T O D ATA S T R U C T U R E S N U R J A H A N N I PA L E C T U R E R , D E P T O F I C T, B D U
  • 2. LECTURE OUTLINES • Basic Terminology • Definition of data structure • Types of data structures • Data Structure Operations • Algorithm
  • 3. BASIC TERMINOLOGY Data “Raw” facts, such as a telephone number, a birth date, a customer name, and phone number. Data have little meaning unless they have been organized in some logical manner Information Processed data. Information is used to reveal the meaning of data. Accurate, relevant, and timely information is the key to good decision making. Group Item Data items which have subordinate data items are called Group item, for example, name of a student can have first name and the last name.
  • 4. Field Field is a smaller entity of the table which contains specific information about every record in the table. In the example, No, time, Temperature, difference, Measurement accuracy is the field of that table. Record A row of a table is also called record. It contains the specific information of each individual entry in the table. It is a horizontal entity in the table. For example, the fields 1,13.33, 29.30, 29.7, 0.40, 98.65 are the part of a record. File A collection of related records. For example, a file might contain data about the students currently enrolled at BDU. Prepared By: Nurjahan Nipa 4
  • 5. WHAT IS DATA STRUCTURE • Data can be organized in many different ways; the logical or mathematical model of a particular organization of data is called a data structure. • Data structure is a method of organizing a large amount of data more efficiently so that any operation on that data becomes easy. • A data structure is a particular way of storing and organizing data either in computer’s memory or on the disk storage so that it can be used efficiently. • Data Structures are widely used in almost every aspect of Computer Science i.e. DBMS, Operating System, Compiler Design, Artificial intelligence, Graphics and many more.
  • 6. CHOICE OF PARTICULAR DATA MODEL First, it must be rich enough in structure to mirror the actual relationships of the data in real world. On the other hand, the structure should be simple enough that one can effectively process the data when necessary.
  • 7. TYPES OF DATA STRUCTURE 1. Primitive Data structure: The primitive data structures are fundamental data types that are supported by a programming language. The primitive data structure are also called simple data structures. For example, integer, float, character, and Boolean are all primitive data types. 2. Non-Primitive Data structure: Non-primitive data types are not defined by the programming language, but are instead created by the programmer. The non-primitive data types are used to store the group of values. Examples of the non-primitive data types are Array, linked list, stacks, queue, tree, graphs etc.
  • 8. TYPES OF DATA STRUCTURES
  • 9. LINEAR AND NON LINEAR STRUCTURES • Linear Data Structure: If the elements of a data structure are stored in a linear or sequential order, then it is a linear data structure. Examples- Arrays, Linked Links, Stacks, Queues. • Non-Linear Data Structure: If the elements of a data structure are not stored in sequential order, then it is a non-linear data structure. Examples- Trees and graphs.
  • 11.
  • 12. ARRAY An array is a collection of items stored at contiguous memory locations. The idea is to store multiple items of the same type together.
  • 13. Arrays are of fixed size. Data elements are stored in contiguous memory locations which may not be always available. Insertion and deletion of elements can be problematic because of shifting of elements from their positions. Uses in Real life applications: • 2D Arrays, generally called Matrices are mainly used in Image processing • RGB image is a n*n*3 array
  • 14. LINKED LISTS Like arrays, Linked List is a linear data structure. Unlike arrays, linked list elements are not stored at a contiguous location; the elements are linked using pointers. • Music player- Songs in music player are linked to previous and next song. • Previous and next page in web browser. • Image viewer- Previous and next images are linked.
  • 15. STACK A stack is a linear data structure in which insertion and deletion of elements are done at only ne end, which is known as the top of the stack. Stack follows LIFO semantics i.e. the last element which is added to the stack is the first element which is deleted from the stack.  Push: This term is used to insert an element into a stack.  Pull: This term is used to delete an element into a stack. Uses:  Need to store undo/redo operation in a word process.  Recursion
  • 16. QUEUE • A Queue is a linear list of elements in which deletions can take place only at one end, called the front, and insertions can take place only at the other end, called the rear. • It is also called first-in-first-out (FIFO) system. Uses:  To implement printer spooler.
  • 17. TREE • A tree is a non-linear data structure which consists of a collection of nodes arranged in a hierarchical order. Examples of Real Life: • Family tree • Table of contents of a book • Computer file system
  • 18. GRAPH • A graph is a non-linear data structure which is a collection of vertices (also called nodes) and edges that connect these vertices. Real life uses of graph:  Google Map  Facebook  World Wide Web  Course Pre-requisite  Circuit  Computer Networks
  • 19. OPERATIONS PERFORMED ON DATA STRUCTURE Operations Description Insertion Adding a new record to the structure. Deletion Removing an item from the structure. Traversing Accessing and processing each data item of the data structure exactly once Searching Find the location of the key value within the data structure. Sorting Arranging all the data items in a data structure either in ascending or in descending order or in lexicographical order (for Strings). Merging Combining the data items of two different sorted lists into a single sorted list.
  • 20. WHAT IS ALGORITHM • An algorithm is a set of well-defined instructions in sequence to solve a problem. Algorithms are generally created independent of underlying languages, i.e. an algorithm can be implemented in more than one programming language. Each algorithm should have five characteristics: • Input: The algorithm must take zero or more input. • Output: The algorithm may produce one or more outputs. • Definiteness: Each step of algorithm must be defined unambiguously. • Effectiveness: A human should be able to calculate the exact values involved in the procedure of the algorithm using paper & pencil. It must be possible to perform each step of the algorithm correctly and a finite amount of time. It is not enough that each step is definite, but it must also be feasible. • Termination: An algorithm may terminate after a finite number of steps
  • 21. AN ALGORITHM FOR MAKING A CUP OF TEA. • Put the teabag in a cup. • Fill the kettle with water. • Boil the water in the kettle. • Pour some of the boiled water into the cup. • Add milk to the cup. • Add sugar to the cup. • Stir the tea. • Drink the tea.
  • 22. DESIGN AN ALGORITHM TO ADD TWO NUMBERS AND DISPLAY THE RESULT
  • 23. TIME & SPACE COMPLEXITY The performance of an algorithm is measured on the basis of following properties : • Time Complexity- Time complexity of an algorithm quantifies the amount of time taken by an algorithm to run as a function of the length of the input. • Space Complexity-Space complexity of an algorithm quantifies the amount of space or memory taken by an algorithm to run as a function of the length of the input.
  • 25. #include<stdio.h> void function1(void); void function2(void); main() { int m=1000; function2(); printf("%dn", m); } void function1(void) { int m=10; printf("%dn", m); } void function2(void) { int m=100; function1(); printf("%dn", m); }