Getting Started with Competitive Programming this course is designed in a way to provide students a real-world analysis of competitive programming, the techniques and implementations are in a way that can be understood by beginner students but students has knowledge of any programming language.
Getting Started with Competitive Programming is a MOOC course offered by IIT Gandhinagar on the NPTEL platform. The course is developed by Prof. Neeldhara is an Assistant Professor of Computer Science and Engineering at the Indian Institute of Technology, Gandhinagar. Her primary research interest involves the design and analysis of efficient algorithms for “hard” problems in general, and parameterized algorithms in particular.
- INTENDED AUDIENCE: Final Year Undergraduates
- Requirements/Prerequisites: Knowledge of basic data science algorithms
- INDUSTRY SUPPORT: All industry.
CRITERIA TO GET A CERTIFICATE
Average assignment score = 25% of the average of the best 8 assignments out of the total 12 assignments given in the course.
Exam score = 75% of the proctored certification exam score out of 100 Final score = Average assignment score + Exam score
Students will be eligible for CERTIFICATE ONLY IF AVERAGE ASSIGNMENT SCORE >=10/25 AND EXAM SCORE >= 30/75. If any of the 2 criteria are not met, the student will not get the certificate even if the Final score >= 40/100.
Getting Started with Competitive Programming ASSIGNMENT WEEK 6 ANSWERS:-
Q1. Suppose you have a simple, undirected, edge-weighted graph G and you have computed the shortest path between a pair of vertices u and v. After which of the changes to the edge weights described below will the shortest path not change?
Q2. Compute the sequence of vertices visited by a run of Dijkstra starting at vertex S on the following graph. What is the last vertex visited?
Q3. Consider the following building layout with k = 3:
Determine the time steps taken by our hero to get over the towers safely.
Q4. We can model the towers and windows as a graph consisting of every meter step as a node and edges representing the jumps/climbs, Spiderman can perform from one step to another. What strategy could be used to solve for the number of time steps required by Spiderman to escape the towers.
Q5. To support Sandman, Aquaman comes to his help. He uses his powers to increase the water level and tries to make the climb tough for Spiderman. At the time step i, the towers get covered with water upto i meters. Spiderman cannot go to areas currently underwater. At the beginning, the water level is at the bottom of the first area.
Q6. For the houses present at the locations marked by the blue circles:
Q7. Suggest an optimal method to figure out the number of places for any given configuration of houses.
Q8. Suppose you have n=2 and f(0)=0,f(1)=2, and f(2)=1; and further g(0)=1,g(1)=0, and g(2)=2. Is there any graph G that is feasible with respect to this information?
Q9. For any two vertices a and b, when can you say that the edge (a,b) does NOT belong to the graph G?
Q10. Let H be some graph consistent with the information in g and h and all other properties given above. For any two vertices a and b, if and there is no edge (a,b) in the graph H, then the graph H with the edge (a,b) added is also a valid solution if:
Getting Started with Competitive Programming ASSIGNMENT WEEK 4 ANSWERS:-
Q1. Consider a situation with three distinct sets X, Y, and Z with leaders x, y, and z. If z is enemies with x and y, have all the friendships been accounted for?
Q2. Suppose x and y are enemies and we are asked to make enemies between a and b, where a belongs to the same set as x and b belongs to the same set as y. Is this a contradiction?
Q3. Suppose x and y are enemies and we are asked to make enemies between a and b, where a belongs to the same set as x and b belongs to the same set as y. Is this a contradiction?
Q4. Suppose you have a DSU data structure that has already been created. There are a total of N vertices in the entire data structure. You have to process M queries of the FIND type and none of UNION. What is the worst case time complexity for this with Path Compression?
Q5. Suppose you have a DSU data structure consisting of two trees T1 and T2, of max depths (longest path from root to a child in the tree) k1 and k2 respectively. You now perform a UNION operation between vertices v1 at depth d1 from T1 and v2 at depth d2 from T2. What is the minimum depth of the newly formed tree that you can guarantee?
Q6. Suppose you have a set of N people who all do not know each other, and you have to process a sequence of queries of the following kinds:
Q7. Suppose you have a set of N people who all do not know each other, and you have to process a sequence of queries of the following kinds:
Q8. On the ith day you wonder how the message find it could be sent economically? What strategy should you use?
Q9. On the jth day, you discover that the words find and discover have the same meaning. However, you take a look at your DSU data structure and find that they are part of two different trees. How do you modify your DSU data structure on the jth day?
Q10. At the end of the 7th day you decide that you need to urgently send the message Find me I is lost. So far, you have learnt that the following words mean the same, in your given language:
Getting Started with Competitive Programming ASSIGNMENT WEEK 3 ANSWERS:-
Q1. It’s festive season and you want to give away some gifts over n days. At first, you have nothing. On the i-th day, ai gifts are delivered by Amazon. You can give away at most 8 of these gifts and keep the remaining to give away later. What is the minimum day index at the end of which you would have given away k gifts? The days are indexed from 1 to n. For example, if n=3, k=17, and a1=a2=a3=10, then the answer is 3. If n=1, k=10 but ai=9, then you won’t be able to give away a total of k gifts over n days, and in this case the answer can be given as −1.
Suppose k is 167 and n is 99, with the ai‘s given by:
Q2. How many bridges need to be destroyed in the example given at the following URL?
NOTE:- THESE MAY BE INCORRECT PLEASE DON’T FOLLOW BLINDLY IF YOU THINK YOU KNOW RIGHT ANSWER FEEL FREE TO CORRECT US SHARE YOUR ANSWER ON TELEGRAM.
Q3. What is the relationship between:
x = maximum # of disjoint requests, and
y = minimum # of bridges that need to be destroyed to serve all requests?
Infer as much as you can
Q4. Consider the following strategies to solve this problem.
Q5. For each dragon head d, how much time does it take to find the knight with the shortest height that is at least as tall as d? Assume that the knights are sorted according to their height.
Q6. For each dragon head d, how much time does it take to find the knight with the shortest height that is at least as tall as d? Assume that the heights of the knights are stored in a C++multiset.
Q7. Suppose we are using approach (C) from above on an instance where n and m can be as large as 105. If we use a linear search to find a suitable knight for each dragon head, and the time limit on the judge is two seconds, what response are we likely to get?
Note:- WE NEVER PROMOTE COPYING AND We do not claim 100% surety of answers, these answers are based on our sole knowledge and by posting these answers we are just trying to help students to reference, so we urge do you assignment on your own.
Q8. In a stable marriage instance, if a man M and woman W each put each other at the top of their respective preference lists, then M must be paired with W in every stable matching.
Q9. In every instance of the Stable Matching Problem, there is a stable matching containing a pair (M, W) such that M and W are each others’ favorites – in other words, M is ranked first on the preference list of W and W is ranked first on the preference list of M.
Q10. Suppose that all of the men rank the women in the same order, and all of the women also rank the men in the same order. Then, there is exactly one stable matching.
Getting Started with Competitive Programming ASSIGNMENT WEEK 2 ANSWERS:-
Q1. Consider the problem of sorting the array [2,3,4,5,6,1], calculate the number of passes required by bubble sort to sort the given array. Ignore any extra passes which do not alter the array.
Answer:- b – 5
Q2. Again, consider the above problem, however now calculate the number of passes required by cocktail sort to sort the given array. Ignore any extra passes which do not alter the array.
Answer:- a – 2
Q3. Statement A: There exists an array on which bubble sort takes O(n) time but cocktail sort takes O(n2).
Statement B: There exists an array on which cocktail sort takes O(n) time but bubble sort takes O(n2).
Answer:- a – Both statements are true.
Q4. What is the worst case time complexity for cocktail sort?
Answer:- c- O(n2)
Q5. Suppose we know that the given key is greater than some matrix element, A[i][j]. Choose the correct set of regions of the given figure, where the key could lie in.
Answer:- a – 4
For Programming Assignment:- Getting Started with Competitive Programming
Q6. By expanding on the idea from above, figure out a Divide and Conquer algorithm to solve this problem – Given a key, determine if it is present
in a matrix whose each row and column is sorted in increasing order. Now, find the time complexity of this algorithm.
Answer:- d – O(n1.58)
Q7. Let’s start with solving one more example to build up the intuition of the algorithm to solve this problem. So, if the given map
given = [12, 33, 2, 34, 8, 54, 85, 43, 67] and it’s said that the transmission range is 19, then, how many radio transmitters will be needed?
Answer:- b – 3
Q8. Consider the following approaches and choose the optimal answer, which will give us the minimum number of radio transmission towers needed to cover the city.
Q9. So up till now, you might have established that a transmission tower can cover a range of 2k, k on the left and k on the right. Look up the following piece of code and conclude if it’ll work or not.
Q10. Based on the discussion up till now, can you come up with the optimum time complexity of the algorithm required to solve this problem?
Getting Started with Competitive Programming ASSIGNMENT WEEK 1 ANSWERS:-
Q1. What is the cost of reversorting an array of numbers in descending order, i.e, the reverse of the desired sorted order? For example, the cost of reversorting the array [7,6,5,4,3,2,1] is 12. Let N denote the length of the array, and assume that N>1.
Answer:- D – 2N−2
Q2. For which of the following combinations of values of C and N can we design an array of length N that has cost C ?
Q3. Which of the following arrays are MGOOD?
Q4. If the product of all the elements in a given array is not a perfect square, the array is necessarily MGOOD.
Q5. If the product of all the elements in a given array is a perfect square, the array is necessarily not MGOOD.
Q6. Given an array a such that it is not SGOOD. What could the possible strategies to make this array SGOOD. You are allowed to remove some elements from the array. Specifically, you are expected to give the indices of the elements you will remove to make the array SGOOD.
Q7. We can add a prime number as one of the N numbers.
Q8. Consider a number of the form where each pi is a distinct prime number. What is the minimum value of k for which we may enter a valid x? Note that a “valid x” is any one of the N numbers that together satisfy the above two conditions.
Answer:- C – N – 1
Q9. Let p1,p2,…,pN be the first N prime numbers. Which of the following strategies would work (N≥3)?
Q10. There are n pairs of old shoes that have been been kept in a straight line in your cupboard, in other words, there are 2n shoes altogether.You want to give them all away, but because you are superstitious, you will give away a pair only if both shoes are next to each other. It doesn’t matter what the order between them is (the left shoe could be next to the right one or the other way round). You can take one of two possible actions:
Answer:- B – N +2K
Also check :- Internship oppurtinites
Note:- We do not claim 100% surety of answers, these answers are based on our sole knowledge and by posting these answers we are just trying to help students, so we urge do you assignment own your own.