According to the heading itself, it says that we are having an array and we have to insert at the end of array
Now to write an algorithm we may have input,output and logic to perform the task
Input: An array named as "Array" and "Pos" describing the position till where the elements are filled, maximum size "size" and "value" the element to be inserted.
Output: Resultant Array with element inserted.
Now to write an algorithm we may have input,output and logic to perform the task
Input: An array named as "Array" and "Pos" describing the position till where the elements are filled, maximum size "size" and "value" the element to be inserted.
Output: Resultant Array with element inserted.
The figure describes an array named as Array it contains 2
data elements already stored as 1 and 2. The G
here is used to represent the garbage values in an array. Below we are
having the index of array element. From
the figure we can get the size as 5 and pos as 2.
Now to insert at end we will follow following steps.
- Check the overflow condition that is pos+1==size i.e. 4+1 =5 and we can’t store the next element.
- Set the value at the particular position and terminate.
- Terminate the algorithm
No comments:
Post a Comment