SlideShare a Scribd company logo
Algorithm and
Data Structure
Andi Nurkholis, S.Kom, M.Kom
Study Program of Informatics
Faculty of Engineering and Computer Science
SY. 2020-2021
February 22, 2021
2
2 Array and Struct
3
What is Array?
Array also known as “larik”. Array is data collections
with each data element using same name and type
Each component/element of array can be accessed
and distinguished through index
4
Type of Array 1) One-Dimensional Array
2) Multi-Dimensional Array
5
One-Dimensional Array
A collection of identical elements arranged in a row. These
elements have the same data type, but content of those elements
may be different
6
Example
2 4 8 16 32 64 128 256 512 1024
0 1 2 3 4 5 6 7 8 9
Index
Data
dataType ArrayName[ElementNumber]={<Initialization>};
ArrayName [index];
Declaration
Access
7
Multi-Dimensional Array
Multi-dimensional array is data collections consisting of rows
and columns of elements of the same type
8
Example
(0,0) (0,1) (0,2)
(1,0) (1,1) (1,2)
(2,0) (2,1) (2,2)
(3,0) (3,1) (3,2)
(4,0) (4,1) (4,2)
(0,0) (0,1) (0,2) (0,3)
(1,0) (1,1) (1,2) (1,3)
(2,0) (2,1) (2,2) (2,3)
(3,0) (3,1) (3,2) (3,3)
(0,0) (0,1) (0,2) (0,3) (0,4) (0,5)
(1,0) (1,1) (1,2) (1,3) (1,4) (1,5)
(2,0) (2,1) (2,2) (2,3) (2,4) (2,5)
(3,0) (3,1) (3,2) (3,3) (3,4) (3,5)
(4,0) (4,1) (4,2) (4,3) (4,4) (4,5)
2-D Array 5x3
2-D Array 4x4
2-D Array 5x6
9
Example (Cont.)
dataType ArrayName [Row][Column] =
{
{<RowInitialization1>},{< RowInitialization2>},{<RowInitializationN>}
{<RowInitialization1>},{< RowInitialization2>},{<RowInitializationN>}
};
ArrayName [Row][Column];
Declaration
Access
10
Record / Struct
Record is data collections that is not similar or
varied. In C, record also known as struct
The difference between record and array is that
record can be filled with data that have different data
type
11
Example
struct nama_type_record {tipe_data1 nm_var1; tipe_data2 nm_var2;
tipe_dataN nm_varN;} var_record;
General form of record
12
Example (Cont.)
struct mahasiswa { char nama[20]; char npm[10], int nilai;
} nilaiMhs;
nilaiMhs.nama;
nilaiMhs.npm;
nilaiMhs.nilai;
Declaration
Access
13
Record in Array
Record in array make it possible to store record data in an array
index.
That is, using this technique can store some data that has different
data types in an array
For example, some students can have a name and value.
14
Example
struct nama_type_record {tipe_data1 nm_var1; tipe_data2 nm_var2;
tipe_dataN nm_varN;} var_record[ArrayElement];
General form of record in array
15
Example (Cont.)
struct mahasiswa { char nama[20]; int nilai;
} nilaiMhs[3];
nilaiMhs[0].nama;
nilaiMhs[0].nilai;
Declaration
Access
16
Array in Record
Arrays in a record make it possible to store array data in a record.
That is, using this technique can store multiple indexes of array
data into a record that has a different data type.
For example, a student can have a name and several grades.
17
Example
struct nama_type_record {tipe_data1 nm_var1[ArrayElement];
tipe_data2 nm_var2[ArrayElement];
tipe_dataN nm_varN;[ArrayElement]}
var_record;
General form of array in record
18
Example (Cont.)
struct mahasiswa { char nama[20][3]; int nilai[3];
} nilaiMhs;
nilaiMhs.nama[0];
nilaiMhs.nilai[0];
Declaration
Access
19
Array in Array Record
Arrays in a array record make it possible to store array data in a
array record.
That is, using this technique can store multiple indexes of array
data into multiple record that has a different data type.
For example, each of student can have a name and several grades.
20
Example
General form of array in record array
struct nama_type_record {tipe_data1 nm_var1[ArrayElement];
tipe_data2 nm_var2[ArrayElement];
tipe_dataN nm_varN;[ArrayElement]}
var_record[ArrayElement];
21
Example (Cont.)
struct mahasiswa { char nama[20][3]; int nilai[3];
} nilaiMhs[3];
nilaiMhs[1].nama[0];
nilaiMhs[1].nilai[0];
Declaration
Access
Thank You, Next …
Modular Programming
February 22, 2021
Andi Nurkholis, S.Kom, M.Kom
Study Program of Informatics
Faculty of Engineering and Computer Science
SY. 2020-2021

More Related Content

PPTX
Array c programming
PPTX
Array in c
PPTX
Array in c
PPT
Numeric Arrays [6]
PPTX
Dsa unit 1
PPT
Presentation of array
PPTX
Array in c programming
PPT
Basics of data structure
Array c programming
Array in c
Array in c
Numeric Arrays [6]
Dsa unit 1
Presentation of array
Array in c programming
Basics of data structure

What's hot (20)

PPTX
Dynamic memory allocation and linked lists
PPT
Abstract data types
PPTX
Matlab Organizing Data
PPTX
PPT
Elementary data organisation
PPTX
2 d array
PDF
PPTX
introduction to Data Structure and classification
PPT
Abstract data types
PPTX
concept of data structure
PPTX
Introduction to arrays
PPT
Basic terminologies
PPTX
Mca ii dfs u-1 introduction to data structure
PPTX
Introduction linked list
PPTX
PPTX
Arrays in C
PPTX
Arrays declartion and initialization
PPT
Data structures
PPT
Using xml in a data set (ado.net)
PPT
Abstract data types (adt) intro to data structure part 2
Dynamic memory allocation and linked lists
Abstract data types
Matlab Organizing Data
Elementary data organisation
2 d array
introduction to Data Structure and classification
Abstract data types
concept of data structure
Introduction to arrays
Basic terminologies
Mca ii dfs u-1 introduction to data structure
Introduction linked list
Arrays in C
Arrays declartion and initialization
Data structures
Using xml in a data set (ado.net)
Abstract data types (adt) intro to data structure part 2
Ad

Similar to Algorithm and Data Structure - Array and Struct (20)

DOCX
PPTX
PPTX
Presentation on array
PPTX
Array lecture
PDF
Arrays
PPTX
Array Introduction One-dimensional array Multidimensional array
PPTX
A singly linked list is a linear data structure
PDF
array-191103180006.pdf
PDF
DSA-Lecture-05
PPTX
Arrays accessing using for loops
PPTX
Arrays in Data Structure and Algorithm
PDF
Chapter 4 (Part I) - Array and Strings.pdf
PPTX
Arrays in c
PPTX
concept of Array, 1D & 2D array
PPTX
Arrays in C++ in Tamil - TNSCERT SYLLABUS PPT
PPTX
"Understanding Arrays in Data Structures: A Beginners Guide."
PPTX
Array in C
PPTX
BHARGAVIARRAY.PPT.pptx
PPTX
Arrays.pptx
PPTX
c2ppt.pptxslidenoteseceslidenoteseceslidenoteseceslidenoteseceslidenotesece
Presentation on array
Array lecture
Arrays
Array Introduction One-dimensional array Multidimensional array
A singly linked list is a linear data structure
array-191103180006.pdf
DSA-Lecture-05
Arrays accessing using for loops
Arrays in Data Structure and Algorithm
Chapter 4 (Part I) - Array and Strings.pdf
Arrays in c
concept of Array, 1D & 2D array
Arrays in C++ in Tamil - TNSCERT SYLLABUS PPT
"Understanding Arrays in Data Structures: A Beginners Guide."
Array in C
BHARGAVIARRAY.PPT.pptx
Arrays.pptx
c2ppt.pptxslidenoteseceslidenoteseceslidenoteseceslidenoteseceslidenotesece
Ad

More from AndiNurkholis1 (20)

PDF
Technopreneurship - 9 Analisis Biaya dan Keuangan
PDF
Pengantar Bisnis - 14 Manajemen Keuangan
PDF
Pengantar Bisnis - 13 Manajemen Operasi
PDF
Pengantar Bisnis - 12 Kebijakan Harga
PDF
Pengantar Bisnis - 11 Kebijakan Distribusi
PDF
Technopreneurship - 8 Manajemen Sumber Daya Manusia
PDF
Pengantar Bisnis - 10 Kebijakan Produk
PDF
Technopreneurship - 7 Manajemen Pemasaran dan Operasional Bisnis
PDF
Pengantar Bisnis - 9 Manajemen Pemasaran
PDF
Technopreneurship - 6 Business Plan
PDF
Pengantar Bisnis - 8 Kepemimpinan
PDF
Technopreneurship - 5 Model Bisnis
PDF
Technopreneurship - 4 Studi Kelayakan Usaha
PDF
Pengantar Bisnis - 7 Motivasi Kerja
PDF
Pengantar Bisnis - 6 Manajemen Sumber Daya Manusia
PDF
Pengantar Bisnis - 5 Pengelolaan & Pengorganisasian Bisnis
PDF
Technopreneurship - 3 Ide dan Prinsip Bisnis
PDF
Pengantar Bisnis - 4 Bentuk Organisasi Bisnis
PDF
Technopreneurship - 2 Pengantar Technopreneurship
PDF
Pengantar Bisnis - 3 Globalisasi Ekonomi & Bisnis Internasional
Technopreneurship - 9 Analisis Biaya dan Keuangan
Pengantar Bisnis - 14 Manajemen Keuangan
Pengantar Bisnis - 13 Manajemen Operasi
Pengantar Bisnis - 12 Kebijakan Harga
Pengantar Bisnis - 11 Kebijakan Distribusi
Technopreneurship - 8 Manajemen Sumber Daya Manusia
Pengantar Bisnis - 10 Kebijakan Produk
Technopreneurship - 7 Manajemen Pemasaran dan Operasional Bisnis
Pengantar Bisnis - 9 Manajemen Pemasaran
Technopreneurship - 6 Business Plan
Pengantar Bisnis - 8 Kepemimpinan
Technopreneurship - 5 Model Bisnis
Technopreneurship - 4 Studi Kelayakan Usaha
Pengantar Bisnis - 7 Motivasi Kerja
Pengantar Bisnis - 6 Manajemen Sumber Daya Manusia
Pengantar Bisnis - 5 Pengelolaan & Pengorganisasian Bisnis
Technopreneurship - 3 Ide dan Prinsip Bisnis
Pengantar Bisnis - 4 Bentuk Organisasi Bisnis
Technopreneurship - 2 Pengantar Technopreneurship
Pengantar Bisnis - 3 Globalisasi Ekonomi & Bisnis Internasional

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
ai-archetype-understanding-the-personality-of-agentic-ai.pdf
PPTX
Web Security: Login Bypass, SQLi, CSRF & XSS.pptx
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PDF
A Day in the Life of Location Data - Turning Where into How.pdf
PDF
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
PDF
Sensors and Actuators in IoT Systems using pdf
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
PDF
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
PDF
Chapter 2 Digital Image Fundamentals.pdf
PDF
Reimagining Insurance: Connected Data for Confident Decisions.pdf
PPTX
CroxyProxy Instagram Access id login.pptx
PDF
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
PDF
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
PPTX
Belt and Road Supply Chain Finance Blockchain Solution
PDF
Automating ArcGIS Content Discovery with FME: A Real World Use Case
PDF
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT
Chapter 3 Spatial Domain Image Processing.pdf
ai-archetype-understanding-the-personality-of-agentic-ai.pdf
Web Security: Login Bypass, SQLi, CSRF & XSS.pptx
GamePlan Trading System Review: Professional Trader's Honest Take
A Day in the Life of Location Data - Turning Where into How.pdf
HCSP-Presales-Campus Network Planning and Design V1.0 Training Material-Witho...
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
CIFDAQ's Market Wrap: Ethereum Leads, Bitcoin Lags, Institutions Shift
Sensors and Actuators in IoT Systems using pdf
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
CIFDAQ's Token Spotlight: SKY - A Forgotten Giant's Comeback?
solutions_manual_-_materials___processing_in_manufacturing__demargo_.pdf
Chapter 2 Digital Image Fundamentals.pdf
Reimagining Insurance: Connected Data for Confident Decisions.pdf
CroxyProxy Instagram Access id login.pptx
CIFDAQ's Teaching Thursday: Moving Averages Made Simple
How AI Agents Improve Data Accuracy and Consistency in Due Diligence.pdf
Belt and Road Supply Chain Finance Blockchain Solution
Automating ArcGIS Content Discovery with FME: A Real World Use Case
BLW VOCATIONAL TRAINING SUMMER INTERNSHIP REPORT

Algorithm and Data Structure - Array and Struct

  • 1. Algorithm and Data Structure Andi Nurkholis, S.Kom, M.Kom Study Program of Informatics Faculty of Engineering and Computer Science SY. 2020-2021 February 22, 2021
  • 2. 2 2 Array and Struct
  • 3. 3 What is Array? Array also known as “larik”. Array is data collections with each data element using same name and type Each component/element of array can be accessed and distinguished through index
  • 4. 4 Type of Array 1) One-Dimensional Array 2) Multi-Dimensional Array
  • 5. 5 One-Dimensional Array A collection of identical elements arranged in a row. These elements have the same data type, but content of those elements may be different
  • 6. 6 Example 2 4 8 16 32 64 128 256 512 1024 0 1 2 3 4 5 6 7 8 9 Index Data dataType ArrayName[ElementNumber]={<Initialization>}; ArrayName [index]; Declaration Access
  • 7. 7 Multi-Dimensional Array Multi-dimensional array is data collections consisting of rows and columns of elements of the same type
  • 8. 8 Example (0,0) (0,1) (0,2) (1,0) (1,1) (1,2) (2,0) (2,1) (2,2) (3,0) (3,1) (3,2) (4,0) (4,1) (4,2) (0,0) (0,1) (0,2) (0,3) (1,0) (1,1) (1,2) (1,3) (2,0) (2,1) (2,2) (2,3) (3,0) (3,1) (3,2) (3,3) (0,0) (0,1) (0,2) (0,3) (0,4) (0,5) (1,0) (1,1) (1,2) (1,3) (1,4) (1,5) (2,0) (2,1) (2,2) (2,3) (2,4) (2,5) (3,0) (3,1) (3,2) (3,3) (3,4) (3,5) (4,0) (4,1) (4,2) (4,3) (4,4) (4,5) 2-D Array 5x3 2-D Array 4x4 2-D Array 5x6
  • 9. 9 Example (Cont.) dataType ArrayName [Row][Column] = { {<RowInitialization1>},{< RowInitialization2>},{<RowInitializationN>} {<RowInitialization1>},{< RowInitialization2>},{<RowInitializationN>} }; ArrayName [Row][Column]; Declaration Access
  • 10. 10 Record / Struct Record is data collections that is not similar or varied. In C, record also known as struct The difference between record and array is that record can be filled with data that have different data type
  • 11. 11 Example struct nama_type_record {tipe_data1 nm_var1; tipe_data2 nm_var2; tipe_dataN nm_varN;} var_record; General form of record
  • 12. 12 Example (Cont.) struct mahasiswa { char nama[20]; char npm[10], int nilai; } nilaiMhs; nilaiMhs.nama; nilaiMhs.npm; nilaiMhs.nilai; Declaration Access
  • 13. 13 Record in Array Record in array make it possible to store record data in an array index. That is, using this technique can store some data that has different data types in an array For example, some students can have a name and value.
  • 14. 14 Example struct nama_type_record {tipe_data1 nm_var1; tipe_data2 nm_var2; tipe_dataN nm_varN;} var_record[ArrayElement]; General form of record in array
  • 15. 15 Example (Cont.) struct mahasiswa { char nama[20]; int nilai; } nilaiMhs[3]; nilaiMhs[0].nama; nilaiMhs[0].nilai; Declaration Access
  • 16. 16 Array in Record Arrays in a record make it possible to store array data in a record. That is, using this technique can store multiple indexes of array data into a record that has a different data type. For example, a student can have a name and several grades.
  • 17. 17 Example struct nama_type_record {tipe_data1 nm_var1[ArrayElement]; tipe_data2 nm_var2[ArrayElement]; tipe_dataN nm_varN;[ArrayElement]} var_record; General form of array in record
  • 18. 18 Example (Cont.) struct mahasiswa { char nama[20][3]; int nilai[3]; } nilaiMhs; nilaiMhs.nama[0]; nilaiMhs.nilai[0]; Declaration Access
  • 19. 19 Array in Array Record Arrays in a array record make it possible to store array data in a array record. That is, using this technique can store multiple indexes of array data into multiple record that has a different data type. For example, each of student can have a name and several grades.
  • 20. 20 Example General form of array in record array struct nama_type_record {tipe_data1 nm_var1[ArrayElement]; tipe_data2 nm_var2[ArrayElement]; tipe_dataN nm_varN;[ArrayElement]} var_record[ArrayElement];
  • 21. 21 Example (Cont.) struct mahasiswa { char nama[20][3]; int nilai[3]; } nilaiMhs[3]; nilaiMhs[1].nama[0]; nilaiMhs[1].nilai[0]; Declaration Access
  • 22. Thank You, Next … Modular Programming February 22, 2021 Andi Nurkholis, S.Kom, M.Kom Study Program of Informatics Faculty of Engineering and Computer Science SY. 2020-2021