Computer Science, asked by anthonyjyothi41, 2 months ago

write an algorithm to insert an element in an array​

Answers

Answered by Anonymous
2

Explanation:

This algorithm inserts an element ITEM into the Kth position in LA.

[Initialize Counter] Set J: = N.

Repeat steps 3 and 4 while J ≥ K.

[Move Jth element downward] Set LA [J+1]: = LA [J]

[Decrease Counter] Set J: = J-1. [End of step 2 loop]

[Insert element] Set LA [K]: = ITEM.

[Reset N] Set N: = N+1.

Exit.

Answered by adsulsnehal07
1

Answer:

This algorithm inserts an element ITEM into the Kth position in LA.

[Initialize Counter] Set J: = N.

Repeat steps 3 and 4 while J ≥ K.

[Move Jth element downward] Set LA [J+1]: = LA [J]

[Decrease Counter] Set J: = J-1. [End of step 2 loop]

[Insert element] Set LA [K]: = ITEM.

[Reset N] Set N: = N+1.

Exit.

Similar questions