Department of Informatics Faculty of Industrial Engineering Universitas Pembangunan Nasional “Veteran” Yogyakarta Data Structure Andi Nurkholis, S.Kom., M.Kom. Array: Concept & Implementation September 1, 2025
Concept of Array Array is a data structure that stores a collection of elements of the same data type in consecutive memory locations. Each element can be accessed directly using an index or subscript, which typically starts at 0 (zero-based indexing) in many programming languages, although some use a starting index of 1 (one-based indexing). By arranging elements contiguously in memory, arrays allow for fast (direct) access to data and make it easier to manage multiple values in a single container without having to create separate variables for each item.
Characteristics of Array 1. Fixed Size 2. Sequential Storage in Memory 3. Fast Access 4. Homogeneous Data Types
Notation of Array The general notation for declaring an array looks like this: DataTypeArrayName[Size] ü DataType: The type of data to be stored in the array (e.g., int, float, char, etc.) ü ArrayName: The name given to the array. ü Size: The number of elements that can be stored in the array. Example of an array declaration in C: int arr[5]; // Declares an integer array with 5 elements
Types of Array 1. One-Dimensional Array 2. Two-Dimensional Array 3. Multi-Dimensional Array
One-Dimensional Array One-dimensional array is the simplest array, storing elements in a single row. An example of using a one-dimensional array is storing a list of student names and grades.
Two-Dimensional Array Two-dimensional array is often referred to as a matrix. It is an array with rows and columns and is used to store data in tabular form.
Multi-Dimensional Array Multidimensional array is an array with more than two dimensions, which can be used for more complex data representation, such as image processing (e.g., RGB).
Basic Operations of Array Various basic operations can be performed on arrays, namely: ü Initialization: The process of assigning initial values to the elements in an array. Example: int arr[5] = {1, 2, 3, 4, 5}; // Initialize the array with five elements ü Element Access: Performed using an index. For example, to get the second element of the array arr, we use arr[1]. ü Changing Element Values: Can be changed by assigning a new value to the corresponding index. Example: arr[2] = 10; // Change the value of the third element to 10
Basic Operations of Array ü Traversing: Visiting each element of an array to perform a specific operation, such as displaying a value. for (int i = 0; i < 5; i++) { printf("%d ", arr[i]); // Display all elements in the array } ü Searching for an Element: This can be done by performing a linear search. For example, to find a specific element in an array, we would examine each element one by one.
Advantages of Array ü Fast Access: O(1) for accessing elements by index. ü Simple: Structures that are easy to understand and use. ü Efficient: Efficient memory usage for static data.
Disadvantages of Array ü Static Size: The size of an array cannot be changed after it is declared. ü Memory Consumption: If the array size is too large and not all elements are used, space will be wasted. ü Insertion and Deletion Operations: Adding or removing elements in the middle of an array requires shifting elements, which can make the operation slow (O(n)).
Department of Informatics Faculty of Industrial Engineering Universitas Pembangunan Nasional “Veteran” Yogyakarta Andi Nurkholis, S.Kom., M.Kom. September 1, 2025 Done Thank You

Data Structure - 3 Array: Concept & Implementation

  • 1.
    Department of Informatics Facultyof Industrial Engineering Universitas Pembangunan Nasional “Veteran” Yogyakarta Data Structure Andi Nurkholis, S.Kom., M.Kom. Array: Concept & Implementation September 1, 2025
  • 2.
    Concept of Array Arrayis a data structure that stores a collection of elements of the same data type in consecutive memory locations. Each element can be accessed directly using an index or subscript, which typically starts at 0 (zero-based indexing) in many programming languages, although some use a starting index of 1 (one-based indexing). By arranging elements contiguously in memory, arrays allow for fast (direct) access to data and make it easier to manage multiple values in a single container without having to create separate variables for each item.
  • 3.
    Characteristics of Array 1. FixedSize 2. Sequential Storage in Memory 3. Fast Access 4. Homogeneous Data Types
  • 4.
    Notation of Array Thegeneral notation for declaring an array looks like this: DataTypeArrayName[Size] ü DataType: The type of data to be stored in the array (e.g., int, float, char, etc.) ü ArrayName: The name given to the array. ü Size: The number of elements that can be stored in the array. Example of an array declaration in C: int arr[5]; // Declares an integer array with 5 elements
  • 5.
    Types of Array 1. One-DimensionalArray 2. Two-Dimensional Array 3. Multi-Dimensional Array
  • 6.
    One-Dimensional Array One-dimensional arrayis the simplest array, storing elements in a single row. An example of using a one-dimensional array is storing a list of student names and grades.
  • 7.
    Two-Dimensional Array Two-dimensional arrayis often referred to as a matrix. It is an array with rows and columns and is used to store data in tabular form.
  • 8.
    Multi-Dimensional Array Multidimensional arrayis an array with more than two dimensions, which can be used for more complex data representation, such as image processing (e.g., RGB).
  • 9.
    Basic Operations ofArray Various basic operations can be performed on arrays, namely: ü Initialization: The process of assigning initial values to the elements in an array. Example: int arr[5] = {1, 2, 3, 4, 5}; // Initialize the array with five elements ü Element Access: Performed using an index. For example, to get the second element of the array arr, we use arr[1]. ü Changing Element Values: Can be changed by assigning a new value to the corresponding index. Example: arr[2] = 10; // Change the value of the third element to 10
  • 10.
    Basic Operations ofArray ü Traversing: Visiting each element of an array to perform a specific operation, such as displaying a value. for (int i = 0; i < 5; i++) { printf("%d ", arr[i]); // Display all elements in the array } ü Searching for an Element: This can be done by performing a linear search. For example, to find a specific element in an array, we would examine each element one by one.
  • 11.
    Advantages of Array üFast Access: O(1) for accessing elements by index. ü Simple: Structures that are easy to understand and use. ü Efficient: Efficient memory usage for static data.
  • 12.
    Disadvantages of Array üStatic Size: The size of an array cannot be changed after it is declared. ü Memory Consumption: If the array size is too large and not all elements are used, space will be wasted. ü Insertion and Deletion Operations: Adding or removing elements in the middle of an array requires shifting elements, which can make the operation slow (O(n)).
  • 13.
    Department of Informatics Facultyof Industrial Engineering Universitas Pembangunan Nasional “Veteran” Yogyakarta Andi Nurkholis, S.Kom., M.Kom. September 1, 2025 Done Thank You