1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Klio2033 [76]
3 years ago
12

Your job is to prepare a lineup of n awardees at an award ceremony. You are given a list of m constraints of the form "i wants t

o receive an award before j." If you violate a constraint, it might upset the affected award recipient (i) and then i may leave the ceremony. Give an algorithm that prepares such a lineup, (or says that it is not possible) in O ( m + n ) time.
Mathematics
1 answer:
DanielleElmas [232]3 years ago
6 0

Answer:

The idea is to use the concept of topological sorting.

Complexity of this algorithm is equal to complexity of DFS algorithm, that is, O(m+n).

Step-by-step explanation:

The idea is to use the concept of topological sorting.

A topological sort also called a topological ordering of a directed graph is a linear ordering of its vertices in a way that for every directed edge uv from vertex u to vertex v, u comes before v in the ordering. For instance, the vertices of the graph may represent tasks to be performed, and the edges may represent constraints that one task must be performed before another; in this application, a topological ordering is just a valid sequence for the tasks.

A topological sorting is possible if and only if the graph has no directed cycles, that is, if it is a directed acyclic graph (DAG).

For every edge (U - - >V), create a directed edge from U to V.

While creating an edge, if an edge creates a cycle, then it is not possible.

n= number of awardees

m= the number of constraint

Let n represent the vertices of a graph and constraints m is representing edges of a graph.

and graph is represented in adjacent of O(m+n)

Constraint i wants to receive award before j

Graphical representation - - - - - > (i) - - - - - - > (j) j depends on i

1. Presently run topological olding on graph G(n, m) where n is vertices and m is edges.

2. Run DFs on Graph, a temporary stack

3. Firstly call topological sorting for all its adjacent vertices and then push it to a stack. Finally, print content of stack.

4. Vertex is push to stack only when all adjacent vertices are already in stack.

Complexity of this algorithm is equal to complexity of DFS algorithm, that is, O(m+n).

You might be interested in
The length of a rectangle is represented by the function L(x) = 5x. The width of that same rectangle is represented by the funct
Mazyrski [523]

Remember that the area of a rectangle is the length of the rectangle multiplied by the width of the rectangle.


In this case, we could say (where A(x) is the area of the rectangle):

A(x) = L(x) \cdot W(x)


Substituting the values the problem gave us for L(x) and W(x), we can find the formula for A in terms of x, which is:

A(x) = (5x) \cdot (2x^2 - 4x + 13) = (10x^3 - 20x^2 + 65x)


The formula for the area of the rectangle would be A(x) = 10x³ - 20x² + 65x.

3 0
3 years ago
Read 2 more answers
For every 11 litres of petrol a car can run for 50 km.
algol [13]

Answer: 50.2 liters

Step-by-step explanation:

11 liters = 50km

Z liters = 228km

To get the value of Z, cross multiply

228 x 11 = Z x 50

2508 = 50z

Divide both sides by 50

2508/50 = 50z/50

50.16 = z

50.16 has two decimal places, so convert to 1 decimal place by approximation

50.16 = 50.2

Thus, 50.2 liters will be enough for 228km

6 0
3 years ago
Read 2 more answers
SOMEONE Please HELP me out with theses 2
olchik [2.2K]
Hello!

The answer for #1. is 4 centimeters, because it is the only reasonable answer. 
The answer for #2. is 1 millimeter, because the tick is smaller than the penny, which is smaller than any of the other lengths. 

I hope this helped :))

4 0
3 years ago
Read 2 more answers
A cylinder shaped can needs to be constructed to hold 600 cubic centimeters of soup. The material for the sides of the can costs
PSYCHO15rus [73]

Answer:

the dimensions that minimize the cost of the cylinder are R= 3.85 cm and L=12.88 cm

Step-by-step explanation:

since the volume of a cylinder is

V= π*R²*L → L =V/ (π*R²)

the cost function is

Cost = cost of side material * side area  + cost of top and bottom material * top and bottom area

C = a* 2*π*R*L + b* 2*π*R²

replacing the value of L

C = a* 2*π*R* V/ (π*R²) + b* 2*π*R²  = a* 2*V/R + b* 2*π*R²

then the optimal radius for minimum cost can be found when the derivative of the cost with respect to the radius equals 0 , then

dC/dR = -2*a*V/R² + 4*π*b*R = 0

4*π*b*R = 2*a*V/R²

R³ = a*V/(2*π*b)

R=  ∛( a*V/(2*π*b))

replacing values

R=  ∛( a*V/(2*π*b)) = ∛(0.03$/cm² * 600 cm³ /(2*π* 0.05$/cm²) )= 3.85 cm

then

L =V/ (π*R²) = 600 cm³/(π*(3.85 cm)²) = 12.88 cm

therefore the dimensions that minimize the cost of the cylinder are R= 3.85 cm and L=12.88 cm

5 0
3 years ago
What is the l and w of a rectangular field of 40 ft perimeter?
shusha [124]
The perimeter doesn't tell you the dimensions.

With a 40-ft perimeter, there an infinite number of possibilities
for the length and with.  The only thing we know for sure is that
the sum of (length + width) is 20-ft.

The field could be . . .

1'  by  40'
2'  by  20'
3'  by  13-1/3 '
4'  by  10'
5'  by  8'
6'  by  6-2/3 '
3 0
2 years ago
Other questions:
  • Plot the points (2, 4) and (2, -8) on the coordinate plane below.
    15·1 answer
  • Triangle ABC has vertices A(4, 5), B(0, 5), and C(3, –1). The triangle is translated 3 units to the left and 1 unit up.
    9·2 answers
  • Jackson says has an odd number of model cars.he has 6 cars on one shel and 8 cars on another shelf.is jackson correct?explain
    8·1 answer
  • Simplify the expression by combining like terms.<br> -3(6j+1)-(3j+6)-4j+7
    14·1 answer
  • The area of trapezoid TRAP is 100. Furthermore, TR=32, AP=8, and TP=RA. If T=R what is the ;length of segment TP?
    9·1 answer
  • If the initial amount of iodine-131 is 537 grams , how much is left after 10 days?
    10·1 answer
  • If someone can help me figure out #6. Thanks
    10·1 answer
  • 90 people attended the movies yesterday. 87 people attended the movies today. Is this an increase or decrease? What was the perc
    8·1 answer
  • In this question what does the value of ? equal to?
    14·1 answer
  • How to solve this ??? can anyone help me ..​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!