a) Write a program that asks user to enter number of vertices in a directed graph and then the adjacency matrix representing the directed graph. The program, then, must display the node with the highest outdegree. Assume that nodes are named as 0, 1, 2 and so on. You will find a sample run of the program below. Enter number of vertices: 4 Enter adjacency matrix: 0 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 Node with the highest outdegree: 0
Q: JAVA Problem Create a function that determines whether elements in an array can be re-arranged to…
A: Algorithm - Take one string as input. Now use the below logic return (arr[arr.length - 1] -…
Q: Q1) A vector is given by x = [7,19,2,14,5,12,4,18,6,13]. Using conditional statements and loops,…
A: The steps to create the program: Create a vector x to store the values. Declare the vectors T and…
Q: Q2] A vector is given by x = [-3.5 -5 6.2 11 0 8.1 -903-1 3 2.5]. Using conditional statements and a…
A: Iterate over the vector using while loop from index 1 to length of vector and then check whether…
Q: Cartesian Product Programming challenge description: The Cartesian product of two lists of numbers A…
A: The solution to the given problem is below.
Q: IN C++ Write a program that implements the game tic-tac-toe: Tic-Tac-Toe is a game played on a…
A: include<bits/stdc++.h> using namespace std; #define COMPUTER 1 #define HUMAN 2 #define…
Q: Create a list of 20 random grades between 0 and 100. Write the code for filtering that generates a…
A: for x in range (1,20): #using randint to get all random values between 1 and 100…
Q: 8. You live in a village. The village can be represented as a line that contains n grids. Each grid…
A: C code with output provided below:
Q: I'm running a 5-star restaurant and I can only have the best items on my menu. My menu offers 6…
A: Q: Code the given problem
Q: For the end of year administration of Programming for History of Arts students you are to write a…
A: To provide the desired output, we have to enter the file name as input. input.txt:- Piet van…
Q: ii) Write a Java program to find the number of loops in the array given below. A loop is defined as…
A: public class Main{ public static void main(String[] args) { int[] a=new…
Q: Graph Data Structure - Adjacency Matrix Implement a Program in C++ that does the following: 1) Asks…
A: Note: As you have asked a mulitpart question, we will solve the first three parts for you. If you…
Q: Q.2 Write C++ code that ask the user to enter any number, then the program will print a matrix (each…
A: NOTE Below is the program for the given question. Hope you understand it well. If you have any…
Q: (Geometry: polygon subareas) A convex 4-vertex polygon is divided into four triangles, as shown in…
A: Here is the java program: import java.util.Scanner; public class PolygonSubareas { staticfinalint…
Q: 7.10: Tic Tac Toe (sort of) Write a program that will allow two users to playtic-tac-toe. The…
A: Program: #include <iostream>using namespace std; void initialize_Board(char board[][3]);void…
Q: 7. a) Write down the 5 by 5 adjacency matrix for the undirected graph below (Figure 1). A C E B…
A: The following is the adjacency matrix for the given graph: A B C D E A 0 1 1 0 0 B 1 0 1 1…
Q: Consider the below code snippet. Assume bool foundPair and int pairCount are both declared and have…
A: Answer : True.
Q: Question: Use the following vector for problem number :
A: sentence <- c("Learning", "loops", "in", "R", "is", "not", "that", "bad")max_val <-…
Q: . Card Flipper: You walk into a room, and see a row of n cards. Each one has a number x; written on…
A:
Q: Q.3 Write a c++ program that asks the user to enter two numbers (from 100 to 999) to create a matrix…
A: NOTE Below is the program for the given question. Hope you understand it well. If you have any…
Q: 4. a) Write a program that asks user to enter number of vertices in an undirected graph and then the…
A: program code: //Header file #include <iostream> #include<queue> //Using namespace using…
Q: Write a program that will first create a graph and then adopt a function that returns if a node is…
A: #include<iostream > #include < vector > using namespace std; vector <int> adj[10];…
Q: 8. You live in a village. The village can be represented as a line that contains n grids. Each grid…
A: Each person can reach 1 grid. People can only access their homes. Note that HB.BH also works. Each…
Q: c++ exercise /* Problem: Write a program that uses nested loops to display the…
A:
Q: code for this in C: Pascal’s Triangle Version 2 The Pascal triangle can be used to compute the…
A:
Q: a,b,c Please write answer so I can copy paste*** Exercise 1.6.4: Truth values for quantified…
A: The correct answer is (b) ∃x P(x) Explanation: An existential quantification is also a quantifier…
Q: Q1) A vector is given by x = [7,19,2,14,5,12,4,18,6,13]. Using conditional statements and loops,…
A: In this question we have to write a code for a vector where we need to separate the vector into two…
Q: 4)- Create a C++ program that finds the location, from the list of elements in an array. The program…
A: #include<iostream> using namespace std; //function to find location of the element in array…
Q: int i; for (i = 0; i ::iterator v = ++vec.begin(); while( ++v != vec.end()) { cout << ((*v/8)?…
A: Vectors are identical to dynamic bunches with the ability to resize itself thusly when a part is…
Q: The following subprogram uses to? for(int i=0;i<3;i++) for(int j=0;j<3;j++) if(i != j) sum+=A[i][j];…
A: NOTE - As per our guidelines we are supposed to answer only one question, please repost other parts…
Q: 4)- Create a C++ program that finds the location, from the list of elements in an array. The program…
A: #include<iostream>using namespace std;int main(){ int n; cout<<"enter the number…
Q: Solving system of linear equations with two variables using Cramer’s rule. In mathematics, the…
A: The program is written in c++
Q: Write a display function and delete function in the following code: Declare the libraries…
A: Write a display function and delete function in the following code: I checked out the above code,…
Q: Create a list of 20 random grades between 0 and 100. Write the code for a filtering that generates a…
A: The code for the given requirement is
Q: Create a function: -That takes a matrix and an integer v, -And returns True if the value v is in the…
A: Below is the required in python as language not specified and sample output:
Q: For the end of year administration of Programming for History of Arts students you are to write a…
A: python code: # function to calculate average grade def average(grades): # avg = sum of all…
Q: For the end of year administration of Programming for History of Arts students you are to write a…
A: # function to calculate average gradedef average(grades):# avg = sum of all grades / number of…
Q: Create a program which will ask the user to enter a list of names and provide a poker tournament…
A: As the programming language is not mentioned here, we are using JAVA The complete code is given…
Q: 3. Write a program to obtain inverse matrix by entering a 3*3 matrix from t user.(using visual…
A: NOTE:- since programming language is not defined we are providing solution in python programming…
Q: C++ The binary search algorithm given in this chapter is nonrecursive. Write and implement a…
A: code in C++
Q: Group B Q1) A vector is given by x-[-3.5-5 6.2 11 08.1-903-13 2.5]. Using conditional statements and…
A: We can write the program using the conditional statements are if , if else and loops for, while, do…
Q: 6. Binary Search [Problem description] Given the grade list of students in a class and your grade,…
A: Binary Search: Search in a sorted array by repeatedly dividing the search interval in half. Begin…
Q: Programming Exercise 5: You are to design a program to create five two-element word arrays (AAA,…
A: Given : You are to design a program to create five two-element word arrays (AAA, BBB, CCC, DDD,…
Q: C++ Programming, Arrays Lights The park is illuminated by n (1 < n < 100) lights. Each of them…
A: ARRAY : a collection of elements with same data type that are placed in contiguous memory location…
Q: For the end of year administration of Programming for History of Arts students you are to write a…
A: Given:
Q: Write in C language Description Gomoku, also called Five in a Row, is an abstract strategy board…
A: #include <stdlib.h> //stdlib header#include <stdio.h>#define MAX 100 //maximum…
Q: Q1: Write a C++ program that search for a number in array (12, 16, 21, 15, 30, 44, 63, 57). The…
A: Input array size, elements and number to be searched. Using for loop iterate through array and check…
Q: Write a program that simulates the game “hangman”.
A: #include<bits/stdc++.h>#include <unistd.h>using namespace std;class Node {private:…
Q: Geometry: area of a pentagon) Write a program that prompts the user to enter the length from the…
A: Declare double type variables to store side and area of pentagon. Read distance from centre to…
Q: nt "Matrix is not a square" Example: Input (The first line contains the number of rows and the…
A: Q. Using C Program and arrays, Write a program that will give the sum of the main and opposite…
Solve the question
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- Knight's Tour: The Knight's Tour is a mathematical problem involving a knight on a chessboard. The knight is placed on the empty board and, moving according to the rules of chess, must visit each square exactly once. There are several billion solutions to the problem, of which about 122,000,000 have the knight finishing on the same square on which it begins. When this occurs the tour is said to be closed. Your assignment is to write a program that gives a solution to the Knight's Tour problem recursively. You must hand in a solution in C++ AND Java. The name of the C++ file should be "main.cc" and the name of the Java file should be "Main.java". Write C++ only with a file name of main.cc Please run in IDE and check to ensure that there are no errors occuring Output should look similar to: 1 34 3 18 49 32 13 16 4 19 56 33 14 17 50 31 57 2 35 48 55 52 15 12 20 5 60 53 36 47 30 51 41 58 37 46 61 54 11 26 6 21 42 59 38 27 64 29 43 40 23 8 45 62 25 10 22 7 44 39 24 9 28 637.10: Tic Tac Toe (sort of) Write a program that will allow two users to playtic-tac-toe. The program should ask for movesalternately from player X and player O. Theprogram displays the game positions as follows: 123 456 789 The players enter their moves by entering theposition number (a single digit, 1-9) theywish to mark. After eachmove, the program re-displays the changed board.A sample board configuration is as follows:XXO 456 O89Computer Science IN C++ Write a program that implements the game tic-tac-toe: Tic-Tac-Toe is a game played on a three-by-three board. Two players, X and O, alternate in placing their respective marks in the cells of this board, starting with player X. If either player succeeds in getting three of his or her marks in a row, column, or diagonal, then that player wins. In this homework, you should use the OOP concepts to implement the tic-tac-toe game.
- C++ Create a Blackjack (21) game. Your version of the game will imagine only a SINGLE suit of cards, so 13 unique cards, {2,3,4,5,6,7,8,9,10,J,Q,K,A}. Upon starting, you will be given two cards from the set, non-repeating. Your program MUST then tell you the odds of receiving a beneficial card (that would put your value at 21 or less), and the odds of receiving a detrimental card (that would put your value over 21). Recall that the J, Q, and K cards are worth ‘10’ points, the A card can be worth either ‘1’ or ‘11’ points, and the other cards are worth their numerical values. FOR YOUR ASSIGNMENT: Provide two screenshots, one in which the game suggests it’s a good idea to get an extra card and the result, and one in which the game suggests it’s a bad idea to get an extra card, and the result of taking that extra card.7.10: Tic Tac Toe (sort of)Write a program that will allow two users to playtic-tac-toe. The program should ask for movesalternately from player X and player O. Theprogram displays the game positions as follows:123456789 The players enter their moves by entering theposition number (a single digit, 1-9) theywish to mark. After eachmove, the program re-displays the changed board.A sample board configuration is as follows:XXO456O89 SAMPLE RUN #1: ./ETest Interactive Session 1 2 34 5 67 8 9Enter move:1X 2 34 5 67 8 9Enter move:2X O 34 5 67 8 9Enter move:3X O X4 5 67 8 9Enter move:4X O XO 5 67 8 9Enter move:5X O XO X 67 8 9Enter move:6X O XO X O7 8 9Enter move:7X O XO X OX 8 9Enter move:8X O XO X OX O 9Enter move:9X O XO X OX O XGame over!In Java language Declare a constant V with value 5 Declare a variable named Graph that is an integer matrix of VxV Define a MENU procedure with the following text GRAPH 1. Create Graph 2.ShowGraph 3. Adjacency between pair 4. Input degree 5.Output degree 6.Loops 0.Exit Validate MENU so that it receives only valid options (from 0 to 6), otherwise send an error message and repeat the reading Make the MENU call in the main program Define a CREATE procedure/function to fill an array with random values between 0 and 1. Where 0 represents no adjacency and 1 indicates there is. Making the CREATE call in the main program receives as a parameter the Graph array created at point Define a SHOW procedure/function to print an adjacency matrix, in matrix form Make the SHOW call in the main program, it receives as a parameter the Graph array created in point 2 Define an ADJACENCY procedure/function that receives, apart from the array, two integer values and returns a true value if…
- Exercise #3 o Write a program averageLuminance(picture) which takes as input a picture uses functional programming to calculate the average luminance of the picture’s pixels. Use the helper function def luminance(pixel): r = getRed(pixel) g = getGreen(pixel) b = getBlue(pixxel) y = 0.2126 * r + 0.7152 * g + 0.0722 * b return y Within your main program, use map and luminance to create a list of luminances from the list of pixels. This is an example answer to help you formulate an answer for the question above: # Exercise 3 def isDocument(fileName): listOfEndings = [ ".docx", ".txt", ".rtf" ] for ending in listOfEndings: if fileName.endswith(ending): return True return False def recursiveListDocuments(directory=os.getcwd()): files = os.listdir(os.path.normpath(directory)) for file in files: fileName = os.path.normpath(directory + "/" + file) if isDirectory(fileName): recursiveListDocuments(fileName) else: if isDocument(fileName): print fileName7.10: Tic Tac Toe (sort of). (c++) Write a program that will allow two users to playtic-tac-toe. The program should ask for movesalternately from player X and player O. Theprogram displays the game positions as follows: 123 456 789 The players enter their moves by entering theposition number (a single digit, 1-9) theywish to mark. After eachmove, the program re-displays the changed board.A sample board configuration is as follows:XXO 456 O89 SAMPLE RUN #1: ./ETest Interactive Session 1 2 34 5 67 8 9 Enter move:1 X 2 34 5 67 8 9 Enter move:2 X O 34 5 67 8 9 Enter move:3 X O X4 5 67 8 9 Enter move:4 X O XO 5 67 8 9 Enter move:5 X O XO X 67 8 9 Enter move:6 X O XO X O7 8 9 Enter move:7 X O XO X OX 8 9 Enter move:8 X O XO X OX O 9 Enter move:9 X O XO X OX O X Game over!Q5. Write a program that reads from the user an integer matrix with 10x10, and then rotate that matrix 180° (UPSIDE DOWN) after that, calculate the sum and the average of the main diagonal. Print the matrix after the rotation and the values of the sum and the average of the main diagonal.
- Program definition: Write a program that simulates the game “hangman”. a. In the game of hangman, have a user enter a word for “another” player to guess. b. After the word to guess is entered, clear the screen and present a list of blanks or underscores representing unguessed letters of the hidden word. c. Have the user guess a letter in the word. If the letter is in the word, display the letter instead of the blank or underscore and display the remaining blanks or underscores for the unguessed letters, all in the proper position. d. If a previously guessed letter is repeated, whether in the word or not, another try is allowed without penalty. If a guess is incorrect, the game state progresses toward being “hung”. e. There are 8 bad guesses allowed before the game is lost. f. The game will progress through the states of PLATORM, HEAD, BODY, LEFT_ARM, RIGHT_ARM, LEFT_LEG, RIGHT_LEG, and HUNG. Use an ENUM to represent the game states listed. g. Use a linked list to…11.10 LAB: All permutations of names Write a program that lists all ways people can line up for a photo (all permutations of a list of strings). The program will read a list of one word names (until -1), and use a recursive method to create and output all possible orderings of those names, one ordering per line. When the input is: Julia Lucas Mia -1 then the output is (must match the below ordering): Julia Lucas Mia Julia Mia Lucas Lucas Julia Mia Lucas Mia Julia Mia Julia Lucas Mia Lucas Julia #include #include #include main.cpp: using namespace std; // TODO: Write method to create and output all permutations of the list of names. void AllPermutations(const vector &permList, const vector &nameList) { } int main(int argc, char* argv[]) { vector nameList; vector permList; string name; // TODO: Read in a list of names; stop when -1 is read. Then call recursive method. return 0; }Q // Write a program in C++ language that enters a number of integer numbers into a singular matrix whose size is renewed after asking the user about the number of numbers he wants to enter, then he collects these numbers and prints the result on the screen