COMS W1004 Lecture Notes - Lecture 5: Pseudocode, Decimal Mark
Document Summary
[solutions] coms w1004 fall 2019 homework 5 - written. Problem 1 (big java r7. 20) give pseudocode for an algorithm that rotates the elements of an array by one position, moving the initial element to the end of the array, as shown at right. Store the array input in an array called in". Let l" be the length of the array in". Create an array called out" of size l", which we use to store the rotated array. For i = 1, 2, , l-1: out[i] = in[i + 1] end for 5. out[l] = in[1] 6. [answer] the intended behavior is that the array passed into the function as a parameter will be updated so that it contains random numbers. Below is a code snippet (assuming we have a method printarray() that prints any int array) and we"ll see what happens. int[] originalvalues = {1, 2, 3, 4, 5}; printarray(originalvalues); // prints 1,