CSCI340 Assignment Rotating Corner Spiral

$50.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (6 votes)

Rotating Corner Spiral Consider a set of values arranged in an NxN square for some N>0. Our task is to visit each value in the square exactly once using a prescribed path. The path begins by first visiting the values in the outermost embedded square (i.e., top and bottom rows, first and last columns), then proceeding inward to the next embedded square, and so on until we reach the center. For each embedded square, start with the upper left corner and proceed clockwise around the square visiting the four corners in sequence. 1 2 4 3 Once you reach the fourth corner, “rotate” your path one cell clockwise and visit the four cells in sequence. 1 5 2 6 8 4 7 3 Repeat “rotating” then visiting four cells until you have visited all the cells in the embedded square. 1 5 9 2 6 12 10 8 4 11 7 3 Continue the sequence by proceeding inward to the upper left corner in the next embedded square and visit its cells in the same manner. Repeat until all the embedded squares have been traversed. What is the sequence of values that an NxN square using the rotating corner method described above? Write a function vector RotatingCornerSpiral(vector<vector> &m) where m is the NxN square of values and returns the sequence if m describes a square, otherwise returns the empty sequence. File you must submit: soln_func.cc 1 5 9 13 2 16 6 12 10 8 14 4 15 11 7 3 1 5 9 13 2 16 17 18 6 12 10 8 20 19 14 4 15 11 7 3 1 5 9 13 2 16 17 21 18 6 12 24 22 10 8 20 23 19 14 4 15 11 7 3 1 5 9 13 2 16 17 21 18 6 12 24 25 22 10 8 20 23 19 14 4 15 11 7 3 Examples: Returns: 8, 6, -6, 15, -4, 1, 2, 9, 11 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 Returns: 1, 4, 16, 13, 2, 8, 15, 9, 3, 12, 14, 5, 6, 7, 11, 10 Returns: empty sequence Explanation: m is not a square. 8 -4 6 9 11 1 15 2 -6 1 2 3 4 5 6 7 8 9 10 11 12