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
Together, teammates Pedro and Ricky got 2679 base hits last season. Pedro had 283 more hits than Ricky. How many hits did each p
Sergio [31]

Answer:

Pedro: 1481 Base hits

Ricky: 1198 Base hits

Step-by-step explanation:

First, take the total amount of base hits last season 2679, then subtract how many more Pedro has 283.

2679 - 283 = 2396 now divide the sum in half  2396 ÷ 2 = 1198 that gives you how many each player has, you're then going to add the amount that you took off to only Pedras total since he had 283 more

Pedro: 1198 + 283 = 1481

Ricky: 1198

3 0
3 years ago
Simplify. Please show your work.<br> 4a+12b+10a-4b
Drupady [299]

Answer:

14a + 8b

Step-by-step explanation:

First, you need to combine like terms.

4a + 10a = 14a

12b + (-4b) = 8b

14a + 8b

6 0
3 years ago
Subtraction.<br> 3x−2y<br> =8<br> 3x+ y<br> =14<br> The solution is that
netineya [11]

Answer:

here is your solution I hope it will help you

4 0
3 years ago
The total number of fruit she bought was less than 100. She bought more apples then pears. Write a system of inequalities that d
morpeh [17]
Let A be the number of apples bought
Let B be the number of pears bought

A+B<100
A>B
3 0
3 years ago
Nicholas sent a chain letter to his friends, asking them to forward the letter to more friends. Every 121212 weeks, the number o
Genrish500 [490]

Answer:

Since the question is incomplete, see below for a fully understanding of this kind of questions.

Explanation:

The question is incomplete but you can set some assumptions and determine the function that model the situation.

The relevant data of the text are:

  • Every 12 weeks, the number of people who receive the email increases by and additional 99%

From that you can:

  • determine the growing factor
  • determine the function P, which depends of the amount of time t (weeks) and models the function
<h2 /><h2>Solution</h2>

You can build a table or write a sequence to help you to figure out what is going on:

First, you need to know the number of friens to whom NIcholas initially sent the chain letter. You must assume a number. Assuming Nicholas initially sent the chain letter to 10 frirends, this would be the table:

t (weeks)       P(t)

0                    10

12                   10 + 99% of 10 = 10 + 0.99× 10 = 10 (1.99)

24                   10(1.99)(1.99) = 10 (1.99)²   ↔ two times 12 weeks

36                   10(1.99)³                             ↔ three times 12 weeks

This is every 12 weeks the number of people who recieve the email is multiplied by 1.99.

That means that the grow factor is 1.99 every 12 weeks, and the power of the exponential function is the number of 12 weeks elapsed, which is t divided by 12: t/12

           P(t)=10(1.99)^{(t/12)}

It is important that you realize that t/12 means the number of times that 12 weeks elapse.

6 0
3 years ago
Other questions:
  • To calculate the tax charged on an item you multiply the original price by the rate if the tax rate is 9.2% and a latter costs 5
    5·1 answer
  • A store sells cans of tomatoes priced as shown.
    7·1 answer
  • Three less than a number x is more than 15
    7·1 answer
  • Scott used 1 3 tablespoons of salt to make 1 4 liters of beans. If Scott's recipe is for 1 liter of beans, how much salt will he
    12·2 answers
  • Look at the picture please
    11·2 answers
  • Is -6.743743… a rational or irrational number?
    8·1 answer
  • Mahmoud is working out the height, h metres, of a tower
    12·1 answer
  • Consider the following equations:
    10·2 answers
  • Help pls I’ll make you brainliest if u get it right
    12·1 answer
  • What is 1.95 times 11
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!