Two short programs to solve problems using recursion Assignment 2

$24.99 $18.99

In this assignment, you will write two short programs to solve problems using recursion. Initial Setup Log in to Unix. Run the setup script for Assignment 2 by typing: setup 2 The setup script will create the directory Assign2 under your csci241 directory. It will copy a make�le named makefile to the assignment directory and…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

In this assignment, you will write two short programs to solve problems using recursion.

  1. Initial Setup

    1. Log in to Unix.

    1. Run the setup script for Assignment 2 by typing: setup 2

The setup script will create the directory Assign2 under your csci241 directory. It will copy a makele named makefile to the assignment directory and will also create symbolic links to a pair of test programs that you can use to verify that your output is correct.

Using the makefile we give you, you can build one specic program or build both programs. To build a single specic program, run the command make followed by the target name for the program that you want to build (hanoi or queens). For example:

z123456@turing:~$ make hanoi

To build both programs, run the command make all or just make.

Running the command make clean will remove all of the object and executableles created by the make command.

2. Towers of Hanoi

Legend has it that in a temple in the Far East, priests are attempting to move a stack of disks from one peg to another. The initial stack had 64 disks threaded onto one peg and arranged from bottom to top by decreasing size. The priests are attempting to move the stack from this peg to a second peg under the constraints that exactly one disk is moved at a time, and at no time may a larger disk be placed above a smaller disk. A third peg is available for temporarily holding the disks. According to the legend, the world will end when the priests complete their task.

Consider three pegs numbered 1 through 3. Let us assume that the priests are attempting to

move the 64 disks from peg 1 to peg 2, using peg 3 as a temporary holding peg. The problem

is to design an algorithm that that will print the precise sequence of disk peg-to-peg transfers.

If you were to approach this problem with conventional methods, you would rapidlynd

Assignment 2 http://faculty.cs.niu.edu/~mcmahon/CS241/Assign/Spring2022/assignme…

Assignment 2 http://faculty.cs.niu.edu/~mcmahon/CS241/Assign/Spring2022/assignme…

Assignment 2 http://faculty.cs.niu.edu/~mcmahon/CS241/Assign/Spring2022/assignme…

Assignment 2 http://faculty.cs.niu.edu/~mcmahon/CS241/Assign/Spring2022/assignme…

Assignment 2 http://faculty.cs.niu.edu/~mcmahon/CS241/Assign/Spring2022/assignme…

Assignment 2 http://faculty.cs.niu.edu/~mcmahon/CS241/Assign/Spring2022/assignme…

Assignment 2 http://faculty.cs.niu.edu/~mcmahon/CS241/Assign/Spring2022/assignme…

8 of 8 3/21/2022, 3:54 PM

Two short programs to solve problems using recursion Assignment 2
$24.99 $18.99