SlideShare ist ein Scribd-Unternehmen logo
1 von 14
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;
}

Weitere ähnliche Inhalte

Was ist angesagt? (19)

Presentation 1st
Presentation 1stPresentation 1st
Presentation 1st
 
Basics of data structure
Basics of data structureBasics of data structure
Basics of data structure
 
Data structures
Data structuresData structures
Data structures
 
Basic terminologies
Basic terminologiesBasic terminologies
Basic terminologies
 
Data Structure - Elementary Data Organization
Data Structure - Elementary  Data Organization Data Structure - Elementary  Data Organization
Data Structure - Elementary Data Organization
 
Elementary data organisation
Elementary data organisationElementary data organisation
Elementary data organisation
 
introduction to Data Structure and classification
 introduction to Data Structure and classification introduction to Data Structure and classification
introduction to Data Structure and classification
 
Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)Chapter 1( intro &amp; overview)
Chapter 1( intro &amp; overview)
 
Data structures
Data structuresData structures
Data structures
 
Introduction to Data Structure part 1
Introduction to Data Structure part 1Introduction to Data Structure part 1
Introduction to Data Structure part 1
 
Pandas
PandasPandas
Pandas
 
Files and data storage
Files and data storageFiles and data storage
Files and data storage
 
Types Of Data Structure
Types Of Data StructureTypes Of Data Structure
Types Of Data Structure
 
Lecture1 data structure(introduction)
Lecture1 data structure(introduction)Lecture1 data structure(introduction)
Lecture1 data structure(introduction)
 
Array in c
Array in cArray in c
Array in c
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Data structure
Data structureData structure
Data structure
 
Lecture 1 data structures and algorithms
Lecture 1 data structures and algorithmsLecture 1 data structures and algorithms
Lecture 1 data structures and algorithms
 
R data structures-2
R data structures-2R data structures-2
R data structures-2
 

Ähnlich wie Dsa unit 1

DataStructurePpt.pptx
DataStructurePpt.pptxDataStructurePpt.pptx
DataStructurePpt.pptxssuser031f35
 
Data structure chapter 1.pptx
Data structure chapter 1.pptxData structure chapter 1.pptx
Data structure chapter 1.pptxKami503928
 
DataStructurePpt.pptx
DataStructurePpt.pptxDataStructurePpt.pptx
DataStructurePpt.pptxDCABCA
 
Unit-1 DataStructure Intro.pptx
Unit-1 DataStructure Intro.pptxUnit-1 DataStructure Intro.pptx
Unit-1 DataStructure Intro.pptxajajkhan16
 
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 JYOTHISowmya Jyothi
 
Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresresamplopsurat
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxsarala9
 
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
 
introduction about data structure_i.pptx
introduction about data structure_i.pptxintroduction about data structure_i.pptx
introduction about data structure_i.pptxpoonamsngr
 
Lecture 2 Data Structure Introduction
Lecture 2 Data Structure IntroductionLecture 2 Data Structure Introduction
Lecture 2 Data Structure IntroductionAbirami A
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptxSaralaT3
 
DATA-STRUCTURES.pptx
DATA-STRUCTURES.pptxDATA-STRUCTURES.pptx
DATA-STRUCTURES.pptxRuchiNagar3
 
Introduction - Data Structures and Algorithms.ppt
Introduction - Data Structures and Algorithms.pptIntroduction - Data Structures and Algorithms.ppt
Introduction - Data Structures and Algorithms.pptJayaKamal
 
Presentations, Documents, Infographics, and more
Presentations, Documents, Infographics, and morePresentations, Documents, Infographics, and more
Presentations, Documents, Infographics, and moreKwadjoOwusuAnsahQuar
 

Ähnlich wie Dsa unit 1 (20)

DataStructurePpt.pptx
DataStructurePpt.pptxDataStructurePpt.pptx
DataStructurePpt.pptx
 
Data structure chapter 1.pptx
Data structure chapter 1.pptxData structure chapter 1.pptx
Data structure chapter 1.pptx
 
DataStructurePpt.pptx
DataStructurePpt.pptxDataStructurePpt.pptx
DataStructurePpt.pptx
 
Unit-1 DataStructure Intro.pptx
Unit-1 DataStructure Intro.pptxUnit-1 DataStructure Intro.pptx
Unit-1 DataStructure Intro.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
 
Unit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data StructuresresUnit.1 Introduction to Data Structuresres
Unit.1 Introduction to Data Structuresres
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.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
 
introduction about data structure_i.pptx
introduction about data structure_i.pptxintroduction about data structure_i.pptx
introduction about data structure_i.pptx
 
Ch1
Ch1Ch1
Ch1
 
Lecture 2 Data Structure Introduction
Lecture 2 Data Structure IntroductionLecture 2 Data Structure Introduction
Lecture 2 Data Structure Introduction
 
DS Module 1.pptx
DS Module 1.pptxDS Module 1.pptx
DS Module 1.pptx
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
Unit 1.ppt
Unit 1.pptUnit 1.ppt
Unit 1.ppt
 
DATA-STRUCTURES.pptx
DATA-STRUCTURES.pptxDATA-STRUCTURES.pptx
DATA-STRUCTURES.pptx
 
UNIT I - Data Structures.pdf
UNIT I - Data Structures.pdfUNIT I - Data Structures.pdf
UNIT I - Data Structures.pdf
 
dsa.pptx
dsa.pptxdsa.pptx
dsa.pptx
 
DSA - Copy.pptx
DSA - Copy.pptxDSA - Copy.pptx
DSA - Copy.pptx
 
Introduction - Data Structures and Algorithms.ppt
Introduction - Data Structures and Algorithms.pptIntroduction - Data Structures and Algorithms.ppt
Introduction - Data Structures and Algorithms.ppt
 
Presentations, Documents, Infographics, and more
Presentations, Documents, Infographics, and morePresentations, Documents, Infographics, and more
Presentations, Documents, Infographics, and more
 

Kürzlich hochgeladen

%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benonimasabamasaba
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburgmasabamasaba
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxAnnaArtyushina1
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...masabamasaba
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...chiefasafspells
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 

Kürzlich hochgeladen (20)

%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
WSO2CON 2024 - API Management Usage at La Poste and Its Impact on Business an...
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
Love witchcraft +27768521739 Binding love spell in Sandy Springs, GA |psychic...
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 

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; }