Arrays
• What isan Array? - A collection of elements of
the same data type stored in contiguous
memory locations.
• Why use Arrays? - To store multiple values in a
single variable, which makes code efficient
and manageable.
• When to use Arrays? - When you need to
store a fixed number of elements.
• Where is it stored? - In the memory (RAM),
starting from a base address.
One Dimensional Arrays
•What is a 1D Array? - An array with a single
row of elements.
• Why use 1D Array? - To represent a list or
sequence of elements.
• When to use 1D Array? - When data is linear
like marks of students, or daily temperatures.
• Where is it stored? - In a continuous block in
memory.
• How is it stored? - Elements are indexed
starting from 0.
Two Dimensional Arrays
•What is a 2D Array? - An array of arrays, with
rows and columns.
• Why use 2D Array? - To represent matrices,
tables, or grids.
• When to use 2D Array? - When data is in row-
column format, like a chessboard.
• Where is it stored? - As a contiguous memory
block logically structured in rows and columns.
• How is it stored? - Stored in row-major or
column-major order based on language.
Array Manipulation
• Whatis Array Manipulation? - Modifying
elements: insert, delete, update, traverse.
• Why manipulate Arrays? - To manage and
utilize stored data effectively.
• When to manipulate Arrays? - When you need
to change existing data.
• Where is it stored? - Operations affect the
existing array memory space.
• How is it stored? - Changes are done in-place
or using new arrays.
8.
Array Manipulation -Example Code
• int[] arr = {1, 2, 3};
• arr[1] = 10; // Update second element