3 Setup an integer array variable of size 20 called nums in a program and initia
ID: 3640421 • Letter: 3
Question
3 Setup an integer array variable of size 20 called nums in a program and initialise it to contain the values:
2 4 6 8 10 12 14 16 18 20
a) Suppose we wish to insert a number into the ordered sequence, eg. If we were to add 9 it should be placed between the 8 and 10. To accomplish this we can find the first number larger than the one we wish to insert (use a separate variable to remember this position) and shuffle it and all remaining numbers along one place. Use a for type loop to do this. Then insert the new number into the position noted above.
A similar situation exists with respect to deletion. In this case we locate and remember the position of the value to be deleted and then shuffle all the items beyond this item back one place. This will have the effect of over-writing the element to be deleted.
TY. Please explain code and make it simple ty.
Explanation / Answer
PS: Please rate Check your inbox
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.