Insert The Element Into The Array At A Given Position





Problem 2.5:
Given a list of integers stored in a linear array and a data element, insert the element into the array at a given position.
Algorithm 2.5:
Algorithm to insert an element into an array.
1. Input: An array A[1...n], the position of insertion m and the data x.
2. Increase the size of the array, A[1...n + 1]
3. for (i = m; i≤ n; i = i + 1)
A[i + 1] = A[i];
4. A[m] = x;
5. Output: The array, A with size n + 1.

Problem as assignment

Given, two linear arrays of integers, merge the two arrays into a single array.


This is the end
of
one dimensional array



Preview <<





No comments:

Post a Comment

There was an error in this gadget

Followers

About Me

Dhaka, Dhaka, Bangladesh
..