using c++
10. Sorting Orders
Write a program that uses two identical arrays of eight integers.
It should display the contents
of the first array, then call a function to sort it using an
ascending order bubble sort, modified
to print out the array contents after each pass of the sort. Next
the program should display the
contents of the second array, then call a function to sort it using
an ascending order selection
sort, modified to print out the array contents after each pass of
the sort.
test case:
Bubble Sort The unsorted values are: 7 2 3 8 4 5 6 1 sort pass #1 : 2 7 3 8 4 5 6 1 sort pass #2 : 2 3 7 8 4 5 6 1 sort pass #3 : 2 3 7 4 8 5 6 1 sort pass #4 : 2 3 7 4 5 8 6 1 sort pass #5 : 2 3 7 4 5 6 8 1 sort pass #6 : 2 3 7 4 5 6 1 8 sort pass #7 : 2 3 4 7 5 6 1 8 sort pass #8 : 2 3 4 5 7 6 1 8 sort pass #9 : 2 3 4 5 6 7 1 8 sort pass #10 : 2 3 4 5 6 1 7 8 sort pass #11 : 2 3 4 5 1 6 7 8 sort pass #12 : 2 3 4 1 5 6 7 8 sort pass #13 : 2 3 1 4 5 6 7 8 sort pass #14 : 2 1 3 4 5 6 7 8 sort pass #15 : 1 2 3 4 5 6 7 8 The sorted values are: 1 2 3 4 5 6 7 8 Selection Sort The unsorted values are: 7 2 3 8 4 5 6 1 sort pass #1 : 1 2 3 8 4 5 6 7 sort pass #2 : 1 2 3 8 4 5 6 7 sort pass #3 : 1 2 3 8 4 5 6 7 sort pass #4 : 1 2 3 4 8 5 6 7 sort pass #5 : 1 2 3 4 5 8 6 7 sort pass #6 : 1 2 3 4 5 6 8 7 sort pass #7 : 1 2 3 4 5 6 7 8 The sorted values are: 1 2 3 4 5 6 7 8
In: Computer Science
1. U ( x 1 , x 2 ) = 2 x1 + 3 x 2
If the price of good 1 is $4/unit, the price of good 2 is $5/unit , and income is $20...
What is this person's optimal consumption level for good 1?
2. U( x 1 , x 2 ) = 5 x1 + 3 x2
If the price of good 1 is $2/unit, the price of good 2 is $1/unit , and income is $10...
What is this person's optimal consumption level for good 1?
In: Economics
Given the vectors u1 = (2, −1, 3) and u2 = (1, 2, 2) find a third vector u3 in R3 such that
(a) {u1, u2, u3} spans R3
(b) {u1, u2, u3} does not span R3
In: Advanced Math
In this question, you are going to implement a human vs. human version of Notakto.
Notakto is a tic-tac-toe variant. It is played across three 3 x 3 boards: Board A, board B and board C. When you start the game you should output the boards as follows.
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
6 7 8 6 7 8 6 7 8
Player 1:
There are two players: Player 1 and player 2. Player 1 always
starts. Both players play the same piece: X. E.g., let player 1
choose location 6 on board A, i.e., the user will enter A6. The
output of the program should be as follows (bold font represents
user input).
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
6 7 8 6 7 8 6 7 8
Player 1: A6
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
X 7 8 6 7 8 6 7 8
Player 2:
Each player takes turn placing an X on the board in a vacant space
(a space not already occupied by an X).
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
6 7 8 6 7 8 6 7 8
Player 1: A6
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
X 7 8 6 7 8 6 7 8
Player 2: A7
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
X X 8 6 7 8 6 7 8
Player 1:
If a board has three X in a row, column, or diagonal, the board is
dead and it cannot be played anymore. It should not be displayed
anymore. E.g., in the following, board A becomes dead and is not
displayed anymore.
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
6 7 8 6 7 8 6 7 8
Player 1: A6
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
X 7 8 6 7 8 6 7 8
Player 2: A7
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
X X 8 6 7 8 6 7 8
Player 1: A8
B C
0 1 2 0 1 2
3 4 5 3 4 5
6 7 8 6 7 8
Player 2:
The game ends when all the boards contain three X in a row, column,
or diagonal, at which point the player to have made the last move
loses the game. Unlike tic-tac-toe, there will always be a player
who wins any game of Notakto.
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
6 7 8 6 7 8 6 7 8
Player 1: A6
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
X 7 8 6 7 8 6 7 8
Player 2: A7
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
X X 8 6 7 8 6 7 8
Player 1: A8
B C
0 1 2 0 1 2
3 4 5 3 4 5
6 7 8 6 7 8
Player 2: B0
B C
X 1 2 0 1 2
3 4 5 3 4 5
6 7 8 6 7 8
Player 1: B4
B C
X 1 2 0 1 2
3 X 5 3 4 5
6 7 8 6 7 8
Player 2: C0
B C
X 1 2 X 1 2
3 X 5 3 4 5
6 7 8 6 7 8
Player 1: C4
B C
X 1 2 X 1 2
3 X 5 3 X 5
6 7 8 6 7 8
Player 2: C8
B
X 1 2
3 X 5
6 7 8
Player 1: B8
Player 2 wins game
Note that you should check for legal moves. If the users enters
something illegal you should prompt them again. Let's play a new
game to illustrate this.
A B C
0 1 2 0 1 2 0 1 2
3 4 5 3 4 5 3 4 5
6 7 8 6 7 8 6 7 8
Player 1: C0
A B C
0 1 2 0 1 2 X 1 2
3 4 5 3 4 5 3 4 5
6 7 8 6 7 8 6 7 8
Player 2: B9
Invalid move, please input again
Player 2: fds
Invalid move, please input again
Player 2: C0
Invalid move, please input again
Player 2: C6
A B C
0 1 2 0 1 2 X 1 2
3 4 5 3 4 5 3 4 5
6 7 8 6 7 8 X 7 8
Player 1: C6
Invalid move, please input again
Player 1: C3
A B
0 1 2 0 1 2
3 4 5 3 4 5
6 7 8 6 7 8
Player 2: C2
Invalid move, please input again
Player 2:
Implement the game and try to pass all test cases. The list of test
cases is not complete. We may add more test cases when marking
after the deadline.
Yo
I want the answer in python
In: Computer Science
The following is the transition probability matrix of a Markov chain with states 1, 2, 3, 4 P
| 0 | 1 | 2 | 3 | |
|---|---|---|---|---|
| 0 | .4 | .3 | .2 | .1 |
| 1 | .2 | .2 | .2 | .4 |
| 2 | .25 | .25 | .5 | 0 |
| 3 | .2 | .1 | .4 | .3 |
If Xnot = 1
(a) find the probability that state 3 is entered before state
4;
(b) find the mean number of transitions until either state 3 or
state 4 is entered.
In: Statistics and Probability
2. Find all eigenvalues and corresponding linearly independent eigenvectors of A = [2 0 3 4] (Its a 2x2 matrix)
4. Find all eigenvalues and corresponding linearly independent eigenvectors of A = [1 0 1 0 2 3 0 0 3] (Its's a 3x3 matrix)
6. Find all eigenvalues and corresponding eigenvectors of A = 1 2 3 0 1 2 0 0 1 .(Its a 3x3 matrix)
In: Math
A jar contains 5 pennies, 4 nickels and 2 dimes. A child selects 2 coins at random without replacement from the jar. Let X represent the amount in cents of the selected coins. Find the probability X = 10. Find the probability X = 11. Find the expected value of X.
In: Statistics and Probability
Consider an isotope with an atomic number of [2(5+A)] and a mass number of [4(5+A)+2]. Using the atomic masses given in the attached table, calculate the binding energy per nucleon for this isotope. Give your answer in MeV/nucleon and with 4 significant figures. (A=8)
A particular radioactive isotope has a half-life of (2.50+A) hours. If you have (24.5+B) g of the isotope at 10:00 AM, how much will you have at 7:30 PM? Give your answer in grams (g)and with 3 significant figures. (A=8, B=7)
In: Physics
A jar contains 2 pennies, 6 nickels and 4 dimes. A child selects 2 coins at random without replacement from the jar. Let X represent the amount in cents of the selected coins.
a. Find the probability X = 11.
b. Find the expected value of X
In: Statistics and Probability
find the surface area of the paraboloid z = 4−x^2 −y^2 in the first octant.
In: Math