Tutorial
Find the questions along with the submission dates
Last updated
Find the questions along with the submission dates
Last updated
List the following functions according to their order of growth from the lowest to the highest: , , , , , ,
Find whether the following assertions are correct:
Given two n*n matrices A and B, write down the algorithm for computing the matrix multiplication and compute its efficiency using a formal analysis framework.
What will be the time complexity of the following code segment:
5. Consider the following algorithm
What does this algorithm compute?
What is its basic operation?
How many times is the basic operation executed?
What is the efficiency class of this algorithm?
Suggest an improvement, or a better algorithm altogether, and indicate its efficiency class. If you cannot do it, try to prove that, in fact, it cannot be done.
Can master theorem be used for recurrence relation which takes poly-logarithmic number of basic operations ? [ Extended version of masters theorem ]
Define the following terms and relate them to the interval scheduling problem feasible solution optimal solution objective criterion greedy strategy proposition used to verify the correctness
Differentiate global and local optimal solution
Identify the optimal substructure for the coin change problem. Write pseudocode of the greedy algorithm for the change-making problem, with an amount n and coin denominations d1 > d2 > ... > dm as its input. What is the time efficiency class of your algorithm?
You are planning to rob banks. All banks are arranged in a circular manner. Which means, the first and last banks are neighbor to each other. Each bank has a certain amount of money stashed. Adjacent banks have a security system connected which will automatically contact the police if two adjacent banks were broken into on the same day, which is the only constraint stopping you from robbing each of them. Given a list of non-negative integers representing the amount of money of each bank, determine the maximum amount of money you can rob tonight without alerting the police. Return -1 when no banks are there. If array: [1, 2, 3] then output is 3, You cannot rob the first bank (money = 1) and then rob the last bank (money = 3), because they are adjacent banks. So here, you can rob any one bank. So the maximum possible money you can rob is from the last bank.
You work as a freelancer and have a pool of 10 projects to work on. For each project you know how much money you will get for completing the project. You can complete any 3 projects this month. You want to select such projects that you will get the most money by completing them. What are the safe moves in this problem? [ Identify the strategy which helps in obtaining global optimal] (a) If there are more than 3 projects in the pool, remove the project with the lowest payment for completion, don't work on this project. In the other case, remove the first project from the pool and work on this project. (b) Take the project which you like the most. (c) Take the project for which you can apply the cool new technology that you've recently learned about. (d) Take the project with the highest payment for completion, complete it and remove it from the pool of projects.
You are going to travel to another city that is located 𝑑 miles away from your home city. Your car can travel at most 𝑚 miles on a full tank and you start with a full tank. Along your way, there are gas stations at distances stop1 stop2 . . . ,stopN from your home city. What is the minimum number of refills needed?
Provide a greedy approach for finding the minimum number of refills.
Minimum number of platforms: Given the arrival and departure times of all trains that reach a railway station, the task is to find the minimum number of platforms required for the railway station so that no train waits. This problem is known as Interval Partitioning (Scheduling all the intervals with minimum number of resources). Use a greedy approach to solve the problem.
Given an array of integers where each element represents the max number of steps that can be made forward from that element. Find the minimum number of jumps required to reach the end of the array? Example:
What is the optimal substructure for the problem? Like in Longest increasing subsequence(LIS), the input array must be processed in order from left to right. 2. Write a recursive procedure for LIS problem using Dynamic Programming. Also, Enhance the solution using the concept of memoization. 3. What will be the time complexity of the recursive version proposed for ques (2) with and without memoization?
Find the time complexity of following recurrence relation using forward substitution: ;
Solve recurrence
Use Master theorem to solve the following recurrence relation. (Indicate the case and the solution) For all the cases, consider a) b) c) d) e)
Draw the recursion tree and derive cost for recurrence
Job scheduling Consider the problem of scheduling n jobs of known durations for execution by a single processor. The jobs can be executed in any order, one job at a time. You want to find a schedule that minimizes the total time spent by all the jobs in the system. (The time spent by one job in the system is the sum of the time spent by this job in waiting plus the time spent on its execution.) Design a greedy algorithm for this problem. Does the greedy algorithm always yield an optimal solution?