Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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).

image text in transcribed

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, { } Procedures A procedure, name, takes zero or more parameters. The procedure contains programming .) instructions. Block: PROCEDURE name parameteri, parameter2,... instructions Text: PROCEDURE name (parameterl, parameter2, ...) A procedure, name, takes zero or more parameters. The procedure contains programming instructions and returns the value of expression. The RETURN statement may appear at any point inside the procedure and causes an immediate return from the procedure back to the calling program RETURN (expression) } Block: PROCEDURE name parameteri, parameter2,.. instructions RETURN expression

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

1 2 3 Data Base Techniques

Authors: Dick Andersen

1st Edition

0880223464, 978-0880223461

More Books

Students also viewed these Databases questions