filmov
tv
Array Operations -Traversal, Insertion | full explanation with Code | GATECSE | Data Structure

Показать описание
Contact Datils (You can follow me at)
Watch Complete Playlists:
An array is a collection of homogeneous (same type) data items stored in contiguous memory locations. For example if an array is of type “int”, it can only store integer elements and cannot allow the elements of other types such as double, float, char etc.
Advantages and disadvantages of Arrays
Advantages
1. Reading an array element is simple and efficient. As shown in the above table, the read time of array is O(1) in both best and worst cases. This is because any element can be instantly read using indexes (base address calculation behind the scene) without traversing the whole array.
2. Array is a foundation of other data structures. For example other data structures such as LinkedList, Stack, Queue etc. are implemented using array.
3. All the elements of an array can be accessed using a single name (array name) along with the index, which is readable, user-friendly and efficient rather than storing those elements in different-2 variables.
Disadvantages
1. While using array, we must need to make the decision of the size of the array in the beginning, so if we are not aware how many elements we are going to store in array, it would make the task difficult.
2. The size of the array is fixed so if at later point, if we need to store more elements in it then it can’t be done. On the other hand, if we store less number of elements than the declared size, the remaining allocated memory is wasted.
Understand Syntax of Arrays
Array name: necessary for easy reference to the collection of elements
Data Type: necessary for type checking and data integrity
Elements: these are the data values present in an array
Why do we need arrays?
Here, are some reasons for using arrays:
Arrays are best for storing multiple values in a single variable
Arrays are better at processing many values easily and quickly
Sorting and searching the values is easier in arrays
Types of Arrays
The various types of arrays are as follows.
One dimensional array
Multi-dimensional array
array operations like insert and delete
Introduction to Arrays
What is array in data structure with example?
What is array and types of array in data structure?
Types of Arrays and their Representation
Accessing Array elements
Ways to Declare an Array in C
You can declare an array in three syntax variants. Which one suits your program; this choice is based on your program requirements.
Declaration Initialization Array Items Only Syntax
dataType arrayName[ ] = {array, items};
dataType arrayName[arraySize] = {array, items};
How to access a specific array value?
You can access any array item by using its index.
arrayName[indexNum]
Array Operations in C
Unlike Python, in C you have to program the logic yourself for performing the insert, delete, search update and traverse operations on C arrays.
Insert
The logic for insertion operation goes as follows:
loop through the array items
shift them to a greater index
add a new array item at a given index
Summary:
An array is a data structure for storing multiple data items that have a similar data type
Identifier, data type, array length, elements, and index are the major parts of an array
Use the index for processing the values of array elements
Arrays have excellent support for keeping data-type intact
In most languages, an array is created by specifying an identifier, data type, and elements to include
Arrays are best for processing a large number of values, and for quick sorting and searching
Python has modules and built-in methods to perform basic array operations like insert, delete, search, update and traverse
C needs defining programs for basic array operations like traversing, insert, delete, search update and traverse
Declaration of Arrays
Initialization of Arrays
how to insert an element into array
What are Arrays?
Concept of Array
Why do we need arrays?
Creating an Array in Python
Ways to Declare an Array in Python
Array Operations
Creating an Array in C++
Array Operations in C++
Array Operations in Java
Watch Complete Playlists:
An array is a collection of homogeneous (same type) data items stored in contiguous memory locations. For example if an array is of type “int”, it can only store integer elements and cannot allow the elements of other types such as double, float, char etc.
Advantages and disadvantages of Arrays
Advantages
1. Reading an array element is simple and efficient. As shown in the above table, the read time of array is O(1) in both best and worst cases. This is because any element can be instantly read using indexes (base address calculation behind the scene) without traversing the whole array.
2. Array is a foundation of other data structures. For example other data structures such as LinkedList, Stack, Queue etc. are implemented using array.
3. All the elements of an array can be accessed using a single name (array name) along with the index, which is readable, user-friendly and efficient rather than storing those elements in different-2 variables.
Disadvantages
1. While using array, we must need to make the decision of the size of the array in the beginning, so if we are not aware how many elements we are going to store in array, it would make the task difficult.
2. The size of the array is fixed so if at later point, if we need to store more elements in it then it can’t be done. On the other hand, if we store less number of elements than the declared size, the remaining allocated memory is wasted.
Understand Syntax of Arrays
Array name: necessary for easy reference to the collection of elements
Data Type: necessary for type checking and data integrity
Elements: these are the data values present in an array
Why do we need arrays?
Here, are some reasons for using arrays:
Arrays are best for storing multiple values in a single variable
Arrays are better at processing many values easily and quickly
Sorting and searching the values is easier in arrays
Types of Arrays
The various types of arrays are as follows.
One dimensional array
Multi-dimensional array
array operations like insert and delete
Introduction to Arrays
What is array in data structure with example?
What is array and types of array in data structure?
Types of Arrays and their Representation
Accessing Array elements
Ways to Declare an Array in C
You can declare an array in three syntax variants. Which one suits your program; this choice is based on your program requirements.
Declaration Initialization Array Items Only Syntax
dataType arrayName[ ] = {array, items};
dataType arrayName[arraySize] = {array, items};
How to access a specific array value?
You can access any array item by using its index.
arrayName[indexNum]
Array Operations in C
Unlike Python, in C you have to program the logic yourself for performing the insert, delete, search update and traverse operations on C arrays.
Insert
The logic for insertion operation goes as follows:
loop through the array items
shift them to a greater index
add a new array item at a given index
Summary:
An array is a data structure for storing multiple data items that have a similar data type
Identifier, data type, array length, elements, and index are the major parts of an array
Use the index for processing the values of array elements
Arrays have excellent support for keeping data-type intact
In most languages, an array is created by specifying an identifier, data type, and elements to include
Arrays are best for processing a large number of values, and for quick sorting and searching
Python has modules and built-in methods to perform basic array operations like insert, delete, search, update and traverse
C needs defining programs for basic array operations like traversing, insert, delete, search update and traverse
Declaration of Arrays
Initialization of Arrays
how to insert an element into array
What are Arrays?
Concept of Array
Why do we need arrays?
Creating an Array in Python
Ways to Declare an Array in Python
Array Operations
Creating an Array in C++
Array Operations in C++
Array Operations in Java
Комментарии