Question
Write a procedure/method (the syntax for writing a procedure is on page 5 of the Reference Sheet) that creates an array of numbers {1, 2,
Write a procedure/method (the syntax for writing a procedure is on page 5 of the Reference Sheet) that creates an array of numbers {1, 2, 3, 4, 5} with 1 being in the first position and 5 being in the fifth position of the list. Call this procedure "CreateArray". (Note that on the Reference Sheet, arrays are referred to as lists)
Write another procedure/method that reverses the array of numbers so that the values are now {5, 4, 3, 2, 1} in positions 1, 2, 3, 4, 5 respectively. Call this procedure "ReverseArray". (using ReverseArray twice should return the array to the previous order of {1, 2, 3, 4, 5})
Now create your Main procedure/method (another name for MyFirstMethod), and store your name inside a variable called "name". Then use CreateArray and ReverseArray to finish with an array of {5, 4, 3, 2, 1}.
(NOTE: I've attached the reference sheet below).
Instruction Explanation List Operations (continued) Any values in list at indices greater than or equal to i are shifted to the right. The length of list is increased by 1, and value is placed at index i in list. Text: INSERT (list, i, value) Block: INSERT list, i, value Text: APPEND (list, value) Block: APPEND list, value The length of list is increased by 1, and value is placed at the end of list. Text: REMOVE (list, i) Removes the item at index i in list and shifts to the left any values at indices greater than i. The length of list is decreased by 1. Block: REMOVE list, i Evaluates to the number of elements in list. Text: LENGTH (list) Block: LENGTH list Text: PROCEDURE name (parameterl, parameter2, {Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started