M
M
mihailos2020-08-22 13:00:07
C++ / C#
mihailos, 2020-08-22 13:00:07

How to use the code from Antti Laaksonen's book?

I am studying A. Laaksonen's book "Olympiad Programming". There's a problem about generating subsets, and the following algorithm is given:

The function manipulates a vector subset that contains the elements of the subset. To start the search, we call the function with parameter 1.

void search(int k){
if (k == n + 1){
    //обработать подмножество
} else{
    //включить k в подмножество
    subset.push_back(k);
    search(k+1);
    subset.pop_back();
    search(k+1);
    //не включить k в подмножество
}}


It is not clear to me how to use this code, I would like to see the whole file. And so I do not know how to apply this code to figure it out.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question