PE2 (AY22/23)

Problems

Questions:

136KB
Open
Questions

Official Answers:

Official Answers

This is just a give-away question. Follow the instructions strictly will let you pass!

2. Missing

This can also be regarded as a give-away question. It just uses counting sort!

3. Group*

This question is a variant of 5. Stone, but the given solution provides a genius way to print out the result using array

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:

4. Cluster*

This question seems to be a variant of Ex5 Q6 Social, but actually it is a problem that tests your recursive thinking.

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.

Tips

  1. Refer back to Lab 09 - Backtracking when doing the backtracking problems! Usually, an easier way to help you understand is to draw a "tree".

Last updated