Array and Array List Data Structures
Array and Array List
In data structures the simplest data structure is the Array. To
store the data the simplest way is that.
We should know two main
things to create a list,
-
In the Array we can only use the same typed
data(same of data type among all elements).
-
Array should be fixed sized.
That means we should know the size of the array before creating the
array, how many data elements we want to store in that.
We should give the exact size of the array.
Why we want Array List
Array should fixed sized, but array list is not
like that it is not fixed one. It’s resizable. Array List change there size
according to our input data, In other way we can tell that as Dynamic Array or
the Dynamic Array List.
arrays and array lists are both important data
structures for storing collections of elements. Arrays are fixed-size and
provide efficient random access, while array lists are dynamic and offer more
flexibility. Understanding the differences between the two can help you choose
the most appropriate data structure for your specific needs. Whether you
prioritize memory efficiency, flexibility, or performance, selecting the right
data structure is crucial for writing efficient and maintainable code.
Array declare and initialize process are there ,
Here 'aryname' is the array name of the array and it is declared as six sized one and up to six elements we can store the data. after that for each index process of assigning the values go on.
After that using print command print the value of the index2.
Array list declare and initialize process are there,
ArrayList Operations
1. Searching: This operation involves finding a specific element within a data structure.
2. Sorting: Sorting rearranges the elements of a data structure, either in ascending or descending order.
3. Insertion: Insertion allows adding new elements into a data structure, expanding its size.
4. Updation: Updation involves modifying existing elements within the data structure, replacing them with new values.
5. Deletion: Deletion removes elements from the data structure, reducing
its size.
Differences between array and the array list,
Comments
Post a Comment