Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 1: Complete the following function template: function MAKEVECTOR(row) new Vector puzzle(4) end function This function should take a four-element vector called row as an

image text in transcribed

Task 1: Complete the following function template: function MAKEVECTOR(row) new Vector puzzle(4) end function This function should take a four-element vector called row as an input parameter and return a vector of four elements called puzzle: each element of puzzle should contain the four-element vector row. Complete this function. Cyclic permutation of row vectors Consider the following vector: This does not satisfy the Pseudoku conditions since in each column only one number appears. The algorithm for generating Pseudoku puzzles will cyclically permute the elements in each row vector until the numbers in all the rows satisfy the Pseudoku conditions. A cyclic permutation of each row will shift all values of the elements one place to the left (or the right) with the value at the end going to the other end. For example, for the second element in the vector above, if we cyclically permute all elements one place to the left we will have: Given a four-element vector and an integer p between 0 and 3 (inclusive) we want to write a function to cyclically permute the values in the vector by p elements to the left. An elegant way to do this is to use the queue abstract data structure. All values in a vector will be enqueued to an empty queue from left to right, e.g. the vector above will give the following queue: To cyclically permute all values one place to the left we enqueue the value stored at the head, and then dequeue the queue. This process will then give the following queve: To cyclically permute the values we can just repeat multiple times this process of enqueueing the value at the head and then dequeueing. When we are finished with this process we then just copy (and overwrite) the values stored in the queue to our original vector and return this vector

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

Students also viewed these Databases questions

Question

Find the derivative. f(x) 8 3 4 mix X O 4 x32 4 x32 3 -4x - x2

Answered: 1 week ago