SlideShare a Scribd company logo
1 of 24
Unit 1
Concept and Definition of
Data Structures
Ashim Lamichhane 1
Goal
• As computers become faster and faster, the need for programs that can
handle large amounts of input becomes more acute.
• This requires more careful attention to efficiency, since inefficiencies in
programs become most obvious when input sizes are large.
• By analyzing an algorithm before it is actually coded, we can decide if
a particular solution will be feasible.
• The goal is to develop good programming and algorithm analysis skills
simultaneously so that we can develop such programs with the maximum
amount of efficiency.
Ashim Lamichhane 2
Objective
• To identify and create useful mathematical entities to determine what
classes of problems can be solved by using these entities and
operations.
• To determine the representations of these abstract entities and to
implement the abstract operations on these concrete representations.
Ashim Lamichhane 3
Introduction to the theory of DATA STRUCTURE
• It’s a branch of computer science that unleashes the knowledge of
• how data should organized,
• how the flow of data should be controlled and
• how data structure should be designed and implemented to reduce the
complexity and increase the efficiency of the algorithm.
• It enables you to design and implement various data structure, for
example, the stacks, queues, linked lists, trees and graphs.
• Effective use of principles of data structures increases efficiency of
algorithms to solve problems like searching, sorting, populating and
handling huge set of data.
Ashim Lamichhane 4
Need of a Data Structure
• A data structure helps you to understand the relationship of one data
element with the other and organize it within the memory.
• Consider an example, list of names of months in a year.
• Similarly consider a set of data that represents location of historical
places in a country.
• Such data form a hierarchical relationship between them and must be
represented in the memory using a hierarchical type of data structure
Ashim Lamichhane 5
Nepal
ktm bkt LLt
pashupati baglamukhi suryabinayak
Mahabauddha
temple
Krishna mandir
Fig. hierarchical representation
Ashim Lamichhane 6
Data structures are widely applied in areas like
• Compiler design
• Operating system
• Statistical analysis package
• DBMS
• Numerical analysis
• Simulation
• Artificial Intelligence
• Graphics
Ashim Lamichhane 7
Arrays
• One dimensional array can be represented either as a single column or
as single row.
• Following are some valid array declarations:
• Int age[15];
• Float weight[40];
• Following are some invalid array declarations in c:
• Int value[0];
• Int marks[0.5];
• Int number[-5];
Ashim Lamichhane 8
Some common operation performed in 1D array
• Creating an array
• Inserting new element at required position
• Deletion of any array element
• Modification of any element
• Traversing of an array
• Merging of arrays
Ashim Lamichhane 9
CODE SAMPLE CHECK
• FOLLOW THE LINK
https://github.com/ashim888/dataStructureAndAlgorithm/blob/master/
codes/shift_pos.c
Ashim Lamichhane 10
ASSIGNMENT AT FOLLOWING LINK
https://github.com/ashim888/dataStructureAndAlgorithm/tree/master/
Assignments/assignment_3
Ashim Lamichhane 11
Implementation of a two dimensional array
• A two dimensional array can be implemented in a programming
language in two ways:
• Row Major Implementation
• Column Major Implementation
Ashim Lamichhane 12
Row Major Implementation
• Row-major implementation is a linearization technique in which
elements of array are readers from the keyboard row-wise
• The complete first row is stored and then the complete second row is
stored.
• For example, an array a[3][3] is stored in the memory as shown in fig
below:
Ashim Lamichhane 13
Column Major Implementation
• In column major implementation memory allocation is done column
by column i.e. at first the elements of the complete first column is
stored, and then elements of complete second column is stored, and
so on.
• For example an array a [3] [3] is stored in the memory as shown in the
fig below:
Ashim Lamichhane 14
Multi-Dimensional array
• C also allows arrays with more than two dimensions. For example, a
three dimensional array may be declared by
int a[3][2][4]
• Here, the first subscript specifies a plane number, the second subscript
a row number and the third a column number.
Ashim Lamichhane 15
Multi-Dimensional array
Fig. Representation of array a[3][2][4]
Ashim Lamichhane 16
Multi-Dimensional array
Ashim Lamichhane 17
Abstract Data Types (ADT)
• We are well acquainted with data types by now, like integers, arrays,
and so on.
• To access the data, we've used operations defined in the programming
language for the data type, for instance by accessing array elements by
using the square bracket notation.
• An abstract data type is a data type whose representation is hidden
from, and of no concern to the application code.
Ashim Lamichhane 18
Abstract Data Types (ADT)
• For example, when writing application code, we don’t care how strings
are represented: we just declare variables of type string, and
manipulate them by using string operations.
• Once an abstract data type has been designed, the programmer
responsible for implementing that type is concerned only with
choosing a suitable data structure and coding up the methods.
• On the other hand, application programmers are concerned only with
using that type and calling its methods without worrying much about
how the type is implemented.
Ashim Lamichhane 19
ADT conclusion
• ADT acts as a useful guideline to implement a data type correctly.
• The implementation of an ADT involves the translation of the ADT’s
specification into syntax of a particular programming language.
• For ex, the int data type, provides an implementation of the
mathematical concept of an integer number.
• The int data type in C can be considered as an implementation of
Abstract Data Type, INTEGER-ADT, which defines the union of set { -1, -
2, -3 …} and the set of whole numbers {0, 1, ....}
Ashim Lamichhane 20
The Array As An ADT
• An array is probably the most versatile or fundamental Abstract Data
Type
• An array is a finite sequence of storage cells, for which the following
operations are defined:
• create(A,N)creates an array A with storage for N items;
• A[i]=item stores item in the ith position in the array A; and
• A[i] returns the value of the item stored in the ith position in the array A.
Ashim Lamichhane 21
Show that an array is an ADT
• Let A be an array of type T and has n elements then it satisfied the following
operations
1. CREATE(A): Create an array A
2. INSERT(A,X): Insert an element X into an array A in any location
3. DELETE(A,X): Delete an element X from an array A
4. MODIFY(A,X,Y): modify element X by Y of an array A
5. TRAVELS(A): Access all elements of an array A
6. MERGE(A,B): Merging elements of A and B into a third array C
Thus by using 1D array we can perform above operations thus an array acts
as an ADT.
Ashim Lamichhane 22
Conclusion
• An abstract data type is the specification of the data type which
specifies the logical and mathematical model of the data type.
• A data type is the implementation of an abstract data type.
• Data Structure refers to the collection of computer variables that are
connected in specific manner.
Ashim Lamichhane 23
ASSIGNMENT AT FOLLOWING LINK
https://github.com/ashim888/dataStructureAndAlgorithm/tree/master/
Assignments/assignment_3
Ashim Lamichhane 24

More Related Content

What's hot

Data structures (introduction)
 Data structures (introduction) Data structures (introduction)
Data structures (introduction)
Arvind Devaraj
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
Kumar
 

What's hot (20)

Data structure ppt
Data structure pptData structure ppt
Data structure ppt
 
Data structures using c
Data structures using cData structures using c
Data structures using c
 
Data structures
Data structuresData structures
Data structures
 
Lecture 1 and 2
Lecture 1 and 2Lecture 1 and 2
Lecture 1 and 2
 
Introduction to data structure by anil dutt
Introduction to data structure by anil duttIntroduction to data structure by anil dutt
Introduction to data structure by anil dutt
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
DATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGEDATA STRUCTURE IN C LANGUAGE
DATA STRUCTURE IN C LANGUAGE
 
Introduction To Data Structures.
Introduction To Data Structures.Introduction To Data Structures.
Introduction To 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
 
Unit 1 introduction to data structure
Unit 1   introduction to data structureUnit 1   introduction to data structure
Unit 1 introduction to data structure
 
Data Structures (CS8391)
Data Structures (CS8391)Data Structures (CS8391)
Data Structures (CS8391)
 
Data Structures Notes 2021
Data Structures Notes 2021Data Structures Notes 2021
Data Structures Notes 2021
 
DATA STRUCTURE
DATA STRUCTUREDATA STRUCTURE
DATA STRUCTURE
 
Lecture 2a arrays
Lecture 2a arraysLecture 2a arrays
Lecture 2a arrays
 
Data structures (introduction)
 Data structures (introduction) Data structures (introduction)
Data structures (introduction)
 
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 Structure In C#
Data Structure In C#Data Structure In C#
Data Structure In C#
 
Data Structure Using C
Data Structure Using CData Structure Using C
Data Structure Using C
 
Data structure and algorithm All in One
Data structure and algorithm All in OneData structure and algorithm All in One
Data structure and algorithm All in One
 
Data structure lecture 2
Data structure lecture 2Data structure lecture 2
Data structure lecture 2
 

Viewers also liked

Friedman two way analysis of variance by
Friedman two way analysis of  variance byFriedman two way analysis of  variance by
Friedman two way analysis of variance by
Iybaro Reyes
 
Text data mining1
Text data mining1Text data mining1
Text data mining1
KU Leuven
 

Viewers also liked (20)

Searching
SearchingSearching
Searching
 
Queues
QueuesQueues
Queues
 
Algorithm big o
Algorithm big oAlgorithm big o
Algorithm big o
 
Unit 11. Graphics
Unit 11. GraphicsUnit 11. Graphics
Unit 11. Graphics
 
Unit 9. Structure and Unions
Unit 9. Structure and UnionsUnit 9. Structure and Unions
Unit 9. Structure and Unions
 
Algorithm Introduction
Algorithm IntroductionAlgorithm Introduction
Algorithm Introduction
 
Linked List
Linked ListLinked List
Linked List
 
Sorting
SortingSorting
Sorting
 
The Stack And Recursion
The Stack And RecursionThe Stack And Recursion
The Stack And Recursion
 
Unit 8. Pointers
Unit 8. PointersUnit 8. Pointers
Unit 8. Pointers
 
Unit 6. Arrays
Unit 6. ArraysUnit 6. Arrays
Unit 6. Arrays
 
Friedman two way analysis of variance by
Friedman two way analysis of  variance byFriedman two way analysis of  variance by
Friedman two way analysis of variance by
 
Unit 7. Functions
Unit 7. FunctionsUnit 7. Functions
Unit 7. Functions
 
Formal Concept Analysis
Formal Concept AnalysisFormal Concept Analysis
Formal Concept Analysis
 
Data analysis chapter 18 from the companion website for educational research
Data analysis   chapter 18 from the companion website for educational researchData analysis   chapter 18 from the companion website for educational research
Data analysis chapter 18 from the companion website for educational research
 
UNIT 10. Files and file handling in C
UNIT 10. Files and file handling in CUNIT 10. Files and file handling in C
UNIT 10. Files and file handling in C
 
File handling in c
File handling in cFile handling in c
File handling in c
 
Concept Analysis Presentation
Concept Analysis PresentationConcept Analysis Presentation
Concept Analysis Presentation
 
Tree - Data Structure
Tree - Data StructureTree - Data Structure
Tree - Data Structure
 
Text data mining1
Text data mining1Text data mining1
Text data mining1
 

Similar to Introduction to data_structure

Introduction to DS.pptx
Introduction to DS.pptxIntroduction to DS.pptx
Introduction to DS.pptx
OnkarModhave
 
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
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
AntareepMajumder
 
data structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxdata structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptx
coc7987515756
 

Similar to Introduction to data_structure (20)

Data Structures - Lecture 1 - Unit 1.pptx
Data Structures  - Lecture 1 - Unit 1.pptxData Structures  - Lecture 1 - Unit 1.pptx
Data Structures - Lecture 1 - Unit 1.pptx
 
Introduction to DS.pptx
Introduction to DS.pptxIntroduction to DS.pptx
Introduction to DS.pptx
 
Data structure
Data structureData structure
Data structure
 
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
 
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 - 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
 
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
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Unit 1 dsa
 
UNIT 3 PPT.ppt
UNIT 3 PPT.pptUNIT 3 PPT.ppt
UNIT 3 PPT.ppt
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
 
UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 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
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 
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.pptx
b,Sc it data structure.pptxb,Sc it data structure.pptx
b,Sc it data structure.pptx
 
8.unit-1-fds-2022-23.pptx
8.unit-1-fds-2022-23.pptx8.unit-1-fds-2022-23.pptx
8.unit-1-fds-2022-23.pptx
 
b,Sc it data structure.ppt
b,Sc it data structure.pptb,Sc it data structure.ppt
b,Sc it data structure.ppt
 
data structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptxdata structure unit -1_170434dd7400.pptx
data structure unit -1_170434dd7400.pptx
 
ADS Introduction
ADS IntroductionADS Introduction
ADS Introduction
 
Data Structure & Algorithm.pptx
Data Structure & Algorithm.pptxData Structure & Algorithm.pptx
Data Structure & Algorithm.pptx
 

Recently uploaded

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 

Introduction to data_structure

  • 1. Unit 1 Concept and Definition of Data Structures Ashim Lamichhane 1
  • 2. Goal • As computers become faster and faster, the need for programs that can handle large amounts of input becomes more acute. • This requires more careful attention to efficiency, since inefficiencies in programs become most obvious when input sizes are large. • By analyzing an algorithm before it is actually coded, we can decide if a particular solution will be feasible. • The goal is to develop good programming and algorithm analysis skills simultaneously so that we can develop such programs with the maximum amount of efficiency. Ashim Lamichhane 2
  • 3. Objective • To identify and create useful mathematical entities to determine what classes of problems can be solved by using these entities and operations. • To determine the representations of these abstract entities and to implement the abstract operations on these concrete representations. Ashim Lamichhane 3
  • 4. Introduction to the theory of DATA STRUCTURE • It’s a branch of computer science that unleashes the knowledge of • how data should organized, • how the flow of data should be controlled and • how data structure should be designed and implemented to reduce the complexity and increase the efficiency of the algorithm. • It enables you to design and implement various data structure, for example, the stacks, queues, linked lists, trees and graphs. • Effective use of principles of data structures increases efficiency of algorithms to solve problems like searching, sorting, populating and handling huge set of data. Ashim Lamichhane 4
  • 5. Need of a Data Structure • A data structure helps you to understand the relationship of one data element with the other and organize it within the memory. • Consider an example, list of names of months in a year. • Similarly consider a set of data that represents location of historical places in a country. • Such data form a hierarchical relationship between them and must be represented in the memory using a hierarchical type of data structure Ashim Lamichhane 5
  • 6. Nepal ktm bkt LLt pashupati baglamukhi suryabinayak Mahabauddha temple Krishna mandir Fig. hierarchical representation Ashim Lamichhane 6
  • 7. Data structures are widely applied in areas like • Compiler design • Operating system • Statistical analysis package • DBMS • Numerical analysis • Simulation • Artificial Intelligence • Graphics Ashim Lamichhane 7
  • 8. Arrays • One dimensional array can be represented either as a single column or as single row. • Following are some valid array declarations: • Int age[15]; • Float weight[40]; • Following are some invalid array declarations in c: • Int value[0]; • Int marks[0.5]; • Int number[-5]; Ashim Lamichhane 8
  • 9. Some common operation performed in 1D array • Creating an array • Inserting new element at required position • Deletion of any array element • Modification of any element • Traversing of an array • Merging of arrays Ashim Lamichhane 9
  • 10. CODE SAMPLE CHECK • FOLLOW THE LINK https://github.com/ashim888/dataStructureAndAlgorithm/blob/master/ codes/shift_pos.c Ashim Lamichhane 10
  • 11. ASSIGNMENT AT FOLLOWING LINK https://github.com/ashim888/dataStructureAndAlgorithm/tree/master/ Assignments/assignment_3 Ashim Lamichhane 11
  • 12. Implementation of a two dimensional array • A two dimensional array can be implemented in a programming language in two ways: • Row Major Implementation • Column Major Implementation Ashim Lamichhane 12
  • 13. Row Major Implementation • Row-major implementation is a linearization technique in which elements of array are readers from the keyboard row-wise • The complete first row is stored and then the complete second row is stored. • For example, an array a[3][3] is stored in the memory as shown in fig below: Ashim Lamichhane 13
  • 14. Column Major Implementation • In column major implementation memory allocation is done column by column i.e. at first the elements of the complete first column is stored, and then elements of complete second column is stored, and so on. • For example an array a [3] [3] is stored in the memory as shown in the fig below: Ashim Lamichhane 14
  • 15. Multi-Dimensional array • C also allows arrays with more than two dimensions. For example, a three dimensional array may be declared by int a[3][2][4] • Here, the first subscript specifies a plane number, the second subscript a row number and the third a column number. Ashim Lamichhane 15
  • 16. Multi-Dimensional array Fig. Representation of array a[3][2][4] Ashim Lamichhane 16
  • 18. Abstract Data Types (ADT) • We are well acquainted with data types by now, like integers, arrays, and so on. • To access the data, we've used operations defined in the programming language for the data type, for instance by accessing array elements by using the square bracket notation. • An abstract data type is a data type whose representation is hidden from, and of no concern to the application code. Ashim Lamichhane 18
  • 19. Abstract Data Types (ADT) • For example, when writing application code, we don’t care how strings are represented: we just declare variables of type string, and manipulate them by using string operations. • Once an abstract data type has been designed, the programmer responsible for implementing that type is concerned only with choosing a suitable data structure and coding up the methods. • On the other hand, application programmers are concerned only with using that type and calling its methods without worrying much about how the type is implemented. Ashim Lamichhane 19
  • 20. ADT conclusion • ADT acts as a useful guideline to implement a data type correctly. • The implementation of an ADT involves the translation of the ADT’s specification into syntax of a particular programming language. • For ex, the int data type, provides an implementation of the mathematical concept of an integer number. • The int data type in C can be considered as an implementation of Abstract Data Type, INTEGER-ADT, which defines the union of set { -1, - 2, -3 …} and the set of whole numbers {0, 1, ....} Ashim Lamichhane 20
  • 21. The Array As An ADT • An array is probably the most versatile or fundamental Abstract Data Type • An array is a finite sequence of storage cells, for which the following operations are defined: • create(A,N)creates an array A with storage for N items; • A[i]=item stores item in the ith position in the array A; and • A[i] returns the value of the item stored in the ith position in the array A. Ashim Lamichhane 21
  • 22. Show that an array is an ADT • Let A be an array of type T and has n elements then it satisfied the following operations 1. CREATE(A): Create an array A 2. INSERT(A,X): Insert an element X into an array A in any location 3. DELETE(A,X): Delete an element X from an array A 4. MODIFY(A,X,Y): modify element X by Y of an array A 5. TRAVELS(A): Access all elements of an array A 6. MERGE(A,B): Merging elements of A and B into a third array C Thus by using 1D array we can perform above operations thus an array acts as an ADT. Ashim Lamichhane 22
  • 23. Conclusion • An abstract data type is the specification of the data type which specifies the logical and mathematical model of the data type. • A data type is the implementation of an abstract data type. • Data Structure refers to the collection of computer variables that are connected in specific manner. Ashim Lamichhane 23
  • 24. ASSIGNMENT AT FOLLOWING LINK https://github.com/ashim888/dataStructureAndAlgorithm/tree/master/ Assignments/assignment_3 Ashim Lamichhane 24