young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
Array operations
1.
2. It Is An Ordered List, Which Consist Of
A Fixed Number Of Homogeneous Data
Items (Elements).An Array Is A Primitive
Data Structure. These Elements Are
Stored In Successive Memory Locations
According To Size Of Data Type. Array Is
Also Referred As Set Of (Index , Value).
3. (index)
A[0] A[1] A[2] A[3] A[4] A[5] A[MAX -1]
10 5 46 2 100 97 ...
Data element value
4. The Insert Operation Is Performed By
Shifting All The Elements One Position
Ahead From Index iTo N-1 Where i Is The
Specified Index For New Element Is To Be
Inserted. And Adding The New Element To
The Array At The Specified Index Position.
5. For example,
index for insertion is i=2 and new element is 17 with N=6. the
MAX is the size of the array A.
A[0] A[1] A[2] … A[N-1] A[MAX-1]
10 5 46 2 100 97 …
Insert index position
Move All Elements From Insert Index Position I N-1 Towards Right By One Position
A[0] 1 2 3 4 5 A[6] A[MAX-1]
10 5 46 2 100 97 …
Insert Index Position
6. A[0] 1 2 3 4 5 A[6] A[MAX-1]
10 5 46 46 2 100 97 …
Insert index position
Shifted elements
7. Now, insert (store) new data element 17 at given index position 2:
A[0] 1 2 3 4 5 A[6] A[MAX-1]
10 5 17 46 2 100 97 …
Inserted element
For Every New Element Inserted The Number Of Elements
I.E N Should Be Incremented By 1. If N= Max-1 Then Array
Is Full And Insertion Operation Cannot Be Performed As
There Is No Space For New Element In The Array.
8. The delete operation will delete the element at
specified element index from one-dimensional array.
The deletion operation performed by shifting all the
elements one position before from index i=1 to N-1
where i is the index of element to be deleted. A[i] =
A[i+1], for all i to N-1 . This shifting causes
overwriting of the said element with element at next
index position.
9. For example,
For an array N=7 and index position for deletion is
i=3 and maximum array size as MAX.
A[0] 1 2 3 4 5 A[6] A[MAX-1]
10 5 17 46 2 100 97 …
Delete Index Position
Now , Shift All Element From Index 4 To 6 One Position Before As Below:
A[0] 1 2 3 4 5 A[6] A[MAX-1]
10 5 17 46 2 100 97 …
Element At Index 3
The Array After The Shifting Backward Is:
10. A[0] 1 2 3 4 A[5] A[MAX-1]
10 5 17 2 100 97 97 …
Last element of array
The element 46 is deleted from the array. After every
delete operation the number of elements N should be
decrement by 1. if array is empty , the deletion operation
cannot be performed .