Please enable JavaScript.
Coggle requires JavaScript to display documents.
Kump 5 Joh, Syukri C1 - Coggle Diagram
Kump 5 Joh, Syukri C1
-
-
-
-
Array for Data Structure
Array is a container that can hold a fix number of items and these items is similar data type because all data structures make use of arrays to implement their algorithms
- Important terms to understand the concept of Array
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 element
Array presentation
Arrays can be declared in various ways in different languages. For illustration, let's take C array declaration.
As per the below illustration, following are the important points to be considered
-
Basic Operations
- Traverse - print all the array elements one by one
- Insertion - adds on element at the given index
- Deletion - deletes an element at the given index
- Search - searches an element using the given index of by the value
- Update - updates an element of at the given index
Advantages of Arrays
- We must know in advance that how many elements are to be stored in array.
- The elements of array are stored in consecutive memory locations. So insertions and deletions are very difficult and time consuming
- Array is static structure. It means that array is of fixed size. The memory which is allocated to array can not be increased or reduced
- Since array is of fixed size, if we allocate more memory than requirement then the memory space will be wasted. And if we allocate less memory than requirement, then it will create problem.