1/10
Prelim Topic
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
Array
A type of linear data structure that is defined as a collection of elements with same or different data types
Exist in both single and multiple dimensions
Used when there is a necessity to store multiple elements of similar nature together at one place
Element
Each item stored in an array is called an element
Index
Each location of an element in an array has a numerical index, which is used to identify the element
Single-Dimensional Arrays
Indexed from 0 to n-1, where n is the total size of the array
- Ex: An array of size 10 has buckets indexed from 0 to 9
Multidimensional Arrays
It can be thought of as “sub-buckets” within each main bucket.
Indexing Format: array_name[m][n]
m and n represent the sizes or indices at each level of the array
This structured indexing is what enables the efficient O(1) random access property of arrays
Insertion
(Array Operation)
A new element can be added at the beginning, end, or any given index of array. This is done using input statements of the programming languages
Deletion
(Array Operation)
In this operation, we erase an element from the particular index of an array. This operation takes place as we assign the value in the consequent index to the current index.
Search
(Array Operation)
Looking for an element in the array using a key; The key element sequentially compares every value in the array to check if the key is present in the array or not
Traversal
(Array Operation)
This operation traverses through all the elements of an array. We use loop statements to carry this out
Update
(Array Operation)
This operation refers to updating an existing element from the array at given index
Display
(Array Operation)
This operation displays all the elements in the entire array using a print statement