Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In java 2.pdf Problem 2 (40 points): A Walk on the Hypercube: The unit hypercube in the n-dimensional space is the set of all points

In java image text in transcribed
2.pdf Problem 2 (40 points): A Walk on the Hypercube: The unit hypercube in the n-dimensional space is the set of all points (X1, Xy, -, *) in that space such that its coordinates are restricted to be 0 SX S1 for 1 = 1..n. This hypercube has 2"corners. Each coordinate of a corner is either 0 or 1. Each edge of the hypercube connects a pair of comers that differ in exactly one of their coordinates. A walk on the hypercube starts at some corner and walks along a sequence of edges of the hypercube so that it visits each corner exactly once. There are many such walks possible. The following figure shows an example for n. 3. The edges of the (hypercube along the walk are thickened. A Walk: 000 100 110 010 011 010 111 101 001 The problem for any given n, output the sequence of corners visited along a walk of the dimensional hypercube. We want to study recursive and iterative solutions to this problem. In order to do that, design a Hypercube class that (among possibly other members) includes the following: a) A nested class named Corner. An instance of this type represents a corner of the hypercube and occupies O(n) memory cells. b) A recursive method named recursive Walk() to solve the above problem. The parameters and local variables of this method can only be primitives or Corner types c) An iterative method named iterative Walk() to solve the above problem using a single queue. The elements of this queue, as well as the other local variables and method parameters, can only be primitives or Corner types (Note: We know that any recursive algorithm can be converted to an equivalent iterative one by simulating a recursion stack. However, here you are forbidden to use a stack or any structure that may act as one such as an array or a list Java has a Queue interface, not a class. But it has an ArrayDeque class that can do the job of a queue as well as other lists. You may either design your own Queue class or use the queue methods in ArrayDeque. You are not allowed to use the stack or other methods in ArrayDeque. In other words, use ArrayDeque only as a queue, ie, a First-in-First Out list) d) Explain the running times of your solutions in parts (b) and (c) in a2 sol.pdf e) The main() method of Hypercube class should test recursive Walk and iterativeWalk for at least the dimensions 1 3,4,5. Report the I/O results in a 2sol.pdf

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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