Design And analysis algorithm course
Remarks: In all the algorithms, always explain their correctness and analyze their com- plexity. The complexity should be as small as possible. A correct algorithm with large complexity, may not get full credit
Here, we will first sort the the cars in increasing order of their filling time.
After that, we will assign cars alternately to each pump.
//sorting
bubble_sort(s[],n)
{
for all elements of the s
if s[i]>s[i+1]
swap(s[i],s[i+1])
return
}
//now that we have sorted the cars in increasing order of their filling time, we can assign them alternatively to each pump
assign(s[],n)
{
for all element in s
if(i%2==0)
assign this car
pump 1
else
assign this car
pump 2
}
Sorting will take worst case time of O(n^2)
Assigning will take O(n) time
Design And analysis algorithm course Remarks: In all the algorithms, always explain their correctness and analyze...
Design And analysis algorithm
course .
Remarks: In all the
algorithms, always explain their correctness and analyze their com-
plexity. The complexity should be as small as possible. A correct
algorithm with large complexity, may not get full credit
Question 2: Give an algorithm that finds the maximum size subarray (the entries may not be contiguous) that forms an increasing sequence.
Remarks: In all the algorithms, always explain their correctness and analyze their complexity. The complexity should be as small as possible. A correct algorithm with large complexity, may not get full credit. Say that we are given a rooted tree so that any element in the tree has a profit. An independent set in the tree is a collection of vertices no two of which are a parent and a child. The goal is to find an independent set of...
Please explain
Remarks: In all algorithm, always prove why they work. ALWAYS, analyze the com- plexity of your algorithms. In all algorithms, always try to get the fastest possible. A correct algorithm with slow running time may not get full credit. In all data structures, try to minimize as much as possible the running time of any operation. . Question 4: 1. Say that we are given a mazimum flow in the network. Then the capacity of one of the...