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
Usimov [2.4K]
4 years ago
8

Suppose that we have a set of activities to schedule among a large number of lecture halls, where any activity can take place in

any lecture hall. We wish to schedule all the activities using as few lecture halls as possible. Give an efficient greedy algorithm to determine which activity should use which lecture hall.
Computers and Technology
1 answer:
Burka [1]4 years ago
3 0

Answer:

By Using the Greedy- Activity- Selection algorithm

Explanation:

The Greedy- Activity- Selection algorithm in this case involves

First finding a maximum size set S1, of compatible activities from S for the first lecture hall.

Then using it again to find a maximum size set S2 of compatible activities from S - S1 for the second hall.

This is repeated till all the activities are assigned.

It requires θ(n2) time in its worse .

You might be interested in
Write a program that sorts an array of 10 integers using bubble sort. In the bubble sort algorithm, smaller values gradually “bu
blsea [12.9K]

Answer:

#include<iostream>

using namespace std;

int main(){

   //initialization

  int arr1[10] = {2,4,6,1,7,9,0,3,5,8};

  int temp;

   int size_arr;

   //nested for loop

  for(int i=0;i<size_arr-1;i++){

   for(int j=0;j<size_arr-i-1;j++){

       if(arr1[j]>arr1[j+1]){ //compare

               //swapping

           temp = arr1[j];

           arr1[j]=arr1[j+1];

           arr1[j+1]=temp;

       }

   }

  }

  //display the each element

  for(int i=0;i<10;i++){

   cout<<arr1[i]<<" ";

  }

    return 0;

}

Explanation:

Create the main function and declare the variable and defining the array with 10 values.

take the nested for loop, nested loop means loop inside another loop.

the outer loop traverse in the array from 0 to size-1.

and inside loop traverse from 0 to size -i-1, because for every cycle of the outer loop the one element is sorted at the end. so, we do not consider the element from the last for every cycle of the outer loop. That's why (size-i-1)

In the bubble sort, the first element compares with the second element and if the first id greater than the second then swap the value. so, for the above algorithm, we take the if statement and it checks the condition if the condition becomes true then the swap algorithm executes.

we take a third variable for swapping. after that, if the outer loop condition false it means all elements will traverse and then the loop will terminate.

and finally, take another for loop and display the output.

8 0
4 years ago
Which of the following Internet protocols is MOST important in reassembling packets and requesting missing packets to form compl
marishachu [46]

Answer:

A

Explanation:

TCP numbers the packets before sending them so that the receiver can correctly reorder the packets, and it can request missing packets be resent.

UDP- sends all the packets at once

IP- rules on the networks

HTTP- used for transmitting web pages over the Internet

4 0
4 years ago
Trevor is working with his data records for paydays. Some of the dates were left blank because of holidays. To find these record
ch4aika [34]

Answer:

Either leave it blank or type zero

Explanation:

8 0
3 years ago
Write a program that asks a user to roll a single die twice to get a sum value of 7. If the sum is 11, the user loses. If the su
barxatty [35]

Answer:

Check the explanation

Explanation:

#include <stdio.h>

int dice1;

int dice2;

int sum;

int roll_die_twice(int dice1,int dice2){

 

if(sum==7){

printf("winner");

 

}

else if (sum==11){

printf("looser");

}

else if (sum!=7 && sum!=11)

{

printf("nor winner or looser");

 

}

}

int main()

{

roll_die_twice(2,7);

return 0;

}

The code screenshot and code output can be seen in the attached image below.

6 0
3 years ago
Read 2 more answers
. Which of the following is a command in MySQL for creating a database called 'game_data'?
kozerog [31]

Answer:

The correct option for the following question is option(b) i.e CREATE DATABASE game_data;

Explanation:

The CREATE  command is used to create the database in MySQL .The syntax for creating a database is given as  

Create database database name ;

Here database name is game_data

So the query is CREATE DATABASE game_data;

Insert command is used for inserting the value into database not for creating the database .so option(a) is wrong .

MAKE and NEW  are not any command so these both the option are wrong.

Therefore the correct answer is option(b);

5 0
3 years ago
Other questions:
  • Yet another variation: A better packet switched network employs the concept of acknowledgment. When the end user’s device receiv
    11·1 answer
  • What are the major features of a successful ethics training program and communication systems? Think of an example of a company
    13·1 answer
  • Select the correct text in the passage.
    5·1 answer
  • How does machine learning help to make modern Web Application Firewalls more effective? (Choose two.)
    5·1 answer
  • 2.24 Write the relevant Python expression or statement, involving a list of numbers lst and using list operators and methods for
    11·1 answer
  • Order the following routine maintenance tasks from most to least important when securing a computer. a. Verify anti-malware sett
    15·1 answer
  • Return the "centered" average of an array of ints, which we'll say is the mean average of the values, except ignoring the larges
    6·1 answer
  • What is a career pathway for ctso
    6·2 answers
  • Which of the following is not a key component of a structure?
    5·1 answer
  • Create a timeline of the evolution of computers and their impact on society
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!