Write pseudo code to do the following. Your pseudo code or algorithm must follow
ID: 3901943 • Letter: W
Question
Write pseudo code to do the following. Your pseudo code or algorithm must follow all the rules of an algorithm. It must be written in steps. No paragraphs. All conditions and iterations must be clearly specified. You must use loops and functions to do this. The steps in the pseudo code must be very clear without ambiguity. 1. To remove numbers from an array given the array and the position of the number to remove. You should not replace the element with 0. If your original array was {34, 12, 56, 18, 20, 16, 8, 9, 10, 11}, after removing the element from position 0, your array should print {12, 56, 18, 20, 16, 8, 9, 10 11}. 2. To insert numbers from an array given the array, the number to insert, and the position where the number should be inserted. If your original array was {34, 12, 56, 18, 9, 10, 11}, after inserting the number 15 at position 1, your array should print {15, 34, 12, 56, 18, 9, 10 11}. You should make sure that size does not exceed capacity when inserting.
Explanation / Answer
1 .Pseudo code
step 1 : set Size=20 , i=0
step 2 : read size of the array, array_size form user.
step 3 : for i less than array_size
read each element arr[i].
increment i by 1
step 4 : Read location of the number loc to be deleted from user
step 5 : if loc is greater than array_size
print " deletion is not possible"
else
set c = loc-1
for c is less than (array_size-1)
move arr[c+1] to arr[c]
increment i by 1
step 6 : Print " Array after deletion is : "
step 7 : set i=0
step 8 : for i is less than (array_size-1 )
print arr[i]
increment i by 1
step 9 :stop.
2. insert element to the array
step 1 : set Size=20 , i=0 and j=0
step 2 : read size of the array, array_size form user.
step 3 : for i less than array_size
read each element arr[i].
increment i by 1
step 4 : Read location of the number loc where the user wish to insert the number.
Step 5 : Read the number to be inserted to num
step 5 : if array_size is greater than Size
print " insertion is not possible"
else
set c = ( array_size)-1
for c is greater than or equals to (loc-1)
move arr[c] to arr[c+1]
decrement i by 1
step 6 : Print " Array after deletion is : "
step 7 : set i=0
step 8 : for i is less than or equals to array_size
print arr[i]
increment i by 1
step 9 :stop.
*********************END******************PLS GIVE ME GOOD RATING*****************
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.