Array_Presentation
Array_Presentation
Items
• Array stores items of the same type in
contiguous memory locations.
• It is a popular and simple data structure used
in programming.
Table of Contents
• Basic Terminologies of Array
• Memory Representation of Array
• Declaration of Array
• Initialization of Array
• Importance of Array
• Applications of Array Data Structures
• Types of Arrays
• Operations on Array
• Complexity Analysis of Array Operations
Basic Terminologies of Array
• Array Index: Elements are identified by their
indexes, starting from 0.
• Array Element: Items stored in an array,
accessible by their index.
• Array Length: Number of elements an array
can contain.
Memory Representation of Array
• Elements are stored in contiguous memory
locations.
• Allows efficient access and manipulation of
elements.
Declaration of Array
• Language-specific examples:
• - int arr[]; // Stores integer elements
• - char arr[]; // Stores char elements
• - float arr[]; // Stores float elements
Initialization of Array
• Language-specific examples:
• - int arr[] = {1, 2, 3, 4, 5};
• - char arr[] = {'a', 'b', 'c', 'd', 'e'};
• - float arr[] = {1.4f, 2.0f, 24f, 5.0f, 0.0f};
Importance of Array
• Efficiently manages data for a large number of
instances.
• Replaces individual variables with a single
array variable.
Applications of Array Data
Structures
• Implementing data structures like stacks and
queues.
• Representing data in tables and matrices.
• Building dynamic structures like hash tables
and graphs.
• Advantages: Random access and cache
friendliness.
Types of Arrays
• Classification based on size and dimensions.
• Fixed Size Arrays: Predefined size; static
memory allocation.
• Dynamic Size Arrays: Resize dynamically;
dynamic memory allocation.
Types of Arrays Based on
Dimensions
• 1-D Arrays: Elements stored in a single row.
• 2-D Arrays: Arrays of arrays or matrices.
• 3-D Arrays: Arrays of 2-D arrays.
Operations on Array
• Traversal: Visit all elements.
• Insertion: Add elements at any position.
• Deletion: Remove elements at any position.
• Searching: Find specific elements.
Complexity Analysis of Array
Operations
• Traversal: Best/Average/Worst Case -
Ω(N)/θ(N)/O(N)
• Insertion: Best/Average/Worst Case -
Ω(1)/θ(N)/O(N)
• Deletion: Best/Average/Worst Case -
Ω(1)/θ(N)/O(N)
• Searching: Best/Average/Worst Case -
Ω(1)/θ(N)/O(N)
• Space Complexity: Traversal/Insertion -
Ω(1)/O(1)