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
-5+|-15÷(-5) |2(-5) ​
pav-90 [236]

Answer:

The value of this expression is -35.

Step-by-step explanation:

Let's use the order of operations (PEMDAS), to solve this problem.

-5+|-15/-5|*2*(-5)\\-5+3*-10\\-5+-30\\-35

In conclusion, the value of this expression is -35. Hope this helped :D

7 0
3 years ago
Graph the first six terms of a sequence where a1 = 2 and r = 4.
zavuch27 [327]
We are given with
a1 = 2
r = 4

These are components of a geometric series. The first term is 2 and the common ratio is 4. To get the first six terms, we use the formula:
an = a1 r^(n-1)
a1 = 2 (4)^(1-1) = 2
a2 = 2 (4)^(2-1) = 8
a3 = 2 (4)^(3-1) = 32
a4 = 2 (4)^(4-1) = 128
a5 = 2 (4)^(5-1) = 512
a6 = 2 (4)^(6-1) = 2048
8 0
3 years ago
Read 2 more answers
What's the equation of this line ?
Gennadij [26K]
Y = -3x + 7

good luck!
5 0
2 years ago
Read 2 more answers
6а + 9 = 33<br> Need to solve
liq [111]

Answer: a=4

Step-by-step explanation:

6a+9=33

Subtract

6a=24

Divide

a=4

7 0
2 years ago
Read 2 more answers
If f(x)= 1/x+2 and a&gt;3, which of the following could be f(a)
Xelga [282]
I think it’s D not sure
5 0
2 years ago
Other questions:
  • A motorcycle zoomed along the freeway, traveling 10 meters in
    15·1 answer
  • Which ordered pair is a solution of the equation?
    10·2 answers
  • Q =3x2+5x-2 R = 2 – x2 S = 2x + 5 Find Q – [R + S] Show all of the steps.
    8·1 answer
  • Please help I really need help on this
    6·2 answers
  • Determine if EF || HL
    15·1 answer
  • Write a capital letter that appears to have perpendicular line segments?
    10·2 answers
  • True or False question
    7·1 answer
  • AP statistics:<br><br> What is the easiest way to understand sample size?
    6·1 answer
  • Solve question 5 all steps
    15·1 answer
  • What is not a factor of 16​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!