Question 1 (1 point) You have 9 tasks you would like to complete, and each task
ID: 3711072 • Letter: Q
Question
Question 1 (1 point) You have 9 tasks you would like to complete, and each task takes 1 hour to complete. You also have a deadline you must complete the tasks by, otherwise you will not get paid for the task. The tasks are lists below by Task Number, Amount of Pay you will get for completing, and Deadline for the task. Task 1, $15, hour 7 Task 2, $20, hour 2 Task 4, $30, hour 5 Task 4, $18, hour 3 Task 5, $18, hour 4 Task 6, $10, hour 5 Task 7, $23, hour 2 Task 8, $16, hour 7 Task 9, $25, hour 3 You can do the tasks in any order, what is the most money you can make? Save Question 2 (1 point) Mergesort is an example of which type of algorithmic approach. 1) Dynamic Programming 2) Greedy Method 3) Divide and Conquer 4) Backtracking SaveExplanation / Answer
1) In this problem we have to maximize our earnings,we need to see when 2 of the task are clashing and which one to pick.We will go with greedy approach.
Pick-up task number 7,2,9,5,3,8,1.Adding there values we will get 147.
So,answer is 147.
2)Merge sort algorithm follows Divide and conquer technique.It breaks the array from middle until only single element is left.Than it combines and last step is conqering by merging the list into one.
3)Floyd-warshall algorithm follows Dynamic programming approach.It compares all the possible path of graphs and takes the minimum path from them.It satisfies the criteria of overlapping sub-problem and optimal substructure.
4) Fibonaaci numbers is like sum of previous two numers like 1,1,2,3,5,8,13,21,34...We observe that every 3rd number is even.BU Writing code and taking only even numbers we get our answer as 4613732.we have to go till 33rd number of the series.
5)Following is the code in c:
#include<stdio.h>
long int sum=0;
long int divide(int n)
{
for(int i=1;i<1000;i++)
{
if(i%3==0){
sum=sum+i;
// printf("%d ",i);
}
//sum=sum+i;
if(i%5==0)
sum=sum+i;
if(i%15==0)
sum=sum-i;
// printf("%ld ",sum);
}
return sum;
}
int main ()
{
printf("%ld", divide(1000));
return 0;
}
By running the program we will get our answer as 233168.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.