Read programs and find out their outputs. Please provide process tree with our answer to get...

Read programs and find out their outputs. Please provide process tree with our answer to get full points.

(a)
#include <unistd.h> #include <stdlib.h> #include <stdio.h>

int main()
{ for(i=0;i<3;i++)

if(fork()>0) printf(“A\n”); }

(b)
#include <unistd.h> #include <stdlib.h> #include <stdio.h>

int gVar=0;

int main() {

int lVar=0;
int *p;
p=(int *)malloc(sizeof(int));

int pid=fork(); if(pid>0){

gVar=1;
lVar=1;
*p=1;
printf("%d, %d, %d\n", gVar, lVar, *p);

}else{
gVar=2;

lVar=2;
*p=2;
printf("%d, %d, %d\n", gVar, lVar, *p);

} }

(c) Read the following code and answer the questions below:

#include <unistd.h> #include <stdio.h>

main() {

int i;

for(i=0;i<3;i++) if(i%2==1)

fork(); else{

fork();

fork(); }

}

(1) How many processes are created by the OS when it runs the following program?

(2) Suppose your answer to (1) is n, and let us denote the n processes as P1, P2, ..., Pn, please describe the parent-child relations among the processes.

In: Computer Science

1.If one statement is nested within another statement, as in a loop or recursive call, what...

1.If one statement is nested within another statement, as in a loop or recursive call, what is the running time of the two statements when considered as a block?

the running time for the inner statement added to the running time for the outer statement

the running time for the inner statement multiplied by the running time for the outer statement

the running time for the inner statement divided by the running time for the outer statement

the running time for the outer statement divided by the running time for the inner statement

2. Which of the following is false regarding a recursive algorithm?

It should proceed towards a base case.

Each recursive call places another activation record on the stack.

It will always be more efficient than a corresponding iterative solution.

Each recursive call should operate on a smaller version of the original problem

3. What will happen if you execute a recursive algorithm that does not have a base case?

The algorithm will immediately fail.

The algorithm will execute, but it will take much longer to terminate than it would if it had a base case.

The algorithm will never terminate.

It can not be said what will happen with only the given information

4. What is the advantage of using dynamic programming?

Dynamic programming will work with dynamic data instead of static data (i.e., data that do not change).

Dynamic programming allows a recursive algorithm to be used, but prevents the algorithm from solving the same instance of a problem more than once.

Dynamic programming is an iterative, rather than a recursive technique, and thus performs more efficiently.

Dynamic programming is the only way to handle multiple base cases in a recursive problem

In: Computer Science

What is one part of risk management which you would like to learn more about and...

What is one part of risk management which you would like to learn more about and why?

In: Finance

Why have the largest internet providers warned consumers not to purchase anything through public WiFi networks?...

Why have the largest internet providers warned consumers not to purchase anything through public WiFi networks? Briefly discuss the history and background of the issue of WiFi Networks, and it’s current and future impact on the Network Security and Cryptography field.

In: Computer Science

Make and discuss three strategies that you as the Human Resources manager can take to either...

Make and discuss three strategies that you as the Human Resources manager can take to either capitalize on an opportunity presented through the external variables and/or minimize the negative impact of external variables on the organization. based on Nike industry or cunsumer electric industry with referenec

In: Operations Management

(Could you solve this by using a financial calculator and just telling me what I need...

(Could you solve this by using a financial calculator and just telling me what I need to input) You would like to have the current equivalent in terms of today's buying power of $3,000 in years 4 5 and 6 How much would you have to invest in years 1, 2 and 3 (the same amount in each year in nominal terms) to fund this level of real consumption? You expect inflation to be 3% per year over that time period. Your investments earn 7% per year in nominal terms

Answer Choices:

$2,449 $2,779 $2,893 $2,836

In: Finance

You need to write a program that reads in two integers from cin and outputs an...

You need to write a program that reads in two integers from cin and outputs an horribly inefficent calculation of the median value.

First count from the first number to the second, but stop one short.

Then, count from that number back towards the first, again stopping one short.

Continue until you reach a single number.

In: Computer Science

5. Paint the ceiling You want to build yourself a house. The building company you hired...

5. Paint the ceiling You want to build yourself a house. The building company you hired can only build houses with sides from their specific set s. That means they can build you a square house or a rectangular one but if and only if its length and width belong to the set s. This month, they have a special promotion: they will paint the ceiling of a new house for free...but only if its area is not more than a. You want them to do it for free but you also want to be sure that the house will be comfortable and not too small. How many possible house configurations can you create to have the ceiling painted for free given the side lengths offered? There is a method to how the company decides what lengths of sides to produce. To determine n lengths of wall segments to offer, they start with a seed value s0, some variables k, b and m, and use the following equation to determine all other side lengths s[i]: s[i]=((k*s[i-1]+b) mod m)+1+s[i-1]) for 1 si

In: Computer Science

Langton Ant Program: This assignment will apply Langton's ant a two-dimensional universal turning machine on a...

Langton Ant Program:

This assignment will apply Langton's ant a two-dimensional universal turning machine on a 2 dimensional X by X grid where each grid cell is of the color white or black and the ant can be described as one of eight states ie. cell color and orientation.

Create a X by X square grid of “Cell”s that are either black or white. Begin with the “ant” in the center of the grid ( X must be a odd number/integer). Start the ant in a “up” orientation in the center of the board. Perform N steps where each step has to follow some simple rules:

  1. If the ant is on a white tile turn 90° clockwise, then change the color of the tile & move forward one unit
  2. If the ant is on a black tile turn 90° counterclockwise, change the color of the tile and then move forward one unit.

You are to program the `Cell` class according to the following:

Cell color:

The `Cell` class will store the cell's color as a private member variable named `color` of type `CellColor` where `CellColor` is an enumeration data type defined as:

“enum CellColor {white, black};”

Constructor :

The `Cell` class will be constructed using the default constructor i.e. will not accept any arguments. The constructor will set `color` to `white` upon construction.

Cell Color Mutator

The `Cell` class will contain a public member function called `change_color` to change the `color` member. I.e. if `color` is set to `white`, calling `change_color( )` will change the `color` to `black`. The member function `change_color` will return type `void` and will accept no input parameters.

Cell Color Accessors

The `Cell` class will contain two "getter" functions to access `color`.

1.) Must be named `get_color`, will return type `CellColor`, must return the value of `color`, and must accept no input parameters. `get_color must return the value of `Cell`'s `color` member.

  1. Must be named `get_color_string`, must return type `std::string`, and must accept no input. `get_color_string` must return "1" if `color` is `black` and must return "0" if `color` is `white`.

The template we will be using to declare the “Cell” class

Cell.hpp:

#include

// Declare an enumeration data type to store the Cell's color

enum CellColor {white, black};

// Declare the Cell Class

class Cell {

public:

          // Declare default constructor to initialize color to white

          // Declare member function getter for the color (get_color). Returns CellColor

          // Declare a member to flip the color (change_color)

          // Declare a member to print the string for this color.

          // white = "0", black = "1"

private:

          // Declare the color of this cell (color) as type CellColor

};

#endif

Cell.cpp:

#include "Cell.hpp"

(This is only part 1. of this assignment so I only need the code for this part I described and not the grid and ant movement yet)

In: Computer Science

When you are promoted into a role where you are managing people, you don’t automatically become...

When you are promoted into a role where you are managing people, you don’t automatically become a leader? Agree or Disagree and please support your argument.

In: Psychology

Useing Gulf Airline company For ,, A- Explain what business strategy is and discuss why the...

Useing Gulf Airline company For ,,

A- Explain what business strategy is and discuss why the competitive advantages are temporary along with the four key areas of a SWOT analysis.

B-Give an example to show how you may apply the SWOT.

(1000 Words).







Use the same quastion For Any Big Airline in the world that you have information about it


In: Operations Management

When Managing Quality—why is selecting a facility location becoming much more complex? Please elaborate on the...

  1. When Managing Quality—why is selecting a facility location becoming much more complex? Please elaborate on the following:

    1. Shipping (transport)

    2. capital ($ funding)

    3. labor (workforce)

In: Operations Management

Write Hamilton’s rule and discuss how it is used to explain the evolution altruism.

Write Hamilton’s rule and discuss how it is used to explain the evolution altruism.

In: Biology

What is the rate constant for a reaction based on the following experimental information? Experiment Rate...

What is the rate constant for a reaction based on the following experimental information?

Experiment Rate (M/s) [A] (M) [B] (M) [C] (M)
1 0.3126 0.25 0.53 0.45
2 0.3126 0.55 0.53 0.45
3 0.574 0.25 0.954 0.45
4 2.3217 0.55 1.484 1.17

In: Chemistry

ANY BANKS ARE FINE!! PLEASE ANSWER ALL OF THESE QUESTIONS↓ It is time to do some...

ANY BANKS ARE FINE!! PLEASE ANSWER ALL OF THESE QUESTIONS↓

It is time to do some bargain shopping as you decide to open your own checking account. Then visit or call three local banks in your area and obtain the necessary information from each to complete the checklist. In a few paragraphs, compare the pros and cons of opening an account with each bank and explain which you would choose and why.

1) Do I have to keep a minimum balance, or amount of money, in the account to avoid fees?

2) Is there a monthly fee? How much is it?

3) Will it be charged check writing fees?

4) How many checks can I write per month?

5) Will the bank return my canceled checks each month or keep them on file?

6) Will I be charged ATM fees?

7) What other fees are associated with this account.

In: Finance