![subject](/tpl/images/cats/informatica.png)
Computers and Technology, 11.03.2020 02:13 kskfbfjfk
C CODE .Finish the code and run ./fork-puzzle |sort| uniq. Which of the following is the correct output?
//In this assignment, we use fork() to create multiple processes to solve a puzzle.
//The puzzle is specified by the following array
//int a[] = {3, 6, 4, 1, 3, 4, 2, 5, 3, 0};
//A walker walks along the index of this array.
//He starts at index 0, where a[0] is 3, which indicates that
//the walker can move 3 steps. If the walker moving to the left, he would be at index
//-3, which is out of the range. Hence, he can only move to the right, after he makes the move,//he will be at index 3. Since a[3] = 1, he can move to the left or right by one move.
//Note whenever he makes his move, he should be in the range [0, 9]. He is not allowed to move
//outside of this range.
//The goal of the puzzle is to for the walker to reach index 9, where a[9] = 0. And he will
//stop there.
//What we need to do is to find the solutions of this puzzle. We limit the solutions to have
//at most 10 moves.
#include
#include
#include
#include
void print_solution(int b[], int moves)
{
for(int k = 0; k
{
printf("->%d ", b[k]);
}
printf("\n");
}
int main(int argc, char *argv[])
{
//We use the array a to describe the puzzle
int a[] = {3, 6, 4, 1, 3, 4, 2, 5, 3, 0};
//We use the array b to save the moves the walker makes
//Essentially, we save each index that the walker reaches in array b
//For example, b[0] = 3 since the walker goes to index 3 for the first move
int b[10];
int cur = 0;
int moves = 0;
int n = 10;
for(int i = 0; i< n; i++)
{
if(fork() == 0)
{
//If we find a solution, we print the solution
if(a[cur]==0)
{
b[moves - 1] = cur;
print_solution(b, moves);
return 0;
}
else if(cur + a[cur] >= 0 && cur + a[cur]
{
//Add your code here
}
}
else
{
//If we find a solution, we print the solution
if(a[cur]==0)
{
b[moves - 1] = cur;
print_solution(b, moves);
return 0;
}
else if(cur - a[cur] >= 0 && cur - a[cur]
{
//Add your code here
}
}
}
return 0;
}
/*
Note run your code the following different ways and observe the outputs
./fork-puzzle
./fork-puzzle |sort
./fork-puzzle |sort| uniq
*/
there is four option, chose one.
->3 ->2 ->6 ->8 ->5 ->9
->3 ->4 ->1 ->7 ->2 ->6 ->8 ->5 ->9
->3 ->4 ->7 ->2 ->6 ->8 ->5 ->9
All of the above
![ansver](/tpl/images/cats/User.png)
Answers: 3
Another question on Computers and Technology
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 22.06.2019 16:50
Consider a slotted aloha system, where the time slot equals the fixed duration of each packet. assume that there are 4 stations a,b,c,d sharing the medium. (a) stations a,b,c,d receive one packet each from higher layers at times 1.3, 1.5, 2.6,5.7 respectively. show which transmissions take place when, according to the slottedaloha protocol; describe all transmissions until all four packets have been successful.when needed, each station has access to the following sequence of random number, provided by a random number generator and drawn uniformly between 0 and 1: (1) station a draws numbers: 0.31, 0.27, 0.78, 0.9, 0.9, 0.11, 0. (2) station b draws numbers: 0.45, 0.28, 0.11, 0.83, 0.37, 0.22, 0. (3)station c draws numbers: 0.1, 0.2, 0.3, 0.4, 0. (4) station d draws numbers: 0.36, 0.77, 0.9, 0.1, 0.1, 0.1, 0.1, 0. (b) in slotted aloha, a station transmits in each time slot with a given probability. what probabilities would you assign to each of the four stations so as to: (i) maximize the efficiency of the protocol? (ii) maximize fairness among the four stations? (c) will the efficiency increase or decrease if we modify slotted aloha as follows: (i) get rid of slots and allow stations to transmit immediately? (ii) implement carrier sensing? (iii) implement collision detection? (iv) implement collision avoidance?
Answers: 3
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 19:00
In python a floating-point number must be written using scientific notation?
Answers: 1
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 21:40
is on drugs i swear i ask a question and its not showing whats going
Answers: 2
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 22:30
To include a watermark or page border on a word document, you will first need to navigate to the tab. file home insert design
Answers: 1
You know the right answer?
C CODE .Finish the code and run ./fork-puzzle |sort| uniq. Which of the following is the correct out...
Questions
![question](/tpl/images/cats/informatica.png)
Computers and Technology, 19.08.2019 11:10
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/fizika.png)
Physics, 19.08.2019 11:10
![question](/tpl/images/cats/mat.png)
Mathematics, 19.08.2019 11:10
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/obshestvoznanie.png)
Social Studies, 19.08.2019 11:20
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/istoriya.png)
History, 19.08.2019 11:20
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/mat.png)
![question](/tpl/images/cats/en.png)
English, 19.08.2019 11:20
![question](/tpl/images/cats/mat.png)
Mathematics, 19.08.2019 11:20
![question](/tpl/images/cats/mat.png)
Mathematics, 19.08.2019 11:20
![question](/tpl/images/cats/fizika.png)
Physics, 19.08.2019 11:20
![question](/tpl/images/cats/obshestvoznanie.png)
![question](/tpl/images/cats/obshestvoznanie.png)
Social Studies, 19.08.2019 11:20
![question](/tpl/images/cats/istoriya.png)
![question](/tpl/images/cats/en.png)
English, 19.08.2019 11:20