Midterm Lecture ---> Arrays Flashcards
- a container which can hold a fix number of
items and these items should be of the same type. - A linear data structure where elements are
allocated contiguous memory, allowing for constant-
time access.
-can only include input variables of the same data type.
Arrays
Each item stored in an array
Element
Each location of an element in an array
has an _____ , which is used to identify the
element.
Index
Prints all the array elements one by one.
Traverse
Adds an element at the given index.
Insertion
Deletes an element at the given index.
Deletion
Searches an element using the given index or by
the value.
Search
Updates an element at the given index.
Update
Types of arrays:
Fixed Size Array
Dynamic Sized Array
1 - Dimensional Array
Multi - Dimensional Array
cannot alter or update the size of this
array. Here only a fixed size (i,e. the size that is mentioned
in square brackets []) of memory will be allocated for
storage.
Fixed Size Array
The size of the array changes as per
user requirements during execution of code so the coders
do not have to worry about sizes. They can add and
removed the elements as per the need. The memory is
mostly dynamically allocated and de-allocated in these
arrays.
Dynamic Sized Array
You can imagine a 1d array
as a row, where elements are stored one after another.
One - Dimensional Array
can be considered as an array
of arrays or as a matrix consisting of rows and columns.
Multi - Dimensional Array
- are a way to group
several related variables into one place. - can contain many different
data types (int, float, char, etc.) - can include input variables of multiple data
types.
Structures
a collection of items that are all of
the same type (grocery items, integers,
names)
List