Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Write a program to fill in a two- dimensional array of boolean values by setting a[i][j] to 1 if the greatest common divisor of

image text in transcribed
image text in transcribed
1. Write a program to fill in a two- dimensional array of boolean values by setting a[i][j] to 1 if the greatest common divisor of i and jis l. Else if the greatest common divisor is not 1, then set a[i]lj] to 0. Sample Input: ./a.out 6 Sample Output: OOOOOO 0 1 1 1 1 1 0101 01 011011 010101 0 1 1 1 1 0 Place this program in your pgm directory and call it 1.cpp. 2. Write a program to solve the Josephus problem, with the following modification: Sample Input: ./a.out nmp where n is the number of players and mis the count used for every odd turn while p is the count used for every even turn. ./a.out 5 2 3 Sample Output: Round 1: 1 -> 3 -> 4 -> 5 Round 2: 1 -> 3 -> 4 Round 3: 1 -> 4 Round 4: Winner is 1. Place this program in your pgm directory and name it 2.cpp 3. When is a graph a tree? Write a program that will read from a file specified on the command line and determine from the graph's adjacency matrix whether or not it is a tree. Example: ./a.out graph.txt Output: The graph is a tree! Contents of graph.txt will be something like this: 01000 10111 01000 01000 01000 To be graded, your program must be in your pgm and named precisely as 3.cpp

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

More Books

Students also viewed these Databases questions

Question

What is the best conclusion for Xbar Chart? UCL A X B C B A LCL

Answered: 1 week ago