PE2 (AY22/23)
Last updated
Last updated
Questions:
Official Answers:
This is just a give-away question. Follow the instructions strictly will let you pass!
This can also be regarded as a give-away question. It just uses counting sort!
The key idea to solve this question is to draw a "tree", more details are discussed in Lab 09 - Backtracking.
But let's see how genius the answer is:
By overwriting the value of students[current]
, we are actually doing our "back-tracking"! And once we have reached the end element, we print out the whole array. And our main should look like below:
The idea of this problem you iterate through each pair in the network, if they are in contact, remove all their "cluster" contact by iterating through from 0 to n recursively.
Refer back to Lab 09 - Backtracking when doing the backtracking problems! Usually, an easier way to help you understand is to draw a "tree".
This question is a variant of , but the given solution provides a genius way to print out the result using array
This question seems to be a variant of , but actually it is a problem that tests your recursive thinking.