SlideShare a Scribd company logo
DSA:Unit 1
Prepared by
Gobinda subedi
For BIT, KIST
Prerequisite
• Knowledge of C
• From the point of exam, students should be
familiar with algorithm and functions fluently.
Contents Of Unit 1
• Information and its meaning of Data Structure
• Abstract Data Type
• ADT VS DS
• Array in C
• The array as an ADT
• One dimensional array
• Two dimensional array
• Multidimensional array
Introduction
• What is data structure?
A data structure is an arrangement of data in a
computer’s memory (or sometimes on a disk) so
that it can be used efficiently. Data structures
include arrays, linked lists, stacks, binary trees,
and hash tables, among others.
• What is an Algorithm?
Algorithms manipulate the data in these
structures in various ways, such as searching for a
particular data item and sorting the data.
Introduction contd..
• Data structures are the building blocks of a program.
• Data structure mainly specifies the following four
things:
Organization of data.
Accessing methods
Degree of associativity
Processing alternatives for information
• To develop a program from an algorithm, we should
select an appropriate data structure for that algorithm.
Therefore algorithm and its associated data structures
form a program.
• Hence, we can say that
Algorithm + Data structure = Program
Introduction contd..
• Data structure can be thought of in two basic
ways:
A static data structure is one whose capacity is
fixed at creation. For example, array.
A dynamic data structure is one whose capacity is
variable, so it can expand or contract at any time.
For example, linked list, binary tree etc.
Data Structure type
• Data structure can be divided into two types:
Linear Data Structure: When the data is stored in
the memory in the memory in linear or sequential
form is called linear data structure. Examples
include Array, Stack, Queue etc.
Non linear Data Structure: When the data is
stored in the memory in disperse or non-
sequential order is called non linear data
structure. Example includes trees, graphs files etc.
Classification of Data Structure
Data Operation Operations
• Operations are used to process the data
appearing in the data structure. Following are the
some of the operations used frequently:
Traversing: Accessing each record exactly once so that
certain items in the record may be processed.
Searching: Finding the location of the record with the
given key value.
Inserting: Adding a new record
Deleting : Removing a record.
Sorting: Arranging the records in some logical order.
Merging: Combining the records in two different file
into a single file.
Abstract Data Type (ADT)
• Abstract data type (ADT) is a specification of a
set of data and the set of operations that can
be performed on the data. A set of data values
and associated operations that are precisely
specified independent of any particular
implementation.
• Real life example:
Book is Abstract (Telephone Book is an
implementation)
ADT vs DS
• ADT is a logical description and data structure is concrete.
ADT is the logical picture of the data and the operations to
manipulate the component elements of the data. Data
structure is the actual representation of the data during the
implementation and the algorithms to manipulate the data
elements. ADT is in the logical level and data structure is in
the implementation level.
 ADT is implementation independent. For example, it only
describes what a data type List consists (data) and what are the
operations it can perform, but it has no information about how
the List is actually implemented.
 Whereas data structure is implementation dependent, as in the
same example, it is about how the List implemented i.e., using
array or linked list. Ultimately, data structure is how we
implement the data in an abstract data type.
Overview of Array
• Arrays a kind of data structure that can store a fixed-
size sequential collection of elements of the same
type. An array is used to store a collection of data,
but it is often more useful to think of an array as a
collection of variables of the same type.
• All arrays consist of contiguous memory locations.
The lowest address corresponds to the first element
and the highest address to the last element.
Types of Array
• One dimensional array:
 The elements of the array can be represented either as a single
column or as a single row.
• Declaring one-dimensional array:
 data_type array_name[size];
• Following are some valid array declarations:
 float weight[50];
 int marks[100];
 int age[15];
• Array Initialization (1-D):
• The general format of array initialization is:
 data_type array_name[size]={element1,element2,…………..,element
n};
• #include <stdio.h>
• int main ()
{
int n[ 10 ]; /* n is an array of 10 integers */
int i,j; /* initialize elements of array n to 0 */
for ( i = 0; i < 10; i++ )
{
n[ i ] = i + 100; /* set element at location i to i + 100 */
}
/* output each array element's value */
for (j = 0; j < 10; j++ )
{
printf("Element[%d] = %dn", j, n[j] );
}
return 0;
}
Ad

More Related Content

What's hot (19)

Presentation 1st
Presentation 1stPresentation 1st
Presentation 1st
MuhammadAmir220
 
Basics of data structure
Basics of data structureBasics of data structure
Basics of data structure
Rajendran
 
Data structures
Data structuresData structures
Data structures
Lovely Professional University
 
Basic terminologies
Basic terminologiesBasic terminologies
Basic terminologies
Rajendran
 
Data Structure - Elementary Data Organization
Data Structure - Elementary  Data Organization Data Structure - Elementary  Data Organization
Data Structure - Elementary Data Organization
Uma mohan
 
Elementary data organisation
Elementary data organisationElementary data organisation
Elementary data organisation
Muzamil Hussain
 
introduction to Data Structure and classification
 introduction to Data Structure and classification introduction to Data Structure and classification
introduction to Data Structure and classification
chauhankapil
 
Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)
MUHAMMAD AAMIR
 
Data structures
Data structuresData structures
Data structures
Amrutha Rajan
 
Introduction to Data Structure part 1
Introduction to Data Structure part 1Introduction to Data Structure part 1
Introduction to Data Structure part 1
ProfSonaliGholveDoif
 
Pandas
PandasPandas
Pandas
Dr. Chitra Dhawale
 
Files and data storage
Files and data storageFiles and data storage
Files and data storage
Zaid Shabbir
 
Types Of Data Structure
Types Of Data StructureTypes Of Data Structure
Types Of Data Structure
Vaishali Chinchkhede
 
Lecture1 data structure(introduction)
Lecture1 data structure(introduction)Lecture1 data structure(introduction)
Lecture1 data structure(introduction)
Taibah University, College of Computer Science & Engineering
 
Array in c
Array in cArray in c
Array in c
Harsh Bhanushali
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
Rohit Rai
 
Data structure
Data structureData structure
Data structure
Prof. Dr. K. Adisesha
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
Aakash deep Singhal
 
R data structures-2
R data structures-2R data structures-2
R data structures-2
Victor Ordu
 

Similar to Dsa unit 1 (20)

DataStructurePpt-01.pptxEngineering data structure notes
DataStructurePpt-01.pptxEngineering data structure notesDataStructurePpt-01.pptxEngineering data structure notes
DataStructurePpt-01.pptxEngineering data structure notes
limev72215
 
Unit-1 DataStructure Intro.pptx
Unit-1 DataStructure Intro.pptxUnit-1 DataStructure Intro.pptx
Unit-1 DataStructure Intro.pptx
ajajkhan16
 
Introduction to Data Structures and their importance
Introduction to Data Structures and their importanceIntroduction to Data Structures and their importance
Introduction to Data Structures and their importance
Bulbul Agrawal
 
DataStructureccvdgddfffdesddsssdssPpt.pptx
DataStructureccvdgddfffdesddsssdssPpt.pptxDataStructureccvdgddfffdesddsssdssPpt.pptx
DataStructureccvdgddfffdesddsssdssPpt.pptx
bgmi52926
 
DataStructurePpt.pptx
DataStructurePpt.pptxDataStructurePpt.pptx
DataStructurePpt.pptx
DCABCA
 
DSA Ch1(Introduction) [Recovered].pptx
DSA Ch1(Introduction)   [Recovered].pptxDSA Ch1(Introduction)   [Recovered].pptx
DSA Ch1(Introduction) [Recovered].pptx
HOWoTO79
 
Data Structure Ppt for our engineering college industrial training.
Data Structure Ppt  for our engineering college industrial training.Data Structure Ppt  for our engineering college industrial training.
Data Structure Ppt for our engineering college industrial training.
AnumaiAshish
 
Data structures - unit 1
Data structures - unit 1Data structures - unit 1
Data structures - unit 1
SaranyaP45
 
DataStructurePpt.pptx
DataStructurePpt.pptxDataStructurePpt.pptx
DataStructurePpt.pptx
ssuser031f35
 
Lecture 1.pptxffffffffffffffcfffffffffff
Lecture 1.pptxffffffffffffffcfffffffffffLecture 1.pptxffffffffffffffcfffffffffff
Lecture 1.pptxffffffffffffffcfffffffffff
andrewandjames
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
SaralaT3
 
Introduction to datastructures presentation
Introduction to datastructures presentationIntroduction to datastructures presentation
Introduction to datastructures presentation
krishkiran2408
 
UNIT I - Data Structures.pdf
UNIT I - Data Structures.pdfUNIT I - Data Structures.pdf
UNIT I - Data Structures.pdf
KPRevathiAsstprofITD
 
Introduction To Data Structures.ppt
Introduction To Data Structures.pptIntroduction To Data Structures.ppt
Introduction To Data Structures.ppt
NALESVPMEngg
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2
RajSingh734307
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
sarala9
 
DATA STRUCTURES, ADTS INTRO lecture .pptx
DATA STRUCTURES, ADTS INTRO lecture .pptxDATA STRUCTURES, ADTS INTRO lecture .pptx
DATA STRUCTURES, ADTS INTRO lecture .pptx
ssuser4302bb
 
Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresres
amplopsurat
 
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notesM v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
Malikireddy Bramhananda Reddy
 
unit 1_Linked list.pptx
unit 1_Linked list.pptxunit 1_Linked list.pptx
unit 1_Linked list.pptx
ssuser7922b8
 
DataStructurePpt-01.pptxEngineering data structure notes
DataStructurePpt-01.pptxEngineering data structure notesDataStructurePpt-01.pptxEngineering data structure notes
DataStructurePpt-01.pptxEngineering data structure notes
limev72215
 
Unit-1 DataStructure Intro.pptx
Unit-1 DataStructure Intro.pptxUnit-1 DataStructure Intro.pptx
Unit-1 DataStructure Intro.pptx
ajajkhan16
 
Introduction to Data Structures and their importance
Introduction to Data Structures and their importanceIntroduction to Data Structures and their importance
Introduction to Data Structures and their importance
Bulbul Agrawal
 
DataStructureccvdgddfffdesddsssdssPpt.pptx
DataStructureccvdgddfffdesddsssdssPpt.pptxDataStructureccvdgddfffdesddsssdssPpt.pptx
DataStructureccvdgddfffdesddsssdssPpt.pptx
bgmi52926
 
DataStructurePpt.pptx
DataStructurePpt.pptxDataStructurePpt.pptx
DataStructurePpt.pptx
DCABCA
 
DSA Ch1(Introduction) [Recovered].pptx
DSA Ch1(Introduction)   [Recovered].pptxDSA Ch1(Introduction)   [Recovered].pptx
DSA Ch1(Introduction) [Recovered].pptx
HOWoTO79
 
Data Structure Ppt for our engineering college industrial training.
Data Structure Ppt  for our engineering college industrial training.Data Structure Ppt  for our engineering college industrial training.
Data Structure Ppt for our engineering college industrial training.
AnumaiAshish
 
Data structures - unit 1
Data structures - unit 1Data structures - unit 1
Data structures - unit 1
SaranyaP45
 
DataStructurePpt.pptx
DataStructurePpt.pptxDataStructurePpt.pptx
DataStructurePpt.pptx
ssuser031f35
 
Lecture 1.pptxffffffffffffffcfffffffffff
Lecture 1.pptxffffffffffffffcfffffffffffLecture 1.pptxffffffffffffffcfffffffffff
Lecture 1.pptxffffffffffffffcfffffffffff
andrewandjames
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
SaralaT3
 
Introduction to datastructures presentation
Introduction to datastructures presentationIntroduction to datastructures presentation
Introduction to datastructures presentation
krishkiran2408
 
Introduction To Data Structures.ppt
Introduction To Data Structures.pptIntroduction To Data Structures.ppt
Introduction To Data Structures.ppt
NALESVPMEngg
 
Iare ds lecture_notes_2
Iare ds lecture_notes_2Iare ds lecture_notes_2
Iare ds lecture_notes_2
RajSingh734307
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
sarala9
 
DATA STRUCTURES, ADTS INTRO lecture .pptx
DATA STRUCTURES, ADTS INTRO lecture .pptxDATA STRUCTURES, ADTS INTRO lecture .pptx
DATA STRUCTURES, ADTS INTRO lecture .pptx
ssuser4302bb
 
Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresres
amplopsurat
 
unit 1_Linked list.pptx
unit 1_Linked list.pptxunit 1_Linked list.pptx
unit 1_Linked list.pptx
ssuser7922b8
 
Ad

Recently uploaded (20)

Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
GC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance EngineeringGC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance Engineering
Tier1 app
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
Drawing Heighway’s Dragon - Part 4 - Interactive and Animated Dragon Creation
Drawing Heighway’s Dragon - Part 4 - Interactive and Animated Dragon CreationDrawing Heighway’s Dragon - Part 4 - Interactive and Animated Dragon Creation
Drawing Heighway’s Dragon - Part 4 - Interactive and Animated Dragon Creation
Philip Schwarz
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Grand Theft Auto 6 PC Game Cracked Full Setup Download
Grand Theft Auto 6 PC Game Cracked Full Setup DownloadGrand Theft Auto 6 PC Game Cracked Full Setup Download
Grand Theft Auto 6 PC Game Cracked Full Setup Download
Iobit Uninstaller Pro Crack
 
Aligning Projects to Strategy During Economic Uncertainty
Aligning Projects to Strategy During Economic UncertaintyAligning Projects to Strategy During Economic Uncertainty
Aligning Projects to Strategy During Economic Uncertainty
OnePlan Solutions
 
File Viewer Plus 7.5.5.49 Crack Full Version
File Viewer Plus 7.5.5.49 Crack Full VersionFile Viewer Plus 7.5.5.49 Crack Full Version
File Viewer Plus 7.5.5.49 Crack Full Version
raheemk1122g
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
cram_advancedword2007version2025final.ppt
cram_advancedword2007version2025final.pptcram_advancedword2007version2025final.ppt
cram_advancedword2007version2025final.ppt
ahmedsaadtax2025
 
Choose Your Own Adventure to Get Started with Grafana Loki
Choose Your Own Adventure to Get Started with Grafana LokiChoose Your Own Adventure to Get Started with Grafana Loki
Choose Your Own Adventure to Get Started with Grafana Loki
Imma Valls Bernaus
 
Catching Wire; An introduction to CBWire 4
Catching Wire; An introduction to CBWire 4Catching Wire; An introduction to CBWire 4
Catching Wire; An introduction to CBWire 4
Ortus Solutions, Corp
 
NYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdfNYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdf
AUGNYC
 
IObit Uninstaller Pro Crack {2025} Download Free
IObit Uninstaller Pro Crack {2025} Download FreeIObit Uninstaller Pro Crack {2025} Download Free
IObit Uninstaller Pro Crack {2025} Download Free
Iobit Uninstaller Pro Crack
 
Quasar Framework Introduction for C++ develpoers
Quasar Framework Introduction for C++ develpoersQuasar Framework Introduction for C++ develpoers
Quasar Framework Introduction for C++ develpoers
sadadkhah
 
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo
 
How to Create a Crypto Wallet Like Trust.pptx
How to Create a Crypto Wallet Like Trust.pptxHow to Create a Crypto Wallet Like Trust.pptx
How to Create a Crypto Wallet Like Trust.pptx
riyageorge2024
 
Albert Pintoy - A Distinguished Software Engineer
Albert Pintoy - A Distinguished Software EngineerAlbert Pintoy - A Distinguished Software Engineer
Albert Pintoy - A Distinguished Software Engineer
Albert Pintoy
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Hyper Casual Game Developers Company
Hyper  Casual  Game  Developers  CompanyHyper  Casual  Game  Developers  Company
Hyper Casual Game Developers Company
Nova Carter
 
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by AjathMobile Application Developer Dubai | Custom App Solutions by Ajath
Mobile Application Developer Dubai | Custom App Solutions by Ajath
Ajath Infotech Technologies LLC
 
GC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance EngineeringGC Tuning: A Masterpiece in Performance Engineering
GC Tuning: A Masterpiece in Performance Engineering
Tier1 app
 
Download 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-ActivatedDownload 4k Video Downloader Crack Pre-Activated
Download 4k Video Downloader Crack Pre-Activated
Web Designer
 
Drawing Heighway’s Dragon - Part 4 - Interactive and Animated Dragon Creation
Drawing Heighway’s Dragon - Part 4 - Interactive and Animated Dragon CreationDrawing Heighway’s Dragon - Part 4 - Interactive and Animated Dragon Creation
Drawing Heighway’s Dragon - Part 4 - Interactive and Animated Dragon Creation
Philip Schwarz
 
Programs as Values - Write code and don't get lost
Programs as Values - Write code and don't get lostPrograms as Values - Write code and don't get lost
Programs as Values - Write code and don't get lost
Pierangelo Cecchetto
 
Grand Theft Auto 6 PC Game Cracked Full Setup Download
Grand Theft Auto 6 PC Game Cracked Full Setup DownloadGrand Theft Auto 6 PC Game Cracked Full Setup Download
Grand Theft Auto 6 PC Game Cracked Full Setup Download
Iobit Uninstaller Pro Crack
 
Aligning Projects to Strategy During Economic Uncertainty
Aligning Projects to Strategy During Economic UncertaintyAligning Projects to Strategy During Economic Uncertainty
Aligning Projects to Strategy During Economic Uncertainty
OnePlan Solutions
 
File Viewer Plus 7.5.5.49 Crack Full Version
File Viewer Plus 7.5.5.49 Crack Full VersionFile Viewer Plus 7.5.5.49 Crack Full Version
File Viewer Plus 7.5.5.49 Crack Full Version
raheemk1122g
 
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studiesTroubleshooting JVM Outages – 3 Fortune 500 case studies
Troubleshooting JVM Outages – 3 Fortune 500 case studies
Tier1 app
 
cram_advancedword2007version2025final.ppt
cram_advancedword2007version2025final.pptcram_advancedword2007version2025final.ppt
cram_advancedword2007version2025final.ppt
ahmedsaadtax2025
 
Choose Your Own Adventure to Get Started with Grafana Loki
Choose Your Own Adventure to Get Started with Grafana LokiChoose Your Own Adventure to Get Started with Grafana Loki
Choose Your Own Adventure to Get Started with Grafana Loki
Imma Valls Bernaus
 
Catching Wire; An introduction to CBWire 4
Catching Wire; An introduction to CBWire 4Catching Wire; An introduction to CBWire 4
Catching Wire; An introduction to CBWire 4
Ortus Solutions, Corp
 
NYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdfNYC ACE 08-May-2025-Combined Presentation.pdf
NYC ACE 08-May-2025-Combined Presentation.pdf
AUGNYC
 
IObit Uninstaller Pro Crack {2025} Download Free
IObit Uninstaller Pro Crack {2025} Download FreeIObit Uninstaller Pro Crack {2025} Download Free
IObit Uninstaller Pro Crack {2025} Download Free
Iobit Uninstaller Pro Crack
 
Quasar Framework Introduction for C++ develpoers
Quasar Framework Introduction for C++ develpoersQuasar Framework Introduction for C++ develpoers
Quasar Framework Introduction for C++ develpoers
sadadkhah
 
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo Ltd. - Introduction - Mobile application, web, custom software develo...
Codingo
 
How to Create a Crypto Wallet Like Trust.pptx
How to Create a Crypto Wallet Like Trust.pptxHow to Create a Crypto Wallet Like Trust.pptx
How to Create a Crypto Wallet Like Trust.pptx
riyageorge2024
 
Albert Pintoy - A Distinguished Software Engineer
Albert Pintoy - A Distinguished Software EngineerAlbert Pintoy - A Distinguished Software Engineer
Albert Pintoy - A Distinguished Software Engineer
Albert Pintoy
 
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business StageA Comprehensive Guide to CRM Software Benefits for Every Business Stage
A Comprehensive Guide to CRM Software Benefits for Every Business Stage
SynapseIndia
 
Hyper Casual Game Developers Company
Hyper  Casual  Game  Developers  CompanyHyper  Casual  Game  Developers  Company
Hyper Casual Game Developers Company
Nova Carter
 
Ad

Dsa unit 1

  • 1. DSA:Unit 1 Prepared by Gobinda subedi For BIT, KIST
  • 2. Prerequisite • Knowledge of C • From the point of exam, students should be familiar with algorithm and functions fluently.
  • 3. Contents Of Unit 1 • Information and its meaning of Data Structure • Abstract Data Type • ADT VS DS • Array in C • The array as an ADT • One dimensional array • Two dimensional array • Multidimensional array
  • 4. Introduction • What is data structure? A data structure is an arrangement of data in a computer’s memory (or sometimes on a disk) so that it can be used efficiently. Data structures include arrays, linked lists, stacks, binary trees, and hash tables, among others. • What is an Algorithm? Algorithms manipulate the data in these structures in various ways, such as searching for a particular data item and sorting the data.
  • 5. Introduction contd.. • Data structures are the building blocks of a program. • Data structure mainly specifies the following four things: Organization of data. Accessing methods Degree of associativity Processing alternatives for information • To develop a program from an algorithm, we should select an appropriate data structure for that algorithm. Therefore algorithm and its associated data structures form a program. • Hence, we can say that Algorithm + Data structure = Program
  • 6. Introduction contd.. • Data structure can be thought of in two basic ways: A static data structure is one whose capacity is fixed at creation. For example, array. A dynamic data structure is one whose capacity is variable, so it can expand or contract at any time. For example, linked list, binary tree etc.
  • 7. Data Structure type • Data structure can be divided into two types: Linear Data Structure: When the data is stored in the memory in the memory in linear or sequential form is called linear data structure. Examples include Array, Stack, Queue etc. Non linear Data Structure: When the data is stored in the memory in disperse or non- sequential order is called non linear data structure. Example includes trees, graphs files etc.
  • 9. Data Operation Operations • Operations are used to process the data appearing in the data structure. Following are the some of the operations used frequently: Traversing: Accessing each record exactly once so that certain items in the record may be processed. Searching: Finding the location of the record with the given key value. Inserting: Adding a new record Deleting : Removing a record. Sorting: Arranging the records in some logical order. Merging: Combining the records in two different file into a single file.
  • 10. Abstract Data Type (ADT) • Abstract data type (ADT) is a specification of a set of data and the set of operations that can be performed on the data. A set of data values and associated operations that are precisely specified independent of any particular implementation. • Real life example: Book is Abstract (Telephone Book is an implementation)
  • 11. ADT vs DS • ADT is a logical description and data structure is concrete. ADT is the logical picture of the data and the operations to manipulate the component elements of the data. Data structure is the actual representation of the data during the implementation and the algorithms to manipulate the data elements. ADT is in the logical level and data structure is in the implementation level.  ADT is implementation independent. For example, it only describes what a data type List consists (data) and what are the operations it can perform, but it has no information about how the List is actually implemented.  Whereas data structure is implementation dependent, as in the same example, it is about how the List implemented i.e., using array or linked list. Ultimately, data structure is how we implement the data in an abstract data type.
  • 12. Overview of Array • Arrays a kind of data structure that can store a fixed- size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variables of the same type. • All arrays consist of contiguous memory locations. The lowest address corresponds to the first element and the highest address to the last element.
  • 13. Types of Array • One dimensional array:  The elements of the array can be represented either as a single column or as a single row. • Declaring one-dimensional array:  data_type array_name[size]; • Following are some valid array declarations:  float weight[50];  int marks[100];  int age[15]; • Array Initialization (1-D): • The general format of array initialization is:  data_type array_name[size]={element1,element2,…………..,element n};
  • 14. • #include <stdio.h> • int main () { int n[ 10 ]; /* n is an array of 10 integers */ int i,j; /* initialize elements of array n to 0 */ for ( i = 0; i < 10; i++ ) { n[ i ] = i + 100; /* set element at location i to i + 100 */ } /* output each array element's value */ for (j = 0; j < 10; j++ ) { printf("Element[%d] = %dn", j, n[j] ); } return 0; }
  翻译: