Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question is in bold below, rest are instructions. This needs to be written in pseudocode, but looking for any help to understand this requirement ________

Question is in bold below, rest are instructions.

This needs to be written in pseudocode, but looking for any help to understand this requirement

________

You will check the Pseudoku conditions using a stack. In particular, you will start with a stack containing all numbers from 1 to 4, and then inspect each element in each column (or sub-grid) to see if the number in that element is stored in the stack: if it is stored in the stack, pop that value from the stack and return the stack; otherwise, return false. This process will be repeated for every element in a column or sub-grid. If, at the end of checking every element, the stack is empty then all numbers appear in the the column or sub-grid; if the stack is not empty, then not all numbers from 1 to 4 appear. We will complete a function called SearchStack(stack, item) that will search a stack for the value item: if item is in one of the elements of the stack, we remove that element storing item. Otherwise, the function should return FALSE Lets demonstrate this with diagram. We have the following stack: We want to look for the value 3 in the stack and remove it if it is there, otherwise if it is not there, return FALSE. The value 3 is stored in the stack so we then need to remove it so the stack could look like this: The next task will be to complete a function that does this process of searching a stack and possibly removing an element.

Complete the following function: function SearchStack(stack, item) ... end function

This function will take a stack and a value (called item) as input parameters, and return FALSE if item is not stored in the stack, otherwise return the stack without the element storing item.

To check whether a column contains all numbers from 1 to 4 in a puzzle vector, we will do the following: 1. Create a stack called numbers, which contains all numbers from 1 to 4 2. Initialise a variable k to be 1 3. For the element k in a column, store the number in that element to a variable called value and call Search- Stack(numbers, value) 4. If the function returns FALSE, then we should return FALSE as a number appears twice or not at all in the stack 5. If the function returns the stack, increase the value of k by one and go to step 3 6. If after checking all elements in the column, SearchStack has not returned FALSE, we return TRUE

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

Database Processing

Authors: David M. Kroenke, David Auer

11th Edition

B003Y7CIBU, 978-0132302678

More Books

Students also viewed these Databases questions