in Informatics
Olympiads
Olympiads
in
Informatics
in Informatics
Volume 10,
2016
Volume
10,
2016
3
19
39
61
73
87
J. HROMKOVI. Homo Informaticus Why Computer Science Fundamentals are an Unavoidable Part of Human Culture and How to Teach Them
99
111
125
161
177
195
207
223
T. VERHOEFF. Problem Solving, Presenting, and Programming: A Matter of Giving and Taking
231
REPORTS
M. DOLINSKY. Gomel Training School for Olympiads in Informatics
237
V. DUMANYAN, A. ANDREASYAN.
Armenia: IOI Participation and National Olympiads in Informatics
249
255
263
A. KHUDER, D. TSEDEVSUREN. The Informatics Olympiad in Mongolia: Training Resources for nonEnglish Speaking Students
279
285
ISSN 18227732
ISSN 18227732
Olympiads in Informatics
10
IOI
Inter
n at i
nal
Olym
piad
in
Infor
ics
m at
ISSN 18227732
INTERNATIONAL OLYMPIAD IN INFORMATICS
VILNIUS UNIVERSITY
INSTITUTE OF MATHEMATICS AND INFORMATICS
OLYMPIADS IN INFORMATICS
Volume 10 2016
Selected papers of
the International Conference joint with
the XXVIII International Olympiad in Informatics
Kazan, Rusia, 1219 August, 2016
OLYMPIADS IN INFORMATICS
EditorinChief
Valentina Dagien
Vilnius University, Lithuania, valentina.dagiene@mii.vu.lt
Executive Editor
Richard Forster
British Informatics Olympiad, UK, forster@olympiad.org.uk
International Editorial Board
Benjamin Burton, University of Queensland, Australia, bab@maths.uq.edu.au
Michal Foriek, Comenius University, Bratislava, Slovakia, misof@ksp.sk
Gerald Futschek, Vienna University of Technology, Austria, futschek@ifs.tuwien.ac.at
Mile Jovanov, Sts. Cyril and Methodius University, Macedonia,
mile.jovanov@finki.ukim.mk
Marcin Kubica, Warsaw University, Poland, kubica@mimuw.edu.pl
Ville Leppnen, University of Turku, Finland, villelep@cs.utu.fi
Krassimir Manev, New Bulgarian University, Bulgaria, kmanev@nbu.bg
Seiichi Tani, Nihon University, Japan, tani.seiichi@nihonu.ac.jp
Peter Taylor, University of Canberra, Australia, pjt013@gmail.com
Troy Vasiga, University of Waterloo, Canada, tmjvasiga@cs.uwaterloo.ca
Peter Waker, International Qualification Alliance, South Africa,
waker@interware.co.za
Willem van der Vegt, Windesheim University for Applied Sciences, The Netherlands,
w.van.der.vegt@windesheim.nl
Foreword
Time flies like an arrow
A popular example from the world of Artificial Intelligence (and Computational Linguistics), the phrase Time flies like an arrow is used to illustrate the ambiguity of language and the difficulty in comprehending structure. As a metaphor, it expresses how
quickly time passes. Study the syntax and you can argue that its an instruction to record
the movement of flies (perhaps in the manner of an arrow, or only those that are similar
to arrows), a description as to the preferences of a breed of fly, etc. Some interpretations have meaning, others less so, but underlying this is the message that something
apparently straightforward can have multiple meanings, nuances, interpretations. An
unexpected depth of meaning within a simple form.
IO
IO Informatics Olympiads. For those of us involved with national and international
olympiads there are numerous reasons why we got involved. For some, it has been
the challenge of competing: an opportunity to flex the intellectual muscles, a delight
in problem solving or even the pleasure of pushing yourself against other similarly
minded individuals. For others, it is the academic pursuit as the olympiads provide a
mechanism for learning and teaching: a way to practice skills and infuse knowledge; a
way to demonstrate that knowledge, skill and application to the wider world. Perhaps
for others it is the sense of community: fellow students, fellow educators, competitors
and friends. All of this before we even ask the question as why we stay involved.
10
There are, so says the old joke, 10 types of people in the world those who understand
binary and those who do not. In our modern world it is increasingly important to be
amongst those who understand. If we go back to the first days of the IOI, computer science was still a specialist pursuit. We had had a decade of home computers, so computers were accessible to many, and computing was appearing school curricula, but unless
you took an interest your exposure could be fleeting. We now exist in a world where
people carry powerful computers in their pockets ask yourself how many of the competitors at this years IOI carry a phone but do not wear a watch. So many facets of daily
life aided by computer programs, a manyheaded beast that demands constantly to be
fed. It is not just teaching individuals how to program, most people will never write or
need to write a line of code, but an understanding of what is happening inside the black
box how things work, what is feasible, knowing what is going wrong to know how to
make things right is an important skill.
10
This is the 10th year for the Olympiads in Informatics journal. The first year when we
have publishing two volumes, as we are delighted to publish a special volume celebrating the informatics education of our host special thanks is given to the guest editor
Marina Tsvetkova. We have published a total of 185 papers showcasing 200 authors
from 50 countries. Technical papers and country reports. Algorithms and tasks. Reviews and opinions. The format of the journal is very similar to those early days; a
forum for those in the community to write about specialised technical issues, an opportunity to share our experiences and knowledge, and to give freedom for those who
are not academics to talk about their work. Looking back with the benefit of hindsight
we might have developed the journal in a different direction but, with that same knowledge, we can say that we have fulfilled (in the most part) the vision and aims that we
had when first establishing the conference.
Things are not always as they seem; it certainly does not seem like 10 years already.
Time flies like an arrow indeed.
There are individuals without whose tireless work this volume of the journal indeed every volume of the journal would not exist. As always, thanks are due to all
those who have assisted with the current volume authors, reviewers and editors. A lot
of work goes, not only to the writing of the papers, but to an extended period of review
and correction and, in several cases, translation. Peer viewing all of the papers takes a
significant amount of time and work and special thanks should be given to those otherwise unsung reviewing heroes: Benjamin Burton, Sbastien Combfis, Walter Gander, Gintautas Grigas, Mathias Hiron, Ville Leppnen, Pivi Kinnunen, Jari Koivisto,
Krassimir Manev, Martin Opmanis, Rein Prank, Jrat Skpien, Peter Taylor, Ahto
Truu, Willem van der Vegt. Particular thanks are due to the organisation committee for
IOI2016 in Russia without whose assistance we would be unable to hold the conference. Their assistance, during what is an already busy period, is gratefully received.
Editors
Abstract. It has been almost 50 years since the creation of Logo one of the first educational
programming languages. Although most people agreed that it was important to teach computational thinking to children, only recently have school and district leaders begun to adopt curricula
to include it mainly through Scratch. In many cases this adoption has failed to provide the right
methodologies and tools to teachers.
In this paper, we analyse some of the different languages used in classrooms today and we
propose an improved alternative that we have created eSeeCode. We also share our experiences
using this language in classrooms and how students can learn using this tool.
Keywords: informatics curriculum, promoting informatics, programming language.
1. Overview
Reading Paperts Mindstorms: Children, Computers, and great ideas, one can have the
feeling that we have not advanced much in the past 35 years (Papert, 1980). Many countries are trying to include Coding as a required skill to learn in schools, either as a specific subject or as part of a technology course. However, in many schools, teachers do
not have the resources, materials and/or knowledge to bring computer science and coding into the classroom. This is the case of Spain, among other countries, where computer
science has been introduced into the curriculum, but has failed to provide the details on
how to implement it properly, thus providing teachers the freedom and responsibility to
decide how to teach some basic computer science concepts (SaezLopez etal., 2016,
Ackovska etal., 2015, Duke etal., 2000).
In this paper, we will analyse several computer languages and materials, and we
will explain the difficulties students find when using them in class. As Edsger Dijkstra
explains, the selection of the programming language will influence how the students will
understand computer science (Dijkstra, 1999). We will base our examples on some of the
most popular computer languages used in Spain today, although this experience can be
extrapolated to many other countries.
Fig. 2. Visual coding example with EV3 to make a Lego Robot move in a square pattern.
you change the problem. The teacher acts as a problemsetter or planifier, deciding
which problems to be solved at each moment, such as when a student is asked to code
the Eratosthenes sieve.
As an alternative to problem solving we find Projectbased learning. In Spain, this
strategy is gaining increased attention in the school setting. As part of projectbased
learning, students take a more active and creative role by pursuing an authentic and realworld project that addresses essential questions and works towards gaining an enduring
understanding of a relevant issue. The teacher here is more of a guide or facilitator that
helps the student when needed. In computer science this has the form of software design,
applied programming and modelling. For example, a student could work on solving the
problem of being able to identify a number as prime or not, with the project title being
Create a game that uses prime numbers.
1.2. Languages
To help keep the explanation focused, we have created a list of the main languages used
in schools in Spain, and have classified them by similarity of characteristics.
The final result is shown below:
Under textbased coding we will find two separate groups: the pure educational languages such as Logo or Processing, and the professional languages such as C++, Java,
Python and Javascript.
Under visual block based coding we find again two groups: educational languages
such as Scratch, Alice, Kodu, Ev3, AppInventor, and the group of puzzle languages
such as Lightbot and Beebot. Strictly speaking, Lightbot and Beebot are not complete
languages, but they are used to teach basic structures to students. It is for this reason that
we have decided to include them in our analysis.
Although each language has its own particular characteristic, we will analyse a representative of each group. The languages we have chosen are: Logo, C++, Scratch and
Lightbot.
2. Main Characteristics
To be able to compare the different languages we have created a short introduction for
each one.
2.1. Logo
Originally created by Wally Feurzeig and Seymour Papert in 1967, there are many versions of the language used in schools. Its main objective was to teach programming to
students from ages five to thirteen (Papert, 1980). Due to the fact that it has been around
for so long, there has been more than 300 versions of the language, with a substantial
amount of literature related to it. (Boytchev, 2013).
Main characteristics:
Educational (ages 513).
The majority of versions use textcode.
The first activities proposed were problemsolving oriented, although there was
some space for creativity. This will vary with versions.
Uses a drawing area where you can move a pointer called a Turtle.
Main academic fields are basic algorithmics and 2D3D geometry depending on
the version.
In general there were no debuggers, but a stepbystep execution was possible
in many versions, which helped locate errors. Also syntax errors are difficult to
correct.
2.2. C++
Designed by Bjarne Stroustrup in 1983, C++ is a professional computer language utilized
heavily in many academic and professional circles. It is a compiled language, allowing
the user to be able to select a programming environment. Its standard library makes it
easier to use, as compared to its predecessor C (Stroustrup, 2007). It is important to note
that in this category that there are very different approaches depending on the paradigms
used (Duke etal., 2000), but we will not take them into consideration for the current
analysis and will common ground.
Main characteristics:
Professional (ages 12+)
C++ uses formal code.
The language accepts both problemsolving activities and projectoriented
learning.
No drawingarea. General interface uses a console to write and read (input/output). This can be extended to use of files.
Main academic fields are advanced algorithms, data structures, and numerical
problems. Uses of classes helps teach system design.
Depending on the Interface there is a good debugger, but syntax errors are hard
to read.
2.3. Scratch
Scratch was created in 2005 by Lifelong Kindergarten research group at Massachusetts
Institute of Technology Media Lab led by Mitchel Resnick. Although you can trace some
of its origins to Logo, its different approach to teaching computer science places it in a
different category (Resnick etal., 2009).
Main characteristics:
Educational (ages 816).
It uses visual block based programming.
The language is more focused on projectoriented programming.
There is a drawing area used to place objects and move them around.
Main academic fields cover basic algorithm, software design.
Due to the visual programming interface with blocks, it is impossible to get syntax
errors. There is no debugger.
2.4. Lightbot
There is an educational movement promoted by code.org to reach children in different
regions of the world and give them tutorials to learn how to code. This movement started
as the Hour of code and has had a big impact all around the world. Almost 200,000
events were carried out in more than 140 countries. (Code.org, 20132016)
Many schools around the world use this material as an introductory material for
Computer Science. Among the different tutorials that you can find, we selected one that
had a large acceptance rate in the teacher community in Spain Lightbot.
Lightbot is a puzzlebased game where you need to light some squares on a grid. It
was created in 2008 by Danny Yaroslavski, but it was with the hour of code that it became popular. (Gouws etal., 2014)
Main characteristics:
Educational (ages 48 and 9+).
It uses visual block based programming.
The language is focused only on puzzle solving.
It has nice animations of a robot moving around.
Main academic fields cover basic algorithms (no variables).
Impossible to get syntax errors, the execution can be considered stepbystep.
3. Developing a Curriculum
It is clear that these languages are difficult to compare to one another because of their
fundamental differences. To be able to do so we will analyse its uses in the classroom
and their main drawbacks if used alone. Later we will study the combination of one or
more language.
When considering the development of a curriculum we have to take into account
many factors, but mainly the maturity of the students (their age) and the amount of time
they will spend engaging with that curriculum. In our case we will consider students
from primary secondary schools, and a relatively long length of time of engagement
(34 years). Although some consider this length insufficient (Winslow, 1996), it is a
valid starting point to achieve competence in programming. Some main objectives can
be found in some studies (Duncan and Bell, 2015) and in some publications like the
Computing Progression Pathways (Dorling, 2014).
2010), but it is not included in the main tool. In addition, the high level language makes
the student miss the opportunity to understand what is behind some of the instructions.
Finally, as it can be seen in Fig. 4, Scratch allows some parallel programming, which
is actually not accurate as it is executed sequentially and depends on the order the procedures were created. This is a problem because the student cannot guess the results of a
given program, which is one of the main objectives when teaching CS. (Dorling, 2014)
For a long time the most popular educational programming language in Spain was Logo.
It was used in the 1980s through early 1990s, but its use faded away in the late 1990s. We
can see this, for example, because it disappeared from the teacher majors in universities.
There was not an immediate substitution by another language, but the government stopped
promoting it as it was not news. This is reflected, for instance, in the use of it when training
teachers at that time. (Simon, 1996) At the onset, students were motivated by this new approach to teaching and learning (Rubinstein, 1974), but today the look of a majority of the
Logo platforms appear outdated and need a visual update. There are two major drawbacks
to Logo. Its theoretical use was for students aged 513, with newer versions this could be
extended until age 15, but textbased coding may bring syntax errors, and students need
some maturity to be able to correct them. If not well attended students would get frustrated
with programs that could not run. At the same time, similarly to Scratch, it has a limited
life span in the student studies due to the apparent lack of practical utility.
The last group of languages to analyse is the professional ones. This are the most
common choice among high school students. The students see the real value of coding and can explore other areas such as physics and mathematics, but because it is not
prepared for the classroom the learning curve is very steep. Winslow describes the five
steps from novice to expert (Winslow, 1996), in smalltomedium classrooms, the steep
learning curve produces a clear and early separation between those who understand the
content (and move through Winslow learning steps) and those who do not and remain as
Novices. Another drawback is that due to the lack of visual assistance (in general) and
10
less attractive interface it is more difficult to motivate the students to use it. The syntax
of some functions can also be a problem for some students. For instance, the syntax of
the for loop is more complicated than in other languages, which makes basic algorithms
sometimes hard to teach (Finkel etal., 1994, Robins and Rountree, 2003). Depending
on the programming environment used, the syntax errors are very difficult to read to the
untrained eye, as can be seen in Fig. 5, where only a single character missing produces
20 lines of errors when compiling.
One big advantage is the amount of resources that can be found on the internet, in
particular online judges like Codeforces, Timus, Topcoder, etc. With this sort of information it is really easy to prepare lists of problems for the students to engage.
It is worth pointing out that, in general, all of these languages and platforms are
student focused. There are few tools for the teachers, and this makes using only one
language more difficult. There are some positive exceptions, like the case of Jutge.org.
(Jutge 20082016, Gimnez etal., 2012) This online automated judge has been prepared
as a tool for the classroom and not just for selflearning. Teachers can set up classes,
have their own sets of problems and can view students progress. This kind of platform
contributes to the gamification of learning computer science, by giving achievements,
keeping track of the number of problems solved, etc. When students perceive it as a
game, they become more motivated and less frustrated.
11
12
cover the basic movement of the guide, size of the drawing, colours and general positioning. Each time the student clicks one instruction the environment executes it directly.
The second view created is the Drag view. This view still uses icons as instructions
but the student can move them freely once placed in the coding area. These instructions
accept different arguments and the icons change to match the values of the parameters.
Some examples of this behaviour can be seen in Fig. 8. Notice that the icons also include
a name to help the student read the code. To execute a program the student needs to
click the run button.
The next view is the Build view, which is similar to the Drag view as the blocks can
be displaced around the code area freely. However these blocks dont include icons, just
the name of the instructions and the arguments. The student can read the code fully, but
to create it has to choose among a specific set available. This set is larger than the one
from the drag view and contains a greater variety of instructions. This list of instructions
allows the student to be able to explore eSeeCode by him/herselves, and provides the
student with the familiarization of the names without having to memorize the commands
and the arguments.
The last view is the Code view. In this level students can type their own code.
We created eSeeCode based on JavaScript (although this base is well hidden), so after mastering in the programming in Code view the students can program freely using this wellknown programming language. The platform accepts and executes any
JavaScript program allowing for a deeper learning. A side advantage to the use of
JavaScript is the fact that it is not required to be installed to function, as it will work
with any browser.
In the Code view syntax errors are possible, but we try to give short errors that the
student can correct. This can be seen in Fig. 9. The platform also has a debugger to be
used in case the students program does not execute as expected. When running a program, the editor will restyle the code to encourage students to use clean code.
In the context of the lowfloor, highceiling proposed by Papert (Papert, 1980) and
used by Resnick (Resnick etal., 2009), eSeeCode has a lowerfloor (easytouse) than
Logo and Scratch, and a much higher ceiling (being able to hold complex programs)
comparable to that of C++. The Touch view could be considered our lowfloor while the
Code view our highceiling.
Although you can try to create long programs, we have designed eSeeCode to be a
problemsolving tool and have provided it with an optional easytouse Input/Output
interface.
Fig. 8. The icons of the Drag view adapt depending on their parameters.
13
14
Scratch courses. This allowed the teachers to teach directly using Code view, but they
allowed the students to go back to the Build view to avoid the empty page difficulty
(Resnick et al., 2009), where the student doesnt know how to start because he is used to
having a set of blocks. With the introduction of eSeeCode the teachers had to review the
basic concepts of variables, conditionals, loops, etc. The methodology that was used was
based on Polya problemsolving principles, where the student should take the following
steps (Polya, 1945):
1. Understanding the problem i.e. Can you explain the problem with different words?
Can you create your own paper and pencil examples?
2. Devising a plan. In our case this is clearly the Algorithm. Some things to consider
when devising a plan are to try to find previous, similar problems.
3. Carrying out the plan. This is the implementation of the algorithm. We propose
the baby steps methodology, where you write the code stepbystep and execute
along to avoid syntax errors, while making sure everything goes accordingly to the
plan.
4. Looking Back. Although no judge system has been created, the student should
analyse if s/he obtained the desired result, going back to previous steps if s/he did
not.
Although this experience is different than the experiment done by Lewis in a study to
compare Scratch vs Logo (Lewis, 2010), a similar survey was created and it was taken
by 59 of the students in the course. The survey consisted of 16 questions each being a
4level Likert scale.
As it can be seen in Fig. 10 it seems that Scratch is easier to program, but in fact
the total number of students that have a positive feedback (Strongly agree and Agree)
Fig. 10. Students responses to a 4level likert test about the use of Scratch and eSeeCode in class.
15
is larger in the case of eSeeCode. One of the difficulties to analyse this question is the
fact that the problems that the students had to solve in the two languages are different.
What is interesting is that students would recommend in general to use eSeeCode to
teach programming, this might have similar reasons to what Lewis describes (Lewis,
2010), as the students feel more selfsecure when typing their own code, and might see
Scratch as something different than programming. This would be interesting to analyze
in a future study.
When asking questions about the difficulties when learning the language, we encounter different opinions depending on the topic. In Fig. 11 we can see this results.
Similar to what happened when asking about writing a program the opinion of the
students is less strong with eSeeCode than with Scratch, although the numbers of positive vs negative are similar. We have to take into account that the view students were
using more is the Code view, which makes it difficult to give a precise analysis of the
situation.
Fig. 11. Student responses to a 4level likert test about the difficulties when learning with
Scratch and eSeeCode.
16
What might be interesting is that the students opinion about the difficulties of the
concept of repeat is statistically independent of the language (a Fisher exact test gives
us a pvalue of 0.3401 which tells us that the groups are not significantly different) This
can be because the repeat concept is very easy to understand by the students.
Another experience we want to share is our own version of hour of code (Fig. 12)
where students had to make programs to draw some typical optical illusions. Placing
this activity in the context of students having an enjoyable time seemed to motivate
the students to complete the tutorials and to try to draw their own images. Some of the
activities were designed to be more difficult than the level of knowledge the students
possessed and were accompanied with a solution code. The students would read the
code and try to figure out the expected result. Although some students were not able to
complete the activity, most of them enjoyed it. Another experiment we conducted was
to give students the partial code for the program. In this activity we eliminated all the
numbers from the code. The student was required to fill the gaps, until the right image
would appear. Very few students would try numbers at random, the majority would
first try to understand what the code did, and place the right numbers directly.
Three different sets of students tried the platform with this activity: Students that had
never programmed before, students that had been introduced to Scratch and students that
already knew Logo and C++. The difficulties found were similar in each group, concluding that it adapts to the students needs.
17
5. Conclusions
The time has come for teachers in Spain to take on the responsibility of curriculum
development. This responsibility will come first by understanding the different options
there exist, understanding the previous objectives, the ones we want to have in their
place, and taking on a global vision. Right now one language cannot satisfy all the learning process. It is also valuable for the students to know more than one language, which
would provide the option of overcoming the inherent weaknesses of each one.
eSeeCode tries to provide a new platform to overcome the main weaknesses found,
but we believe it does not need to be a replacement but rather a complement to the learning process. The trials so far show that it is a viable language to take into the classroom,
and that the students show a good overall satisfaction with it.
6. References
Ackovska, N., Erdsn NMeth, ., Stankov, E., Jovanov, M. (2015). Report of the IOI Workshop Creating an
International Informatics Curriculum for Primary and High School Education. Olympiads in Informatics,
9, 205212.
Boytchev, P. (2014). Logo Tree Project. http://www.elica.net/download/papers/LogoTreeProject.pdf
Code.org (2013). http://www.code.org
Dijkstra, E. (1999). Computing Science: achievements and challenges. ACM SIGAPP Applied Computing, 7(2),
29.
Dorling, M. (2014). Computer progression pathways. Computing at Schools.
http://www.computingatschool.org.uk
Dorling, M., White, D. (2015). Scratch: a way to Logo and Python. In: SIGCSE 15: Proceedings of the 46th
ACM Technical Symposium on Computer Science Education.
Duncan, C., Bell, T. (2015). A pilot computer science and programming course for primary schools. In: Proceeding WiPSCE 15 Proceedings of the Workshop in Primary and Secondary Computing Education. 3948.
Duke, R., Salzman, E., Burmeister, J., Poon, J., Murray, L. (2000). Teaching programming to beginners
choosing the language is just the first step. In: ACSE 00: Proceedings of the Australasian conference on
Computing education.
eSeeCode (20152016). http://www.eseecode.com
Finkel, D., Hooker C., Salvidio, S., Sullivan, M., Thomas C. (1994). Teaching C++ to high school students. In:
18
SIGCSE 94: Proceedings of the twentyfifth SIGCSE symposium on Computer science education.
FMSLogo (20062016). http://fmslogo.sourceforge.net/
Gimnez, O., Petit, J., Roura, S. (2012). Jutge.org: an educational programming judge. In: Proc. of the 43rd
ACM Technical Symposium on Computer Science Education (SIGCSE2012). 445450.
Gouws, L.A., Bradshaw, K., Wentworth, P. (2013). Computational thinking in educational activities: an evaluation of the educational game Lightbot. In: ITiCSE 13: Proceedings of the 18th ACM conference on Innovation and technology in computer science education.
Harvey, B., Mnig, J., (2010) Bringing No Ceiling to Scratch: can one language serve kids and computer
scientists? Constructionism 2010, Paris. http://www.eecs.berkeley.edu/~bh/BYOB.pdf
Jutge.org (2012). http://www.jutge.org
Lewis C. (2010). How programming environment shapes perception, learning and goals: logo vs. Scratch. In:
SIGCSE 10: Proceedings of the 41st ACM technical symposium on Computer science education. 346350.
LightBot (2016). http://www.lightbot.com
Papert, S. (1980). Mindstorms: Children, Computers and Powerful Ideas. Basic Books. Inc. USA.
Polya, G. (1945). How to solve it. Princeton University Press, USA.
Resnick, M., Maloney, J., MonroyHernndez, A., Rusk, A., Eastmond, E., Brennan, K., Millner, A., Rosenbaum, E., Silver, J., Silverman, B., Kafai, Y. (2009). Scratch: programming for all. Communications of the
ACM, 52(11).
Robins, A., Rountree, N. (2003). Learning and teaching programming: a review and discussion. Journal Computer Science Educations, 13(2), 137172.
Rubinstein, R. (1974). Using Logo in teaching. ACM SIGCUE Outlook, 9(SI).
SaezLopez, J.M., RomanGonzalez, M., VazquezCano, E., (2016). Visual programming languages integrated
across the curriculum in elementary school: a two year case study using Scratch in five schools. Elsevier
computers & Education, 97, 129141.
Scratch (20132016). https://scratch.mit.edu
Simon, J. (1996). Levoluci de lensenyament del llenguatge logo a lescola de mestres Blanquerna 10 anys.
VI Seminari Logo Terrassa, Spain.
Stroustrup, B. (2007). Evolving a language in and for the real world: C++ 19912006. In: HOPL III: Proceedings of the Third ACM SIGPLAN Conference on History of Programming Languages. ACM.
Winslow, L. (1996). Programming pedagogy a psychological overview. ACM SIGCSE Bulletin, 28(3).
J. Alemany Flos holds a degree in mathematics and is currently completing a Masters Degree in Advanced Mathematics and Mathematical Engineering. He is a former high school teacher, who now designs
and helps develop programming curricula in schools as a consultant.
He has been involved with the National Informatics Olympiad for the
last eight years, also attending the International Olympiad in Informatics as a team leader and deputy leader since 2010.
J. Vilella Vilahur holds a degree in Computer Science and has been
teaching programming and robotics for the last ten years at Aula Escola
Europea where he also provides the IT support. He has been involved
in several open source projects and has been the lead programmer in
eSeeCode.
19
Abstract. The wavelet tree is a data structure to succinctly represent sequences of elements over
a fixed but potentially large alphabet. It is a very versatile data structure which exhibits interesting properties even when its compression capabilities are not considered, efficiently supporting
several queries. Although the wavelet tree was proposed more than a decade ago, it has not yet
been widely used by the competitive programming community. This paper tries to fill the gap
by showing how this data structure can be used in classical competitive programming problems,
discussing some implementation details, and presenting a performance analysis focused in a
competitive programming setting.
Key words: wavelet tree, data structures, competitive programming, quantile query, range query.
1. Introduction
Let = (1 ) be a sequence of integers and consider the following query over .
Query 1. Given a pair of indices ( ) and a positive integer , compute the value of the
th smallest element in the sequence ( +1 ).
Notice that Query 1 essentially asks for the value of the element that would occupy
the th position when we sort the sequence ( +1 ). For example, for the sequence = (3 7 5 2 3 2 9 3 5) and the query having ( ) = (3 7) and = 4,
the answer would be 5, as if we order sequence (3 4 5 6 7) = (5 2 3 2 9) we
would obtain (2 2 3 5 9) and the fourth element in this sequence is 5. Consider now
the following update query.
Query 2. Given an index , swap the elements at positions and + 1.
That is, if = (3 7 5 2 3 2 9 3 5) and we apply Query 2 with index 5, we
would obtain the sequence 0 = (3 7 5 2 2 3 9 3 5).
Consider now a competitive programming setting in which an initial sequence of
6
10 elements with integer values in the range [ 109 109] is given as input. Assume that
20
R. Castro et al.
a sequence of 105 queries, each query of either type 1 or type 2, is also given as input.
The task is to report the answer of all the queries of type 1 considering the applications
of all the update queries, every query in the same order in which they appear in the
input. The wavelet tree (Grossi, 2015) is a data structure that can be used to trivially
solve this task within typical time and memory limits encountered in programming
competitions.
The wavelet tree was initially proposed to succinctly represent sequences while still
being able to answer several different queries over this succinct representation (Grossi
etal., 2003; Navarro, 2014; Grossi, 2015). Even when its compression capabilities are
not considered, the wavelet tree is a very versatile data structure. One of the main features is that it can handle sequences of elements over a fixed but potentially large alphabet; after an initial preprocessing, the most typical queries (as Query 1 above) can be
answered in time (log), where is the size of the underlying alphabet. The preprocessing phase usually constructs a structure of size ( log) for an input sequence
of elements, where is a factor that will depend on what additional data structures
we use over the classical wavelet tree construction when solving a specific task.
Although it was proposed more than a decade ago (Grossi etal., 2003), the wavelet tree has not yet been widely used by the competitive programming community.
We conducted a social experiment publishing a slightly modified version of Query 1
in a well known OnlineJudge system. We received several submissions from experienced competitive programmers but none of them used a wavelet tree implementation
to solve the task. This paper tries to fill the gap by showing how this structure can be
used in classical (and no so classical) competitive programming tasks. As we will show,
its good performance to handle big alphabets, the simplicity of its implementation, plus
the fact that it can be smoothly composed with other typical data structures used in
competitive programming, give the wavelet tree a considerable advantage over other
structures.
Navarro (2014) presents an excellent survey of this data structure showing the most
important practical and theoretical results in the literature plus applications in a myriad
of cases, well beyond the one discussed in this paper. In contrast to Navarros survey,
our focus is less on the properties of the structure in general, and more on its practical
applications, some adaptations, and also implementation targeting specifically the issues
encountered in programming competitions. Nevertheless, we urge the reader wanting to
master wavelet trees to carefully read the work by Navarro (2014).
21
form the leftchild subsequence; all the elements whose values belong to form the
rightchild subsequence. The process continues recursively until a leaf is reached; a leaf
corresponds to a subsequence in which all elements have the same value, and thus no
partition can be performed.
Fig. 1 shows a wavelet tree constructed from the sequence
= (3 3 9 1 2 1 7 6 4 8 9 4 3 7 5 9 2 7 3 5 1 3)
We split values in the first level into sets = f1 4g and = f5 9g.
Thus the leftchild of is associated to 0 = (3 3 1 2 1 4 4 3 2 3 1 3) If we
continue with the process from this node, we can split the values into 0 = f1 2g and
0 = f3 4g. In this case we obtain as right child a node associated with the sequence
00 = (3 3 4 4 3 3 3). Continuing from 00, if we split the values again (into sets
f3g and f4g), we obtain the subsequence (3 3 3 3 3) as left child and (4 4) as right
child, and the process stops.
For simplicity in the exposition, given a wavelet tree we will usually talk about
nodes in to denote, interchangeably, the actual nodes that form the tree and the subsequences associated to those nodes. Given a node in , we denote by Left() its
leftchild and by Right() its rightchild in . The alphabet of the tree is the set of
different values that its root contains. We usually assume that the alphabet of a tree is a
set = f1 2 g. Without loss of generality, and in order to simplify the partition
process, we will assume that every node in has an associated value m() such that
Left() contains the subsequence of composed of all elements of with values
m(), and Right() the subsequence of composed of all elements with values
m(). (In Fig. 1 the value m() is depicted under every node.) We can also associate to every node in , two values l() and r(), such that corresponds to
the subsequence of the root of containing all the elements whose values are in the
range [l() r()]. Notice that a wavelet tree with alphabet f1 g has exactly
leaves. Moreover, if the construction is done splitting the alphabet into halves in every
node, the depth of the wavelet tree is (log).
22
R. Castro et al.
As we will see in Section 4, when implementing a wavelet tree the complete information of the elements stored in each subsequence of the tree is not actually necessary.
But before giving any details on how to efficiently implement the wavelet tree, we use
the abstract description above to show the most important operations over this data
structure.
2.1. Rank
The rank is an operation performed over a sequence that counts the occurrences of
value until an index of . It is usually denoted by rank( ). That is, if = (1
) then
rank( ) = jf 2 f1 g j = gj
So for example, in sequence in Fig. 1 we have that rank3( 14) = 3.
Assume that is a wavelet tree for , then rank( ) can be easily computed with
the following strategy. If m() then we know that all occurrences of in appear
in the sequence Left(), and thus rank( ) = rank(Left() mapLeft( )).
Similarly, if m() then rank( ) = rank(Right() mapRight( )). We
23
repeat this process until we reach a leaf node; if we reach a leaf with this process, we
know that rank( ) = .
In Fig. 1 the execution of rank3( 14) is depicted with solid lines. We map index
14 down the tree using either mapLeft or mapRight depending on the m value
of every node in the path. We first map 14 to 8 (to the left), then 8 to 5 (to the right) and
finally 5 to 3 (to the left), reaching a leaf node. Thus, the answer to rank3( 14) is 3.
Rank is computed by performing (log) calls to (either) mapLeft or mapRight,
thus the time complexity is ( log) where is the time needed to compute the
map functions. Also notice that a rank operation that counts the occurrences of between indexes and can be computed by rank( ) rank( 1), and thus the
time complexity is also ( log).
The range quantile operation is essentially Query 1 described in the introduction: given a
sequence = (1 ), quantile( ) is the value of the th smallest element
in the sequence ( +1 ). For instance in Fig. 1 for the root sequence we have
that quantile6( 7 16) = 7 It was shown by Gagie etal. (2009) that wavelet trees
can efficiently solve this query.
To describe how the wavelet tree can solve quantile queries, lets begin with a simpler
version. Assume that = 1 and thus, we want to find the th smallest element among
the first elements in . Then having a wavelet tree for , quantile( 1 ) can
be easily computed as follows. Let = mapLeft( ). Recall that mapLeft( )
counts how many elements of until index are mapped to the leftchild of . Thus if
then we know for sure that the element that we are searching for is in the left subtree,
and can be computed as
quantile(Left() 1 mapLeft( ))
On the other hand, if then the element that we are searching for is in the right
subtree, but it will no longer be the th smallest in Right() but the ( )th smallest and thus can be computed as
quantile( )(Right() 1 mapRight( ))
This process can be repeated until a leaf node is reached, in which case the answer is
the (single) value stored in that leaf.
When answering quantile( ) the strategy above generalizes as follows. We
first compute = mapLeft( ) mapLeft( 1). Notice that is the number of
elements of from index to index (both inclusive) that are mapped to the left. Thus,
if then the element we are searching for is in the leftchild of between the indexes
mapLeft( 1) + 1 and mapLeft( ), and thus the answer is
24
R. Castro et al.
Note that if range is called on a leaf node , then l() = r() = , so the interval is either completely contained (if 2 [ ]) or completely outside (if 62 [ ]).
Both cases are already considered.
25
It is not difficult to show that for a range counting query, we have to make at most
(log) recursive calls (Gagie et al. (2012) show detailed proof), and thus the time
complexity is, as for rank and quantile, ( log) where is the time needed to
compute the map functions.
26
R. Castro et al.
27
between and in is not less than (which can be easily checked using activeLeft
and activeRight).
Queries rank and range[] are even simpler. In the case of rank we only need
to consider the active elements when we reach a leaf; in the last query rank( ) in a
leaf , we just answer activeLeaf( ). In the case of range[]( ), we almost
keep the recursive strategy as before but now when [l() r()] is totally contained
in [ ] we only have to consider the number of active elements between index and
index , which is computed as
(activeLeft( ) + activeRight( ))
3.3. Adding and Deleting Elements from the Beginning or End of the Sequence
Consider the operations pushBack( ), popBack(), pushFront( ) and
popFront(), with their typical meaning of adding/deleting elements to/from the beginning or ending of sequence .
First notice that when adding or deleting elements we might be changing the alphabet of the tree. To cop with this, we assume that the underlying alphabet is fixed and
that the tree is constructed initially from a sequence mentioning all values in . Thus,
initially there is a leaf in the tree for every possible value. We also assume that in every
moment there is an active alphabet, which is a subset of , containing the values actually mentioned in the tree. To support this we just allow some sequences in the tree to
be empty; if there is some value of not present in the tree at some point, then the
sequence corresponding to the leaf node associated with is the empty sequence. It is
straightforward to adapt all the previous queries to this new setting.
Consider now pushBack( ) and assume that before the update we have jj =
. Then, besides adding to the end of sequence , we should update (or more precisely, create) mapLeft( +1) and mapRight( +1). If m() then we
let mapLeft( + 1) = mapLeft( ) + 1 and mapRight( + 1) =
mapRight( ), and then perform pushBack(Left() ). If m() then we let
mapLeft( + 1) = mapLeft( ) and mapRight( + 1) = mapRight(
)+1, and then perform pushBack(Right() ). Finally when we reach a leaf node,
we just add to the corresponding sequence.
The popBack() operation is similar. Assume that jj = , then besides deleting
the last element in , we should only delete that element from the corresponding sub
28
R. Castro et al.
4. Implementation
In this section we explain how to build a wavelet tree and how to construct the auxiliary
structures to support the mapping operations efficiently. Based on this construction we
also discuss how to implement queries explained in the previous section. Additionally,
we present an implementation strategy alternative to the direct pointer based one. We
implemented both approaches in C++ and the code is available in github1.
https://github.com/nilehmann/wavelettree
29
4.1. Construction
A wavelet tree implementation represents an array [0 1] of integers in the interval
[0 1]. Our construction is based on a node structure and pointers between those
nodes. Every node will be identified by two elements and (which essentially
correspond to l() and r() in Section 2), and an associated sequence which is
the subsequence of formed by selecting elements in the range [ ]. As we will see,
values and and the sequence do not need to be explicitly stored and can be
computed when traversing the tree if needed.
The construction of a wavelet tree starts creating the root node associated to the
original array and the interval [0 1]. We then proceed recursively as follows. In
each node we found the middle of the interval = (+)2 (which corresponds
to the value m() described in Section 2). We create two new nodes and as leftchild and rightchild of , respectively. Then, we perform a stable partition of the array
into two arrays and , such that contains all values less than or equal to
and those greater than . The construction continues recursively for the left
node with the array and the interval [], and for the right node with and
the interval [+1 ]. The base case is reached when the interval represented by the
node contains only one element, i.e., = . It is not necessary to store arrays corresponding to each node . They are only materialized at building time to construct the
auxiliary structures to support the mapping operations required to traverse the tree as
described below.
As previously discussed, the fundamental operations mapLeft and mapRight correspond to count how many symbols until position belong to the left and right node
respectively. To support these operations, when building a node we precompute for
every position how many elements in the array belong to the right node they are
greater than and store the results in an array . We could store a similar array 0
to store how many elements belong to the left node, but it is easy to note that values of
both arrays are related as follows: 0 [] = [] + 1.
To understand how is computed, it turns out useful to associate a bitvector
that marks with 0s elements less than or equal to and with 1s those greater than .
This bitvector must support the operation of counting how many bits are set to 1 until a
position , which is commonly referred as a rank operation. Our array is computed on
build time as the partial sum of by the recurrence [0] = [0] [] = [ 1]
+[], thus supporting the rank operation in constant time. The compression characteristics of the wavelet tree arise mainly because it is possible to represent these bitvectors
succinctly while maintaining constanttime rank queries (Clark, 1998; Okanohara and
Sadakane, 2007; Raman etal., 2002). However, in a competitive programming setting
memory constraints are less restrictive and our representation shows off to be sufficient.
In case the memory is an issue, a practical and succinct implementation is presented by
Gonzlez etal. (2005).
30
R. Castro et al.
31
32
R. Castro et al.
The wavelet matrix has the advantage of being implementable using only (log)
extra words of memory instead of the () used to store the tree structure in the pointer
based alternative while maintaining fast operations. This (log) words are insignificant even for = 109, which means that the structure could be constructed directly over
the original alphabet. On the other hand the wavelet matrix is somehow less adaptable,
because it does not support directly the pop and push updates. However, it can support
swap and toggle in a similar way as the one described for the wavelet tree.
http://www.spoj.com/
http://codeforces.com/blog/entry/17787
4
http://d.hatena.ne.jp/sune2/20131216/1387197255
5
This data considers only until late March 2016.
3
33
49
32
35
Accepted
9
6
2
Nonaccepted
WA
TLE
RTE
19
15
12
3
3
6
18
8
15
34
R. Castro et al.
For ILKQ2 and ILKQ3 sorting of queries or any offline approach is not directly
useful as queries are mixed with updates. For ILKQ2 we received some submissions
implementing a square root decomposition strategy, and run extremely close to the time
limit. The most successful strategy in both problems was the use of ideas coming from
persistent data structures, in particular persistent segment trees6. As in any persistent
structure, the main idea is to efficiently store different states of it. Exploiting the fact that
consecutive states do not differ in more than (log ) nodes, it is possible to keep different segment trees in ( log ) space. Persistent segment trees can be used to answer
quantile queries but need some more work to adapt them for updates like swaps as in
ILKQ3. The two correct solutions that we received for ILKQ3 make use of this structure.
Its relevant to notice that given the input size and the updates, implementing a persistent
segment tree for this problem can use a considerable amount of memory. In particular,
one of the AC submissions used 500MB and the other 980MB. Our wavelet tree solution
uses only 4MB of memory.
6. Performance Tests
Existing experimental analyses about wavelet trees focus mostly on compression characteristics (Claude et al., 2015). Moreover, they do not consider the time required to
build the structure because from the compression point of view the preprocessing time is
not the most relevant parameter. Thus, we conducted a series of experiments focusing on
a competitiveprogramming setting where the building time is important and restrictions
on the input are driven by typical tight time constraints. The idea is to shed some light on
how far the input size can be pushed. We expect these results to be useful for competitors
as well as for problem setters.
We performed experimental tests for our wavelet tree and wavelet matrix implementations comparing construction time and the performance of rank, quantile and range
counting queries. We consider only alphabets of size less than the size of the sequence.
To analyze the impact of the alphabet size, we performed tests over sequences of different profiles. A profile is characterized by the ratio between the size of the alphabet
and the size of the sequence. For example, a sequence of size 103 and profile 05 has an
alphabet of size 500.
Measurements. To measure construction time we generated random sequences of increasing size for different profiles. For each size and profile we generated 1,000 sequences and we report the average time. For queries rank, quantile and range counting,
we generated 100,000 queries uniformly distributed and averaged their execution time.
The machine used is an Intel Core i72600K running at 3.40GHz with 8GB of RAM
memory. The operating system is ArchLinux running kernel 4.4.4. All our code are
singlethreaded and implemented in C++. The compiler used is gcc version 5.3.0, with
optimization flag O2 as customary in many programming contests.
6
bit.ly/persistentsegmenttree
35
Results. No much variance was found in the performance between different profiles, but
as may be expected sequences of profile 1 i.e., permutations reported higher time in
construction and queries. Thus, we focus on the analysis of permutations to test performance on the most stressing setting. For the range of input tested we did not observe big
differences between the wavelet tree and the wavelet matrix, both for construction and
query time. Though there are little differences, they can be attributed to tiny implementation decision and not to the implementation strategy itself.
Regarding the size of the input (Fig. 2), construction time stays within the order
of 250 milliseconds for sequences of size less than or equal to 106, but scales up to
2 seconds for sequences of size 107, which can be prohibitive for typical time constraints. For the case of queries rank, quantile and range counting we report in Fig. 3
the number of queries that can be performed in 1 second for different sizes of the input
sequence. For rank and quantile, around 106 queries can be performed in 1 second for
an input of size 106. In contrast for range counting, only 105 queries can be performed
in the same setting (Fig. 3).
It would be interesting as future work to perform a deep comparison between the
wavelet tree and competing structures for similar purposes such as mergesort trees
and persistent segment trees, testing time and memory usage. From our simple analysis in the previous section one can infer that wavelet trees at least scales better in
terms of memory usage, but more experimentation should be done to draw stronger
conclusions.
36
R. Castro et al.
7. Concluding Remarks
Problems involving advanced data structures are appearing increasingly often in worldwide programming competitions. In this scenario, competitive programmers often prefer
versatile structures that can be used for a wide range of problems without making a lot of
changes. Structures such as binary indexed trees or (persistent) segment trees, to name
a few, conform part of the lower bound for competitors, and must be in the toolbox of
any programmer. The wavelet tree has proven to be a really versatile structure but, as
we have evidenced, not widely used at the moment. However, we have noted that some
programmers have already perceived the virtues of the wavelet tree. We believe that the
wavelet tree, being quite easy to implement, and having such amount of applications, is
probably becoming a structure that every competitive programmer should learn. With
this paper we try to fill the gap and make wavelet trees widely available for the competitive programming community.
Acknowledgments
J. Prez is supported by the Millennium Nucleus Center for Semantic Web Research,
Grant NC120004, and Fondecyt grant 1140790.
References
Clark, D. (1998). Compact Pat Trees. PhD thesis, University of Waterloo.
Claude, F., Navarro, G., Ordez, A. (2015). The wavelet matrix: an efficient wavelet tree for large alphabets.
Inf. Syst., 47, 1532.
Fenwick, P. M. (1994). A new data structure for cumulative frequency tables. Software: Practice and Experience, 24(3), 327336.
Gagie, T., Navarro, G., and Puglisi, S.J. (2012). New algorithms on wavelet trees and applications to information retrieval. Theor. Comput. Sci., 426, 2541.
Gagie, T., Puglisi, S.J., Turpin, A. (2009). Range quantile queries: another virtue of wavelet trees. In: SPIRE.
16.
Gonzlez, R., Grabowski, S., Mkinen, V., Navarro, G. (2005). Practical implementation of rank and select
queries. In: WEA. 2738.
Grossi, R. (2015). Wavelet trees. In: Encyclopedia of Algorithms. Springer.
Grossi, R., Gupta, A., Vitter, J.S. (2003). Highorder entropycompressed text indexes. In: SODA03. 841850.
Knuth, D. (1997). The Art of Computer Programming, Volume 1: Fundamental Algorithms. Third Edition.
AddisonWesley. 238243.
Navarro, G. (2014). Wavelet trees for all. J. Discrete Algorithms, 25, 220.
Okanohara, D., Sadakane, K. (2007). Practical entropycompressed rank/select dictionary. In: ALENEX. 60
70.
Raman, R., Raman, V., Rao, S. (2002). Succinct indexable dictionaries with applications to encoding kary trees
and multisets. In: SODA. 233242.
37
R. Castro is a computer engineering student at Department of Computer Science, Universidad de Chile, bronze medalist of IOI2013 in
Brisbane, and problem setter for OCI (Chilean Olympiad in Informatics).
39
Abstract. Learning of programming and, more generally, of computer science concepts is now
reaching the public at large. It is not only reserved for people who studied informatics (computer
science) or programming anymore. Teaching programming to schoolchildren presents many
challenges: the big diversity in ability and aptitude levels; the big amount of different tools; the
timeconsuming nature of programming; and of course the difficulty to motivate schoolchildren
to keep them busy with hard work. There are various platforms that offer to learn coding and
programming, in particular gamebased platforms, which are more and more popular. These
latter exploits of the gamification process focused on increase in motivation and engagement
of the learners. This paper reviews the main kinds of online platforms to learn programming
and more general computer science concepts, and illustrates the review with concrete platforms
examples.
Keywords: gamebased learning, gamification, learning programming, online programming platform, programming contest.
1. Introduction
Informatics (computer science or computing) as a science discipline, and in particular
programming as an important part of that, is gaining a lot of popularity these years in
education. As core subjects in a computer science (CS) major, programming subjects
play an important role in a successful CS education. One of the greatest challenges
faced by most students is the understanding of programming basics, especially for novices or for those who are in their first year of studies. Students develop algorithmic
40
41
This paper reviews literature of the last decade on programming education for school
students (high, secondary and primary levels) using games and online platforms that
support games and contests which goal is to teach programming. The literature review
of programming games and an overview of programming learning platforms were structured to accomplish the following three research objectives:
1. To overview the last decade literature on programming education using games.
2. To identify the important online platforms for learning programming through
games and contests.
3. To identify suitable tools for programming novices.
The goal of the paper is twofold: from one side, to provide an overview of the work
that has been done in this area, and from the other side, to discuss the important tools
(online platforms and contests) and to improve programming education. After this introductory part, Section2 makes a short presentation of the understanding of gamification
and overviews the literature on teaching programming using games. Section 3 presents three kinds of online platforms, which allow students to learn programming. Then
Section 4 tours several existing contest platforms. Finally, the last section concludes
the paper with some thoughts about what could be the future evolution of these online
platforms and contests and makes some suggestions for teaching programming by educational games or by other ways.
42
43
44
45
46
Fig.1. The classification of the educational programming games (adapted and extended schema of Laamarti etal., 2014).
47
48
able to write code to solve challenges. Different coding activities are possible, the main
ones being:
Bugfix: the user is given a program that contains a bug to be fixed.
Recovery: the user is given a program where some parts are missing that have to
be filled.
Code writing: the user has to write an instruction, a function or a program from
scratch.
Agent: the user has to write a program that represents the behaviour of an intelligent agent.
To help the learner to identify the bug, additional information is provided in the statement of the challenge. For example, a precise specification of the program or the results
of the execution of test sets can be provided. Once the learner has written/fixed the
code, he submits it and then gets a feedback. As summarised by Combfis and Wautelet
(2014), feedback is very important for the learning process. Those feedbacks can take
several forms such as:
A simple succeeded/failed status.
The result of the execution of test sets.
A textual feedback providing hints regarding the failure.
Codecademy is an example of an online game platform to learn how to code (Fig.2).
The left part of the window provides the explanations of the new concept to learn. Instructions about the exercise are then provided at the very bottom of this left pane. The
learner can directly code in the editor located in the right part and then submit his/her
code for correction. If the code is wrong, a simple feedback trying to explain why is
provided and if it is right the learner earns a badge, increases his/her progress and can
go to the next lesson.
Fig. 2. Codecademy proposes a course composed of lessons in which you have to write code
and for which you will earn badges and make progress whenever you succeed.
49
Fig. 3. In LightBot, the player has to find a correct sequence of actions to perform so that the
robot reaches the blue cell and lighten it.
Fig. 4. In Initial Conditions, the player has to place cities on a map so that a river is passing
through them and so that two cities cannot be adjacent. This particular map has one river and
the player has to place five cities.
50
This problem is a typical an artificial intelligence (AI) search problem that could for
example be solved using any exploration algorithms, or with a constraint programming
solver, for example. Again, it is not explicitly explained to the learner who just sees a
game with puzzles to solve. Playing the game will challenge the learner and should develop algorithmic thinking in learners mind.
Again, if the purpose is educational, the provided feedback is very important. For
LightBot, the feedback is visual since the learners can visualise the execution of their
programs and therefore visually debug them if the robot failed to reach the goal. For
Initial Conditions, the only feedback is a success/failed status indicating which cities are
violating the constraints or which river is missing villages.
Fig. 5. The main window of the Scratch program is split into two parts: the left part shows
the sprites of the game and the right part shows the programs representing the behaviour of
the different sprites.
51
Fig. 6. In Flowlab, the user programs the game using flowchart diagrams representing the
behaviours of the different sprites it included in the game.
This last category requires the learner to be able to program, but not necessarily to
write code. The focus is put on the creativity and on the skills needed to design and architecture an application.
52
a game. As highlighted by Morrison and DiSalvo (2014) who relate the gamification
of the Khan Academy, one critical motivational element to have is to place the user
at the centre by adding elements of pure play, to make the gaming more playful.
Examples of such approaches include CodeSpells (Esper etal., 2013) and Gidget (Lee
etal., 2013).
Ibez et al. (2014) made an experiment to explore the impact of gamification
techniques on the engagement and learning about the C programming language. The
authors conclude that the gamification they performed has a positive impact on the
students engagement. Most students continued to work even after having earned the
maximum amount of points. ODonovan etal. (2013) present a case study where they
used gamification in a universitylevel course about game development. In their paper, the authors provide insights about gamification mechanics and explain how the
design of their game has been created and which game elements have been used. Their
research allows them to conclude that the gamification they performed in a university
setting was effective, increasing the engagement and understanding of the students.
Again, it is a situation where the platform has been thought as a game from the starting point.
53
Fig. 7. Two leeks are fighting in a war, playing alternatively one after the other. The garden is
divided into cells between which the leeks are moving and has some impassable obstacles.
4.2. CodinGame
CodinGame (https://www.codingame.com) proposes coding challenges to solve.
Basically, the user is asked to code agents that have to interact in a given environment
in order to achieve a given goal. In the example shown in Fig. 8, the user has to code the
spaceship so that to destroy all the targets on the ground. The spaceship is moving from
Fig. 8. In this mission, the agent is a spaceship that must destroy targets on the ground. These
targets have different heights so that the spaceship must destroy them in the right order if it
does not want to enter in collision with any of them.
54
left to right then back from right to left while descending when it reaches the rightmost
part of the world. The difficulty is that targets have different heights and the spaceship
must avoid entering in a collision with any of them.
Several test sets are provided and to succeed, the code of the player must pass them
all (some being public and others being hidden). The execution of the code also results
in an animation, which makes it possible for the learner to directly visualise the behaviour he/she wrote. This latter point helps to increase the motivation and engagement of
the learner, better than a simple textual test execution report. Finally, the platform offers the possibility to code the agents with a lot of different programming languages.
Several challenges/missions are available for the user to tackle. They are organised
into categories such as tutoring, advanced, etc. The users can follow their progress and
that motivates to solve more challenges.
Fig. 9. The main window of Code Hunt is split into two parts: the left part shows the code
being run and the right part shows the result of the execution of the public tests.
55
Fig. 10. The main window of Code Fights is split into two parts: the left part shows the statement of the challenge and the right part shows the code and the result of the execution of the
public tests.
56
intelligent behaviours. The three other platforms do contain some game element, but
they are not designed completely as full games. Table 1 summarises the game elements
that appear in the presented platforms.
All the platforms presented in this paper can also be classified according to the
adapted and extended schema we proposed to classify educational programming games.
Table2 shows how that classification can be done. All the games presented in this paper
Table 1
The four presented online game platforms to learn different skills of coding training and
contains different game elements
Platform
Trained skills
Game elements
Leek Wars
Coding agents AI
Inventing algorithms
CodinGame
Understanding specifications
Coding objects behaviours
Code Hunt
Fixing bugs
Code recovery
Understanding tests sets results
Understanding specifications
Points, levels and rankings
Coding algorithms
Matches against other players or bots
Fixing bugs
Code recovery
Code Fights
Table2
Classification of the platforms
Game
Modality
Interaction style
Environment
Learning approach
Codecademy
Visual
Keyboard/Mouse
Single Player
Code Fights
Visual
Keyboard/Mouse
Code Hunt
Visual
Keyboard/Mouse
CodinGame
Visual
Keyboard/Mouse
Keyboard/Mouse
Leek Wars
Visual
Keyboard/Mouse
LightBot
Visual
Keyboard/Mouse
Social Presence
2D
Online
Social Presence
2D
Online
2D
Online
Social Presence
2D
Online
2D
Online
2D
Online
2D
Online
Mixed Player
Single Player
Single Player
Single Player
Mixed Player
Collaboration
Single Player
57
are visual ones with which the players interact with the keyboard and mouse. Concerning the environment, all the games are of course online ones. They are also all 2D games
and some of them will require social presence, in particular for those where duels are
available. Finally, the learning approaches of those selected games can be either single
or mixed player. One of the game, namely Leek Wars, supports collaboration through the
creation of teams of Leeks.
58
l. Contests and duels in programming games may be used to improve the programming skills.
We proposed taxonomy of the programming educational games and classified several
online programming games / platforms. All of these games are visual; interactive with
keyboard/mouse, 2D and online. The majority of them are designed for a single player,
however, two of them are designed for mixed players (game may be played as single
player or multiplayer) and one of them involves collaboration aspect. As we already
mentioned, multiplayer and collaborating games are more motivating. 3Dgames sometimes have more advantages than 2D, but it depends more on a combination of many
other mentioned or not mentioned factors.
Our findings may be useful in creating educational programming games on your
own, or recreating noneducational games and gamifying them to teach programming, it
is especially useful for novices in programming. This research does not propose to use
all these factors, because some of them may be successful in one kind of games, but may
not be successful for other type of games. However, it is recommended to use at least
some of these factors due to our research analyse.
References
ACM/IEEE Computer Society (2013). Computer Science Curricula 2013.Curriculum Guidelines for Undergraduate Degree Programs in Computer Science. ACM Press, New York, N. Y. USA. Available on the
internet: https://www.acm.org/education/CS2013finalreport.pdf
Alvarez, J., Michaud, L. (2008). Serious games: advergaming, edugaming, training, and more, IDATE, BP 4167,
34092 Montpellier Cedex 5. France, 36, 1112.
Arena, D.A., Schwartz, D.L. (2013). Experience and explanation: using videogames to prepare students for
formal instruction in statistics. Journal of Science Education and Technology, 111.
Azmi, S., Iahad,N.A., Ahmad, N. (2015). Gamification in online collaborative learning for programming courses: a literature review. ARPN Journal of Engineering and Applied Sciences, 10(23), 13.
Barata, G., Gama, S., Jorge, J., Goncalves, D. (2013). Engaging engineering students with gamification. In:
Proceedings of the 5th International Conference on Games and Virtual Worlds for Serious Applications
(VSGAMES 2013). 18.
Becker, K. (2008). Video game pedagogy: good games = good pedagogy. In: T.C. Miller (Ed.), Dames: Purpose
and Potential in Education. Springer, NewYork, NY, 73125.
Bishop, J., Horspool, R., Xie, T., Tillmann, N., de Halleux, J. (2015). Code hunt: experience with coding contests at scale. In: Proceedings of the 37th International Conference on Software Engineering (ICSE 2015).
398407.
Combfis, S., Bibal, A., Van Roy, P. (2014). Recasting a traditional course into a MOOC by means of a SPOC.
In: Proceedings of the European MOOCs Stakeholders Summit 2014 (EMOOCs 2014). 205208.
Combfis, S., SaintMarcq, D. (2012). Teaching programming and algorithm design with Pythia, a webbased
learning platform. Olympiads in Informatics, 6, 3143.
Combfis, S., Van den Schrieck, V., Nootens, A. (2013). Growing algorithmic thinking through interactive
problems to encourage learning programming. Olympiads in Informatics, 7, 313.
Combfis, S., Wautelet, J. (2014). Programming trainings and informatics teaching through online contest.
Olympiads in Informatics, 8, 2134.
CubaRicardo, G., SerranoRodrguez, M.T.,LeyvaFigueredo, P.A., MedozaTauler, L.L. (2015). Methodology
for characterization of cognitive activities when solving programming problems of an algorithmic nature.
Olympiads in Informatics, 9, 2730.
Deterding, S., Dixon, D., Khaled, R., Nacke, L. (2011). From game design elements to gamefulness: Defining
gamification. MindTrek, 2.
Dickey, M.D. (2005). Engaging by design: how engagement strategies in popular computer and video games
can inform instructional design. Educational Technology Research and Development, 53(2), 6783.
59
ODonovan, S., Gain, J., Marais, P. (2013). A case study in the gamification of a universitylevel games development course. In: Proceedings of the South African Institute for Computer Scientists and Information
Technologists Conference (SAICSIT 2013). 242251.
Esper, S., Foster, S., Griswold, W. (2013). CodeSpells: embodying the metaphor of wizardry for programming.
In: Proceedings of the 18th ACM Conference on Innovation and Technology in Computer Science Education
(ITiCSE 2013). 249254.
Gee, J.P. (2003). What video games have to teach us about learning and literacy. Computers in Entertainment
(CIE), 1(1), 20.
Gee, J.P. (2005). Good video games and good learning. Phi Kappa Phi Forum, 85(2), 3337.
Hunicke, R., Leblanc, M. Zubek, R. (2004). MDA: A formal approach to game design and game research. In
Proc. AAAI workshop on Challenges in Game. AAAI Press, 15.
Ibez, M.B., DiSerio, ., DelgadoKloos, C. (2014). Gamification for engaging computer science students in
learning activities: a case study. IEEE Transactions on Learning Technologies, 7(3), 291301.
Laamarti, F., Eid, M., El Saddik, A. (2014). An overview of serious games. International Journal of Computer
Games Technology. Article ID 358152, vol. 2014, 115. Available on the internet:
http://dx.doi.org/10.1155/2014/358152
Lee, M., Ko, A., Kwan, I. (2013). Ingame assessments increase novice programmers engagement and level
completion speed. In: Proceedings of the 9th Annual International ACM Conference on International Computing Education Research (ICER 2013). 153160.
Maloney, J., Burd, L., Kafai, Y., Rusk, N., Silverman, B., Resnick, M. (2004). Scratch: a sneak review. In: Proceedings of the 5th International Conference on Informatics in Schools: Situation, Evolution and Perspectives (ISSEP 2011). 155164.
Mora, A., Riera, D., Gonzlez, C, ArnedoMoreno, J. (2015). A literature review of gamification design frameworks. In: 7th International Conference on Games and Virtual Worlds for Serious Applications (VSGames),
At Skvde. IEEE, 18.
Morrison, B., DiSalvo, B. (2014). Khan Academy Gamifies Computer Science. In: Proceedings of the 45th
Technical Symposium on Computer Science Education (SIGCSE 2014). 3944.
Muratet, M., Torguet, P., Viallet, F., Jessel, J.P. (2010). Experimental feedback on Prog&Play: a serious game
for programming practice. In: L. Kjelldahl and G. Baronosk (Eds.), EUROGRAPHICS. 18.
Nah, F., Zeng, Q., Telaprolu, V., Ayyappa, A., Eschenbrenner, B. (2014). Gamification of education: a review of
literature. In: Proceedings of the First International Conference on HCI in Business (HCIB 2014). 401409.
Prensky, M. (2003). Digital gamebased learning. Computers in Entertainment (CIE), 1(1), 21.
Ravaja, N., Saari, T., Laarni, J., Kallinen, K., Salminen, M., Holopainen, J., Jrvinen, A. (2005). The psychophysiology of video gaming: phasic emotional responses to game events. In: Proceedings of DiGRA
2005 Conference: Changing Views Worlds in Play. Vancouver, Canada, 3, 113.
Sawyer, B., Rejeski, D. (2002). Serious Games: Improving Public Policy through GameBased Learning and
Simulation. Woodrow Wilson International Center for Scholars, Washington, DC, USA.
Schell, J. (2008). The art of Game Design: A Book of Lenses. Carnegie Mellon University and Schell Games,
Pittsburgh, Pennsylvania, USA.
Shute, V.J. (2011). Stealth assessment in computerbased games to support learning. In: S. Tobias and D. Fletcher (Eds.).Computer Games and Instruction. Information Age: Charlotte N. C., 503524.
Squire, K. (2008). Openended video games: a model for developing learning for the interactive age. In: K.
Salen (Ed.), The John D. and Catherine T. MacArthur Foundation Series on Digital Media and Learning.
MA: The MIT Press, Cambridge, 167198.
Surakka, S., Malmi, L. (2004). Cognitive skills of experienced software developer: Delphi study. In: Korhonen
A., Malmi, L. (Eds), Kolin KolistelutKoli Calling 2004. In: Proceedings of the Fourth Finnish/Baltic Sea
Conference on Computer Science Education. Finland, Koli, 3746.
Swacha, J., Baszuro, P. (2013). Gamificationbased elearning platform for computer programming education.
In: Proceedings of the X World Conference on Computers in Education (WCCE 2015). 122130.
Tillmann, N., de Halleux, J., Xie, T., Bishop, J. (2014). Code hunt: gamifying teaching and learning of computer science at scale. In: Proceedings of the First ACM Conference on Learning @ Scale Conference (L@S
2014). 221222.
Tillmann, N., De Halleux, J., Xie, T., SumitGulwani, Bishop, J. (2013). Teaching and learning programming and
software engineering via interactive gaming. In: 35th International Conference on Software Engineering
(ICSE). IEEE, San Francisco, CA, 11171126.
Vihavainen, A., Airaksinen, J., Watson, Ch. (2014). A systematic review of approaches for teaching introductory
programming and their influence on success. In: ICER 14Proceedings of the tenth annual conference on
International computing education research. ACM, New York, NY, 1926.
60
61
Abstract. The special problemsolving strategies have been receiving a lot of attention lately,
whether it is teaching computational thinking for all or computer science for competitors. A didactically interesting question is how problem solving can be developed in childrens minds, what
steps and tasks lead through from understanding the idea to its professional usage. In this paper
we present and explain how and in what forms the given problemsolving strategies, especially
the dynamic programming concept, appear in childrens informatics studies: from CS unplugged
activities through Bebras tasks and national CS competitions to efficient coding at the IOI.
Keywords: dynamic programming concept, teaching informatics in primary and secondary
schools, preparing for contests.
1. Overview
There are a lot of problemsolving strategies which every contestant has to be familiar
with. In this paper, we want to focus on one of the most important ones, specifically dynamic programming, because [Until] you understand dynamic programming, it seems
like magic (Skiena, 2008).
The dynamic programming name came from Bellmann in the 1950s (Dreyfus,
2002). He wanted to find a name for the multistage decision making process, in which
the general case is very hard to solve thus one must use the divide & conquer concept. It
leads back to special cases, when the solution is expressed more easily not in terms of
the unknown function, but in terms of an action or decision.
If we want to speak about dynamic programming, we also have to examine other corresponding concepts, like recursion, memoization and divide & conquer.
The concept of recursion consists of a recursive function and a recursive implementation; it is a topdown approach. Usually the runtime of the algorithm is exponential
and this technique usually fails already in a small sample size. The memoization is a
topdown approach as well, it is more effective than recursion. The core idea is the
62
same: recursive function and recursive implementation, but storing the calculated results, thus without calling the recursive step again when the actual state previously
appeared.
When we are experienced enough to implement a recursive approach correctly,
there is a special technique for dramatically reducing the runtimes of certain algorithms from exponential to polynomial or from factorial to exponential, at the expense
of higher memory usage. This is done by solving subproblems and storing the results
using a dynamic programming concept. The concept is about a recursive function, but
the implementation is to build the values from bottom up without calling the recursive
step repeatedly.
The simplest type of dynamic programming is when an array is filled namely a
table cellbycell in a predetermined order, implementing the recursive function from
bottom up. We will call it a basic DP.
Some people use the term dynamic programming only for those recursive problems,
which involve optimization, but the technique of completing a table to solve any other
type of problem is almost the same when it comes to implementing the solution. We will
call it classic DP.
The dynamic programming as problemsolving strategy is the implementation of the
following five steps (Horvth, 2004):
1. Analysing the (optimal) solutions structure.
2. Dividing it into subproblems and components:
a. Dependence of components must be acyclic.
b. Every subproblem (optimal) solution should be a (recursive) expression of
components (optimal) solution.
3. Expressing each subproblems (optimal) solution as a (recursive) function of components (optimal) solution.
These three steps are the planning of recursive algorithm. DP comes from the next
two steps:
4. Calculating subproblems (optimal) solutions from bottom up (completing a table).
5. Calculating an (optimal) solution from the previously calculated and stored information.
If you are familiar with the basic DP techniques then you could continue with some
advanced techniques (Steinhardt, 2008).
The first advanced type is to keep track of all possible transition states. In this case
DP means filling out a table rowbyrow, with the values depending on the row number
and values in the previous row.
Second advanced type is the dynamic greedy type.
The third advanced type is a steady state convergence, only for more experienced
students. In this case the recursive equation must be repeatedly applied, then values will
converge exponentially to the correct values.
All of the DP types have a place in different stages and in different ages of contestants studies.
63
64
4.1. CSUnlugged
There is not any activity yet that covers dynamic programming in the CSUnplugged repository, but there is an intention to make a good one from the changemaking problem.
65
4.2. BEBRAS
In the Bebras competitions there are tasks about DP every year. There are other tasks,
in which the recursion is the best solution. There are many in which the greedy gives
wrong answer and the dynamic programming concept must be used for the right solution.
On Bebras competitions the DP problems appear in a wide range of age groups and
difficulties also. It proves that the concept of DP comes much earlier than at the end of
secondary school and it is understandable for everybody, not only for contestants: it is
part of computational thinking skills.
The easiest task of DP is from 2013 for grade 58: the Pairs without Crossing (Kreuzungsfreie Prchen). The brute force algorithm is working, but takes long time to try
every possible connection pairs, the dynamic concept make it easy. In 2011 the problem
Earn coins (Mnzen verdienen) is a special case of the classic knapsack problem. This
one was one of the hard problems for the grade 56, middle for grade 78 and easy for
grade 910. In 2014 another classic DP problem appeared, the Expensive Bridges (Teure
Brcken) which one was hard problem for the grade 78, middle for grade 910 and easy
for grade 1113.
There are more problems connected to DP for secondaryschoolage students: the
Jumping Puddles (Ptzenspringen), the game ROOK, in 2010 the task Pinecone (Tannenzapfen), in 2014 the Best translation (Beste bersetzung) and in 2015 the Fireworks2
(das Feuerwerk2).
Fig. 2. Sierpinskitriangle.
Fig. 3. Kochcurve.
66
In Hungary and many other countries, they meet table filling and the thought of
recursion in mathematics. They calculate total number of possible paths in a grid of
characters, from the topleft corner to the rightbottom corner to spell a given word
(Fig. 4). They calculate total number of possible paths, even if there are empty squares
in the grid (Fig. 5).
Pupils of grade 78 meet simple recursive sequences and functions, like the Fibonacci sequence. In mathematics lessons, they meet combinatorial problems (permutation, variation and combination without repetition) without naming them. They come
across problems, like longest/shortest path in a directed/undirected graphs and coloring
problems on very small graphs, coin changing problem for small numbers, shaking
hands/sitting in a row/around a table, they calculate extreme values in Diophantine
problems. These problems are solved with table filling or with recursive expressions.
How many different, 10cm high towers can build from 2 cm high blue, 2 cm high
yellow and 1 cm high red building blocks?
If they draw it systematically (seeing the blocks from bottom), they can guess the
recursive expression an = an 1 + 2*an 2 and they check it empirically. The solutions are: 1, 3, 5, 11, 21, 43, 85, 171, 341, 683.
How many different covering exist on a 2*8 table with 1*2 size dominos?
67
If they draw it systematically (seeing the blocks from the right), they can guess the
recursive expressionan=an1+an2 and they check it empirically. The solutions are:1,
2, 3, 5, 8, 13, 21, 34. The solution can be built for any given N with a table filling.
In primary schools the children meet problems with large numbers also, like 1000
points, 2016 numbered cards, 10000 people. In such cases, the obvious idea is instead
of the original task to examine a simplest problem. What happens if the number of
points is 2, 3, 4, ..., the number of cards is 5, 6, 7,, the number of people is 2, 3, 4,?
If any regularity is noticed, they try to verify it empirically and apply it on the original
problem with large numbers. On primaryschoollevel, formulating and using the hypotheses is enough to solve such problems.
On the other hand, these problems can be implemented on the computer, as a recursive expression or with table filling for larger numbers. The next classical problems are
the first appearance of dynamic programming approach for them:
Robot A robot starts from the top left corner (1,1) of a MxN grid. At each step
the robot can make one of the two choices: move one cell to the right or move one
cell down. How many possible paths are there for the robot to reach the rightbottom corner of the grid?
The robot problem can occur in many variations at grade 7 and 8:
The question is the same, but there are cells in a grid, on which the robot cant
step on (traps).
The question is the same, but there are cells in a grid, on which the robot have
to step on (mandatory fields).
In every cell there are given number of pearls and the question is, what is the
maximum number of pearls the robot can collect on its way.
Mix of traps and pearls.
Staircase You are standing in front of a staircase, which has N stairs. Your goal
is to reach the top. If you are standing on the ith step, you can hop to (i+1)st or
(i+2)nd or (i+3)rd step. Given N, calculate the count of total possible paths for you
to reach Nth stair!
Coin Change You want to make change for given N cents and you have infinite
supply of each of S1, S2, .. , Sm valued coins. How many ways can you make the
change?
Subset sum Detect, if any of the subset from a given set of N nonnegative integers sums up to a given value S!
Dice Throw Problem Given N dice, each with m faces, numbered from 1 to m.
Find the number of ways to get sum X! (X is the summation of values shown by
the dices.)
Flooring How many different coverings exist on a 1*N floor with 1*1 and 1*2
parquet pieces? How many different covering exist on 2*N floor with 1*2 parquet
pieces?
68
Towers How many different, N meters high towers can be built from 2 meters
high blue, 2 meters high yellow and 1 meter high red blocks?
The previous dynamic programming problems should be solved at the primaryschoollevel as the analogous math problems: children formulate and use the hypothetical recursive expressions and implement them with table filling, without extensive
argumentation. Mostly they cannot calculate directly the answer, but they can give a
recursive formula and the direction of filling the table, and this way they can solve the
problem. They can solve basic DP problems, without optimization.
On informatics contest the children use basic data structures (integer, boolean, one
and twodimensional array of integers, simple strings) and basic algorithms can be applied for various problems in various wording. Choosing, selecting, counting, searching, summarizing, selecting maximum/minimum, sorting, separating into two groups,
prime testing are these basic algorithms. Stages of solving tasks are understanding the
problem, choosing the right data structure, selecting right algorithm, implementing and
testing it. In addition to the conservative tasks there are adhoc problems where children
can apply basic algorithms creatively. The basic DP problems appear in the regional and
national rounds of competitions.
of n! and , they also learn Pascaltriangle. But they do not necessarily know the
relationship between the binomial coeffitients and the Pascaltriangle.
They can discover and solve more complex recursive expressions, sometimes these
functions call each other, like:
How many different covering exist on a 2*N table with 1*2 and 1*1 size dominos?
69
In this age they learn the basics of graph theory in mathematics, they learn types
of graphs (trees, binary trees, relational matrix), storage of graphs (vertex matrix, edge
matrix, edge list) and algorithms of graphs (breadth first traversal, depth first traversal,
relations) in informatics. They meet recursion again, divide and conquer, backtrack, and
greedy algorithms too, on basic level.
They learn all classic dynamic programming problems, as follows:
Partition problem Divide the set of numbers into two groups, where sum of
each group is same!
Longest Increasing Subsequence Find the length of the longest subsequence
of a given sequence, such that all the elements are sorted in increasing order.
Knapsack Problem A thief robbing a store can carry a maximal weight of W
in his knapsack. There are N items and ith item weighs wi and is worth vi dollars.
What items should the thief take?
Contiguous subsequence with maximum value Find the contiguous array
with the maximum sum in a given an array, containing both positive and negative
integers!
Minimal number of coins for change What is the minimal number of coins, to
make change for a given amount T only coins of values v1, v2, , vn can be used?
These examples can be solved by using recursion with optimization, the right order
of filling the table must be given usually it is not evident. There are a number of variations of these problems, sometimes the difference is merely wording.
Next type of DP problems is game strategy in various formats, like:
Optimal Strategy Consider a row of N coins of values v1, ..., vN, where N is
even. We play a game against an opponent by alternating turns. In each turn, a
player removes either the first or last coin from the row and receives the value
of the coin. Determine the maximum possible amount of money we can definitely
win if we move first?
Basic data structures may be supplemented with string and real. There are a number
of dynamic programming problems with strings, too:
Longest Common Subsequence Find the longest common subsequence of two
strings, where the elements are letters from the two strings and they should be in
the same order!
Longest Common Substring Find the longest common substring of two
strings!
Edit Distance Given two strings and a set of operations Change (C), insert (I)
and delete (D). Find minimum number of operations required to transform one
string into another!
On informatics contest classic dynamic tasks can be in every round, so the contestants
have to be ready to solve it.
70
71
(I) no two selected processes intersect and (II) at most one process is selected
from each ktuple!
intersec Complete all tasks given the deadline, so that no task overlap!
Box Stacking You are given a set of N types of rectangular 3D boxes, where
the i^th box has height h(i), width w(i) and depth d(i). You want to create a stack
of boxes which is as tall as possible, but you can only stack a box on top of another box if the dimensions of the 2D base of the lower box are each strictly
larger than those of the 2D base of the higher box. You can rotate a box, any of
the side can be its base. It is also allowable to use multiple instances of the same
type of box.
Counting Boolean Parenthesizations You are given a boolean expression consisting of a string of the symbols true, false, and, or and xor. Count the
number of ways to parenthesize the expression such that it will evaluate to true.
For example, there are 2 ways to parenthesize true and false xor true such that
it evaluates to true. The order is defined only by parentheses.
There are many tasks for practice on the online preparing and contest sites, like
usaco.org, codeforces.com, codechef.com, uva.onlinejudge.org, spoj.pl. If you have met
each type of concept detailed above, the textbook of Halim is a good choice for preparing for IOI.
5. Conclusions
Some antecedents of the dynamic programming concept for example the concept of recursion, might come up in earlier mathematics and informatics studies. If you are aware
of this, introducing DP as a new problemsolving strategy is much easier.
We think, if you want to teach the technique of DP you have to start from a simple
recursion then through memoization and table filling you could end with a real DP for
optimization problems. You could start the whole process in the primary school age and
circularly, returning to it in higher and higher levels your students would be familiar with
this hard concept.
In the upper primary school, the basic DP comes up: a recursive expression implemented with table filling. At the beginning of secondary school, the classic DP programs
continue the sequence: recursive expressions with optimization and at implementation
the right order of table filling need to be thought of. In upper secondary school, the
children can be familiar used with advanced types of DP: all of the previous problems
with the retrieval of the way, how the optimal solution is built up, dynamic greedy type
and the type, when you have to keep track of all possible transition states. Preparing for
Olympiads, the students need everything from textbooks and the combination of other
types of approaches.
Finally, it would not be magic for the contestants, just a useful problemsolving
strategy.
72
References
BebrasInternational Contest on Informatics and Computer Fluency (20072015). http://bebras.org
http://www.beavercomp.org.uk/; http://informatikbiber.de/archiv/
Bebis, G. (2007). CS477/677 Analysis of Algorithms.
http://www.cse.unr.edu/~bebis/CS477/
Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C. (2001). Introduction to Algorithms. MIT Press, 2nd edition.
Dagien, V., Stupurien, G. (2016). Bebras a sustainable community building model for the concept based
learning of informatics and computational thinking. Informatics in Education, 15(1), 2544.
Dasgupta, S., Papadimitriou, C.H., Vazirani, U.V. (2006). Algorithms. McGrawHill.
Dreyfus, S. (2002). Richard Bellman on the birth of dynamic programming. Operations Research, INFORM.
50(1), 4851.
Erds, G. (2010). A rekurzv mdszer. In: Magas Szint Matematikai Tehetsggondozs Konferencia, ZALAMAT. 2032.
Foriek, M. (2015). Towards a better way to teach dynamic programming. Olympiads in Informatics, 9, 4555.
Gupta, N. (2009). Introduction to Algorithms.
http://www.curriki.org/oer/IntroductiontoAlgorithms/
Halim, S., Halim, F. (2014). Competitive Programming 3. The New Lower Bound of Programming Contests.
http://cpbook.net/
Horvth, Gy. (2004). A programozsi versenyek szerepe az oktatsban. In: INFORA Konferencia.
http://www.infoera.hu/infoera2004/eaok/horvathgyula.pdf
Kleinberg, J., Tardos, . (2006). Algorithm Design. AddisonWesley.
Sedgewick, R., Wayne, K. (2011). Algorithms, Fourth Edition. AddisonWesley.
Skiena, S.S. (2008). The Algorithm Design Manual. SpringerVerlag, 2nd edition.
Steinhardt, J. (2008). Advanced Dynamic Programming Techniques.
https://activities.tjhsst.edu/sct/lectures/0708/dpadvanced.pdf
73
email: {samuel,daniel,benjamin}@soi.ch
Abstract. As part of the qualification process for the Swiss Olympiad in Informatics, the contestants are each year confronted with one Creativity Task. Unlike typical problems in programming competitions, creativity tasks usually do not have an optimal solution, and are often
adaptations of popular board or computer games. After receiving all submissions, a tournament is
organized, where the students can watch how their programs play interactively against each other,
and points are awarded to the authors according to the tournament ranking.
We present and discuss this task format in general, as well as the specific creativity tasks of
the past 10 years, accompanied by an online archive of the task descriptions, sample solutions and
game servers.
Moreover, we describe our task selection process and criteria, the task creation process, and
the experience gained and best practices established in the past years.
Finally, we present the many advantages of this task format, showing why we think it is a
refreshing alternative to the common IOIstyle tasks given in most national selection rounds.
Keywords: creativity tasks, interactive tasks, heuristics, programming competition, board games,
artificial intelligence contest, tournaments, task visualization.
1. Introduction
During the first round of the Swiss Olympiad in Informatics (SOI), the students have
two months to solve a set of tasks at home and submit them on the SOI website. There
are practical and theoretical tasks, and one creativity task. This paper is about the creativity tasks.
Contrary to typical tasks in programming competitions, the creativity tasks are usually designed in such a way that there is no optimal solution, or that the optimal solutions are not efficient enough. The creativity tasks are often adaptations of popular
board or computer games, and the game can be played with two or more players. The
participants task is to write a program able to play the game. We will refer to such
programs as bots.
An interesting aspect of this task format is that the participants bots can play and
compete against each other.
74
At the start of each years first round, the following material for the creativity task is
published on the SOI website:
The task description, describing the rules of the game and its parameters. Depending on the game, these could include, for instance, width and height of the
playing field, or a map of the playing field, the number of players, the initial
amount of money/food of each player, etc. The task description also specifies
the communication protocol between the bots and the game server (see below),
which defines how the bots have to communicate their actions and how they are
informed about the other bots actions. All communication is done via standard
input/output.
A game server, a program written by the task authors, which launches the bots,
communicates with them according to the protocol and keeps track of the game
state. It informs the bots about all the relevant changes and prints a log of each
action and state change. The server also acts as a judge that can terminate bots
that drop out of the game or take too long to answer. If the interaction protocol is
easy to read, the game server can also allow for human players that type in their
commands interactively. This way, the participants can play against their own
bots by hand.
Some sample bots in various programming languages. These bots follow all the
rules of the protocol, but they just pick a random move in every step. The participants can base their solutions on these sample bots to quickly learn how to
implement the protocol and input/output. Moreover, they can evaluate their bots
by letting them play against the sample bots.
A visualization, which reads the log produced by the game server, and displays a
graphical animation of the game. For some of our tasks, the game server already
provides a rudimentary textbased visualization of the game.
After the end of the first round of the SOI, the organizers let the submitted bots
compete against each other in a large number of games covering many different configurations, to make sure that the obtained results are representative and random decisions
average out well enough. The results of all these games are then aggregated into a final
score for each participant.
Between the first and the second round of the SOI, all participants are invited to an
event called SOIDay consisting of task discussions, talks and presentations. At this
event, a shortened version of the the creativity task tournament is presented as if it was
a live tournament, and the participants can thrill while watching their bots compete
against the others.
Watch them Fight! Creativity Task Tournaments of the Swiss Olympiad in Informatics
75
http://www.gameaiforum.org/icgatournaments/game.php?id=30
76
Fig. 1. Multisnake.
Discussion Successful
submissions
use of
thelook
scentforward
hints to to
share
knowlabout their exper
experiment
withmade
suchcreative
task types
and
learning
edge between the ants.
Some
even
tried
to
learn
and
imitate
the
marking
patterns
of the
Acknowledgments
opponents to mess We
withwould
it and cause
confusion.
like to thank all the volunteers of the Swiss Olympiad in Informatics
References
78
There were 11 submissions, and for the tournament, they were fed a total of 547
questions. Table 1 shows the ranking and their percentage of correct answers. Note that
the primary ranking criterion was whether they were compilable and never crashed, and
the number of correct answers was only the secondary criterion.
% correct
behavior
10
27%
2%
0%
N/A N/A
did not compile
10
Watch them Fight! Creativity Task Tournaments of the Swiss Olympiad in Informatics
79
Fig. 4. Diamond Auction (the graph shows the last game of the final).
80
The submissions fell into one of two categories: sophisticated algorithms beating
human players easily (3 submissions) or being barely able to play the game (4 submissions). One example from the second category used DFS to determine the shortest
path resulting in some of the longest possible paths.
The winning submission consists of 1741 lines of code using a wide range of algorithms. On small maps it uses a four dimensional BFS (location and velocity) to find
the optimal solution. On bigger maps, a heuristic is used to improve the runtime of this
algorithm and only paths between two checkpoints are calculated. To find the best order
of checkpoints it uses some more heuristics to find a good approximations for the traveling salesman problem.
2.11. Statistics
Table 2 shows our observed participation rates in the last ten years. Given the bonuslike
character of the creativity tasks, participation rates in the past years fluctuated heavily.
Usually, only students with enough time (and interest) left after solving the five classical
problems tackled the creativity task. Tasks with a very simple interface (like the diamond auction in 2015) seem to have drawn additional interest, probably because writing
a first solution was easily possible within an hour, also for beginners.
(4 submissions). One example from the second category used DFS to determine
the shortest path resulting in some of the longest possible paths.
The winning submission
3. Implementation
Details consists of 1741 lines of code using a wide range of
algorithms. On small maps it uses a four dimensional BFS (location and velocity)
to nd the optimal solution. On bigger maps, a heuristic is used to improve the
runtime
thisSelection
algorithm
and
only paths
between two checkpoints are calculated.
3.1.
Our of
Task
and
Creation
Process
To nd the best order of checkpoints it uses some more heuristics to nd a good
approximations for the traveling salesman problem.
The SOI is organized by a team of approximately twenty people, most of whom are
former participants and now university students. Each year when the preparations of the
2.11round
Statistics
first
of the SOI start, they discuss a few proposals for the creativity task on their
internal mailing list. Once the task is chosen, two to three organizers are selected to
write
the detailed
description
and implement
the game
server
and last
the visualization.
The table
belowtask
shows
our observed
participation
rates
in the
ten years.
A
few more
organizers character
proofread the
taskcreativity
description
and write
sample bots
in as
Given
the bonuslike
of the
tasks,
participation
rates
in many
the
languages
possible. heavily. Usually, only students with enough time (and
past yearsas uctuated
interest) left after solving the ve classical problems tackled the creativity task.
Tasks with a very simple interface (like the diamond auction in 2015) seem to
have drawn additional interest, probably
Table 2because writing a rst solution was
easily possible within an hour,
also
for
Participation ratesbeginners.
in the last ten years
year
3
3.1
Implementation Details
Our Task Selection and Creation Process
Watch them Fight! Creativity Task Tournaments of the Swiss Olympiad in Informatics
81
The organizers of the creativity task are usually people who have successfully taken
part in the creativity task a few years before when they were participants, and they are
supported by older organizers who prepared the creativity task a few times before. This
ensures a good knowledge transfer, which leads to good creativity tasks, even though
this task format is more challenging for task creators than ordinary tasks and even though
every year, many organizers join and leave the team.
We cannot provide an online game server instead, because in the first round of the SOI, no participants
should be disadvantaged because they cannot use their favorite programming language. This would mean
that we would have to support a very large number of programming languages, and moreover, it would
require a big effort for the sandboxing.
82
In our experience, implementing the game server in Java, which is available on all
platforms, seems to be the best solution. But even getting a Java game server to run was
a bit challenging for some participants, because some could only install Java 6 (instead
of newer versions) on their system, while others did not know how to specify the paths
to the bots as command line arguments, etc. But we could always help them by email
support or through our forum. What we do not know, however, is how many people did
not succeed in getting the server to run, but did not ask for help.
For the visualization, the two best solutions seem to be either to integrate the visualization in the Java game server, or to implement it as an HTML5/JavaScript page,
where one can paste the log of the game server, and then watch the visualization. An
advantage of the latter is that it only requires a web browser, which is available on every
computer, so we can provide some sample game logs, so that the participants can watch
some games before even starting to implement their own solution and to bother getting
the game server to run.
Fraud Detection The grading of the creativity task is not fully automated on purpose.
The submissions are compiled manually to check for compatibility issues and the source
code is read to get an idea of the participants solution and to check that all the rules are
followed. Given the small number of participants, this is feasible and also eliminates the
need for a separate fraud detection or sandboxing of the submitted programs.
4. Discussion
4.1. Task Selection Criteria
We now present our criteria for the selection of the creativity task. This is more a collection of useful arguments that came up in past discussions rather than an ultimate list.
Interactivity: It should be interactive, and interaction should not only happen between the game server and the bots, but also between the bots, i.e. the possible
moves of a player should depend on the actions that the other players took before.
This is mostly to make the task more fun and different from the standard tasks, but
it is not strictly necessary. For instance, the Grand Theft Cake task (section 2.3),
or the Who wants to be a billionare? task (section 2.7) do not have any interaction
between the players, and still were successful creativity tasks. In the case of the
Vector Car Racing task (section 2.10), however, some special effects were added
to the traditional game to make it interactive, and to increase the size of the search
space that optimal solutions would have to explore.
Hardness: There should be no optimal solution, or optimal solutions should be too
expensive to calculate.
Flat learning curve: The task should be simple, with few, easy to understand
rules, so that it is suitable for beginners, but it should also offer many interesting
options for advanced participants.
Watch them Fight! Creativity Task Tournaments of the Swiss Olympiad in Informatics
83
Novelty: The task should not be too standard to make sure one cannot just copy
and adapt a standard solution found on the internet. For instance, chess or Nine
Mens Morris were proposed in the past years, but not chosen for this reason.
Continuous Complexity Curve: There should be a continuous spectrum of imagineable solutions between straightforward random bots and very sophisticated solutions.
Plethora of solutions: There should be many different solutions that could work
reasonably well and are feasible to implement. For instance, for some proposed
tasks, it was feared that applying a standard minimax algorithm would be almost
the only reasonable solution, and these tasks were thus not chosen.
Manual playing: It is a plus if the game can be played by hand, such as Multisnake
(section 2.5) or Vector Car Racing (section 2.10), so that the participants can compare their bots to their own intuitive playing style.
Visualizability: A good task should allow for an appealing way of watching the
interaction between the bots and giving a dramatic view on the progress of the
game.
84
The tournaments are fun to watch as the interaction between the bots suggests that the
contestants are immediately fighting against each other.
Finally, we believe that creativity tasks are also a way to train for the newer, lessstandard IOI tasks where heuristical solutions are required. Examples of such creative
IOI tasks include Languages and Maze from IOI 2010, Odometer from IOI 2012 and Art
Class from IOI 2013.
5. Conclusion
In summary, creativity tasks proved to be a beneficial addition to the types of algorithmic
challenges given in the first national round of the Swiss Olympiad in Informatics.
We provide the full description and supplementary material for the presented tasks
online at http://creativity.soi.ch and we want to encourage other delegations
to experiment with such task types and look forward to learning about their experiences.
Acknowledgments
We would like to thank all the volunteers of the Swiss Olympiad in Informatics who created, prepared and graded these tasks over the years.
References
Aigner, M., Fromme, M. (1984). A game of cops and robbers. Discrete Applied Mathematics, 8(1), 112.
Burton, B. (2008). Breaking the routine: events to complement Informatics Olympiad training. Olympiads in
Informatics, 2, 515.
Foriek, M. (2013). Pushing the boundary of programming contests. Olympiads in Informatics, 7, 2335.
Gardner, M. (1973) Sim, Chomp and Race Track: new game for the intelligent (and not just for Lady Luck).
Scientific American, 228(1), 108115.
Verhoeff, T. (2009). 20 years of IOI competition tasks. Olympiads in Informatics, 3, 149166.
Watch them Fight! Creativity Task Tournaments of the Swiss Olympiad in Informatics
85
S. Grtter was a participant at CEOI 2009 and IOI 2010, and has
helped with the organization of the Swiss Olympiad in Informatics
since 2011. He was deputy leader of the Swiss team at IOI 2013.
He holds a BSc in Computer Science from Ecole Polytechnique
Fdrale de Lausanne (EPFL), where he is currently pursuing his MSc
and working at the Scala Lab under the supervision of Prof Martin
Odersky.
His research interests are logic, formal languages, type systems and
compilers.
D. Graf participated at CEOI 2009 and IOI 2009 (bronze) and returned
to IOI as the delegation leader of the Swiss team in 2012, 2014 and
2015. He volunteers for the Swiss Olympiad in Informatics since 2010
and is its president since 2011.
He holds a MSc in Computer Science from the Swiss Federal Institute of Technology in Zurich (ETHZ), where he is currently pursuing
his PhD in the group for Algorithms, Data Structures, and Applications
of Prof. Peter Widmayer.
B. Schmid participated at IOI 2013, IOI 2014 (bronze) and CEOI 2013
(bronze). Since 2015 he helps organizing the Swiss Olympiad in Informatics.
He is currently pursuing a BSc in Computer Science from ETH
Zurich.
87
1. Introduction
The problem Friend in IOI 2014 required contestants to find a set of vertices with maximum total weight, such that no two vertices in the set are sharing a common edge. This
is a classical Weighted Maximum Independent Set problem. We can show that Weighted Maximum Independent Set problem is NPhard by reduction from 3SAT (Cormen
etal., 2009). Since the formulation of NPcompleteness 4 decades ago, no one has been
able to propose a solution to any NPhard problem in polynomial time. Clearly, it is not
expected that a high school student can solve the problem in 5 hours. None of the Indonesian IOI 2014 team solved this problem during the contest. After returning from the
competition, I asked the Indonesian team about this problem. None of the team members
were aware of the fact that Maximum Independent Set is an NPhard problem, and thus
were stuck trying to solve a general Maximum Independent Set problem.
A similar problem also occurred in IOI 2008. The problem Island required contestants to find a longest path in a graph with 1,000,000 vertices. The longest path problem
is a classic NPhard problem which can be reduced from the Hamiltonian path problem.
If a contestant is not aware that the longest path problem is difficult to solve, the contestant may spend a lot of his/her time just to tackle the general longest path problem,
without realising that there is a special case to the given graph.
88
J.I. Gunawan
Generally, some contestants spend too much thinking time trying to solve something
that is believed to be unsolvable. If only they realise that their attempt is intractable,
they may try a different approach and find a special case of this problem. In section 2
of this paper, we will introduce a classic reduction technique often used in theoretical
computer science research. In the context of competitive programming, we may find out
that a problem which we are attempting is unlikely to be solvable. After realizing that
a problem is intractable, we are going to discuss how to proceed to solve the problem
in section 3. Finally, in section 4 we will take a look at some common special cases in
competitive programming that can be used to solve these kind of problems.
Fig. 1. The result of Indonesian team in IOI 2014, taken from http://stats.ioinformatics.org. The red squared column highlights the Friend problem.
Fig. 3. The result of Indonesian team in IOI 2008, taken from http://stats.ioinformatics.org. The red squared column highlights the Island problem.
89
22 Identifying
Identifying
Intractability
Intractability
of
aaRedu
Pro
Pro
22 Identifying
of
aaProblem
through
Reduc
IdentifyingIntractability
Intractability
of
Problem
through
2 Identifying
Intractability
of aof
Problem
2
Identifying
Intractability
ofR
entifying
Intractability
of
a
Problem
through
Reduction
2
2
Identifying
Identifying
Intractability
Intractability
of
of
a
a
Problem
Problem
through
through
We
would
like
to
know
that
the
problem
that
we
are
attempting
is
unlikely
to
have
an
m
through
Reduction
actability
of
a
Problem
through
Reduction
ifying
Intractability
of
a Problem
through
Reduction
2 through
Identifying
Intractability
ofthe
aproblem
Problem
through
R
Intractability
of
a
Problem
through
Reduction
of
a
Problem
Reduction
We
We
would
would
like
like
to
to
know
know
that
that
the
problem
that
that
we
we
are
are
attempting
attempting
isis u
immediate
solution.
The
most
way
toare
apply
athe
wellknown
technique
called
rough Reduction
solut
We
would
totoknow
that
the
problem
that
attempting
is
unlikely
to
have
an
immediate
soluti
We
wouldlike
like
know
that
thecommon
problem
that
we
are
attempting
is
unlikely
to
have
an
immediate
solu
We
would
like
toiswe
know
that
problem
that
we
are
attempting
is
unlikely
We that
would
like
to
thatisisthe
problem
thatcalled
we
are
att
actability
of
awould
Problem
doto
like
to
know
that
the
problem
that
we
are
attempting
is Reduction
unlikely
to
have
anknow
immediate
solution.
We
We
would
would
like
like
to
know
know
that
that
the
problem
problem
that
we
are
are
attempting
attempting
unlikely
unlikely
to
toThe
have
have
an
an
immedi
immed
have
anwe
immediate
The
oblem
that
areproblem
attempting
is
unlikely
tothrough
an
immediate
solution.
The
most
most
common
common
way
way
iswe
iscalled
to
to
apply
apply
aa and
wellknown
wellknown
technique
technique
called
redu
reduction.
Suppose
we
know
that
problem
X
is
impossible
to
solve,
we
also
know
know
that
the
that
we
attempting
isthe
unlikely
to
have
an
immediate
solution.
The
most
common
way
is
toto
apply
ahave
technique
reduction.
Suppose
we
know
that
prob
We solution.
like
know
that
the
problem
that
are
is
unlikely
to
have
an
immedia
most
common
way
isare
to
apply
awellknown
wellknown
technique
called
reduction.
Suppose
we
know
thatreduc
pro
most
common
way
is
to we
apply
aattempting
wellknown
technique
called
reduction.
at
the
problem
that
we
are
attempting
isSuppose
unlikely
to have
have
an
immediate
solution.
The
tanthe
problem
that
we
attempting
is
unlikely
to
an
immediate
solution.
The
most
common
isknow
apply
a wellknown
technique
attempting
is
unlikely
to
have
anproblem
immediate
solution.
1 to
mmon
isknow
to
aare
wellknown
technique
called
reduction.
Suppose
we
know
problem
X isproblem
immediate
solution.
The
most
most
common
common
way
way
is
is
to
to
apply
apply
aknow
aThe
wellknown
wellknown
technique
technique
called
called
reduction.
reduction.
we
we know
know
Suppose
we
that
problem
X
is
wellknown
technique
called
reduction.
we
that
problem
Xway
isX
impossible
impossible
to
to
solve,
solve,
and
we
we
also
also
that
that
we
we
can
solve
solve
problem
XX
b.tI
11 1by
that
we
can
solve
X
by
using
problem
Y
asand
a blackbox
If
we
can
solve
way
isaway
to
apply
aapply
wellknown
technique
called
reduction.
Suppose
we
know
problem
Xcan
isSuppose
impossible
toto
solve,
and
we
know
that
we
can
solve
problem
by
using
problem
YSuppose
asasawe
.th
most
common
way
isto
tohave
apply
ato
wellknown
technique
called
reduction.
Suppose
we
impossible
solve,
and
wealso
also
know
that
we
can
solve
problem
Xthat
by.X
using
problem
Y
ablackbox
blackbox
impossible
solve,
and
we
also
know
that
we
can
solve
problem
X know
bysolve
using
apply
wellknown
technique
called
reduction.
Suppose
we
know
that
problem
X
is
pply
a
wellknown
technique
called
reduction.
Suppose
we
know
that
problem
is
impossible
to
solve,
and
we
also
know
that
can
p
1
blem
that
we
are
attempting
is
unlikely
an
immediate
solution.
The
e
called
reduction.
Suppose
we
know
that
problem
X
is
1
1
elve,
tothat
solve,
and
we
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
blackbox
.
If
we
can
we
know
that
problem
X
is
impossible
impossible
to
to
solve,
solve,
and
and
we
we
also
also
know
know
that
that
we
we
can
can
solve
solve
problem
problem
X
X
by
by
using
using
problem
problem
Y
Y
as
as
a
a
blac
bla
1Y
problem
Y
as
a
blackbox
.
If
we
can
ow
we
can
solve
problem
X
by
using
problem
Y
as
a
blackbox
.
If
we
can
solve
solve
problem
problem
Y,
Y,
then
then
we
we
can
can
solve
solve
problem
problem
X
X
as
as
well.
well.
Therefore,
Therefore,
pro
pr
problem
Y,
then
we
can
solve
problem
X
as
well.
Therefore,
problem
is
also
imand
we that
also
know
that
we
can
solve
problem
X
by
using
problem
Ysolve
as
a11 .problem
blackbox
we
can
solve
problem
Y,
then
we
can
solve
problem
XY
as
well.
Therefore,
problem
YIf
also
impossible
to
impossible
toassolve,
and
we1problem
also
know
that
we
can
Xcan
using
problem
Y as
as
asolve.
black
solve
problem
Y,
then
we
can
solve
problem
X
as
well.
Therefore,
problem
Yis
is
also
impossible
to
solve
solve
Y,
then
we
can
solve
problem
X.by
as
well.
Therefore,
problem
eeY
also
know
we
can
solve
problem
X
by
using
problem
Y
as
a
blackbox
If
we
can
also
know
that
we
can
solve
problem
X
by
using
problem
as
a
blackbox
.
If
we
can
solve
problem
Y,
then
we
solve
problem
X
well.
T
ellknown
technique
called
reduction.
Suppose
we
know
that
problem
X
is
1
problem
X
by
using
problem
Y
a
blackbox
.
If
we
can
2
Identifying
Intractability
of
Problem
through
Reduc
blem
Y,
then
can
solve
problem
X
Therefore,
Y as
is a
also
impossible
toproblem
solve.
a we
blackbox
. Ifto
we
can
solve
problem
Y,
Y,as
then
then
we
can
can
solve
solve problem
problem
XX
as
well.
well.
Therefore,
Therefore,
problem
YY isis also
also impossible
impossible
possible
to
solve.
isasalso
impossible
solve.
Xcan
aswe
well.
Therefore,
problem
Ywell.
iswe
also
impossible
,Yproblem
then
solve
problem
X
as
well.
Therefore,
problem
Ytoissolve.
also
to solve.
solve
problem
Y,
then
we
canY
solve
problem
X1 .asIfimpossible
well.
Therefore,
problem Y is also impossible t
can
solve
problem
X
as
well.
Therefore,
problem
Y
is
also
impossible
to
solve.
an
solve
problem
X
as
well.
Therefore,
problem
is
also
impossible
to
solve.
w
that
we
can
solve
problem
X
by
using
problem
as
a
blackbox
we
can
Therefore,
problem
Y
is
also
impossible
to
solve.
We are using NPhard problems forWe
illustration.
Recall that
NPhard
problems
have
impossible to solve.
We
are
are using
using
NPhard
NPhard
problems
problems
for
for
illustration.
illustration.
Recall
Recall
that
that
NPhard
NPhar
We
using
problems
for
illustration.
Recall
that
NPhard
problems
to
bebe
solved
ininpopt
Weare
arelike
using
NPhard
problems
for
illustration.
Recall
that
NPhard
problems
have
yet
toNPhard
solved
We
are
using
problems
for
Recall
that
proble
Weyet
would
toNPhard
know
that
problem
thatNPhard
we
are
attempting
isillustration.
unlikely
to have
have
an
immediate
soluti
We
are
using
NPhard
problems
foryet
illustration.
Recall
problem
X as
well.
Therefore,
problem
Ythe
is also
impossible
toproblems
solve.
to
be
solved
in
polynomial
time
for
more
than
4
decades.
MINVERTEXCOVER
eNPhard
using
NPhard
problems
for
illustration.
Recall
that
NPhard
have
yet
to
be
solved
in
polynomial
We
We
are
are
using
using
NPhard
NPhard
problems
problems
for
for
illustration.
illustration.
Recall
Recall
that
that
NPhard
NPhard
problems
problems
have
have
yet
yet
to
to be
be
so
so
ms
have
yet
to
be
solved
in
polynomial
or
illustration.
Recall
that
NPhard
problems
have
yet
to
be
solved
in
polynomial
time
time
for
for
more
more
than
than
4
4
decades.
decades.
MINVERTEXCOVER
MINVERTEXCOVER
is
is
a
a
graph
graph
prob
pro
2
Identifying
Intractability
of
a
Problem
through
Reductio
2
Identifying
Intractability
of
a
Problem
through
Redu
problems
for
illustration.
Recall
that
NPhard
problems
have
yet
to
be
solved
in
polynomial
minimu
time
for
more
than
4
decades.
MINVERTEXCOVER
is
a
graph
problem
that
involves
nding
a
minimum
We
are
using
NPhard
problems
for
illustration.
Recall
that
NPhard
problems
have
yet
to
be
solv
time
for
more
than
4
decades.
MINVERTEXCOVER
is
a
graph
problem
that
involves
nding
a
minim
time
for
more
than
4
decades.
MINVERTEXCOVER
is
a
graph
problem
most
common
way
isthat
tobeinvolves
apply
ainfinding
wellknown
technique
called
reduction.
Suppose
we
know that
prob
roblems
for
illustration.
Recall
that
NPhard
problems
have
yet
to
be
solved
in
polynomial
roblems
for
illustration.
Recall
that
NPhard
problems
have
yet
to
be
solved
in
polynomial
time
for
more
than
4graph
decades.
MINVERTEXCOVER
isth
ll
that
NPhard
problems
have
yet
to
solved
polynomial
2
Identifying
Intractability
of
a
Problem
throu
2
2
Identifying
Identifying
Intractability
Intractability
of
of
2
a
a
Problem
Identifying
Problem
through
through
Intractability
Reduction
Reduction
of
is
a
graph
problem
a
minimum
subset
of
nodes
such
that
for
every
more
than
4
decades.
MINVERTEXCOVER
is
a
graph
problem
that
involves
nding
a
minimum
subset
yet
to
be
solved
in
polynomial
time
time
for
for
more
more
than
than
4
4
decades.
decades.
MINVERTEXCOVER
MINVERTEXCOVER
is
is
a
a
graph
problem
problem
that
that
involves
involves
nding
nding
hat
involves
nding
a
minimum
subset
VERTEXCOVER
is
a
graph
problem
that
involves
nding
a
minimum
subset
of
of
nodes
nodes
such
such
that
that
for
for
every
every
edge,
edge,
at
at
least
least
one
one
of
of
its
its
endpoint
endpoint
is
is
in
in
ta
tifying
Intractability
a atProblem
through
Reduction
han
4MINVERTEXCOVER
decades.
MINVERTEXCOVER
isof
aof
graph
that
involves
nding
aby
minimum
1sub
MAXINDEPENDENTof
nodes
such
that
for
every
edge,
least
one
ofnding
its
endpoint
the
subset.
MAXINDEPENDENTS
time
for
more
than
4also
decades.
MINVERTEXCOVER
isisat
aXingraph
problem
that
involves
nding
ofRecall
nodes
such
that
for
every
edge,
atproblem
least
one
ofnodes
its
endpoint
is
in
the
subset.
MAXINDEPENDENT
nodes
such
that
for
every
edge,
least
one
ofsubset
its
endpoint
is in
the
impossible
tolike
solve,
and
we
know
that
we
can
solve
problem
using
problem
Yleast
as immediate
aone
blackbox
.aT
I
des.
is
a
graph
problem
that
involves
nding
a
minimum
subset
des.
MINVERTEXCOVER
is
a
graph
problem
that
involves
a
minimum
subset
of
such
that
for
every
edge,
at
of
its
end
or
illustration.
that
NPhard
problems
have
yet
to
be
solved
in
polynomial
is
a
graph
problem
that
involves
nding
a
minimum
subset
Intractability
of
a
Problem
through
Reduction
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAXINDEPENDENTSET
is
a
graph
We
would
like
to
know
that
the
problem
that
we
are
attempting
is
unlikely
to
have
an
immediate
solution.
We
would
like
to
know
that
the
problem
that
we
are
attempting
is
unlikely
to
have
an
immediate
solution.
We
would
to
know
that
the
problem
that
we
are
attempting
is
unlikely
to
have
an
solu
such
that
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAXINDEPENDENTSET
is
a
es
a graph
minimum
subset
of
of
nodes
nodes
such
such
that
for
for every
every
edge,
edge,
at
at
least
least
one
one
of
of its
its
endpoint
isissubset
in
in the
theat
subset.
subset.
MAXINDEPE
MAXINDEPE
set.nding
MAXINDEPENDENTSET
isthat
athat
at
least
one
of
its problem
endpoint
is
in
the
subset.
MAXINDEPENDENTSET
afor
graph
graph
problem
problem
of
of
nding
nding
athat
aisendpoint
maximum
maximum
subset
of
of
nodes
nodes
such
such
that
that
for
for eT
hat
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAXINDEPENDENTSET
is
a
endp
of
nding
a
maximum
subset
of
nodes
such
that
every
edge,
most
one
of
its
endpo
of
nodes
such
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAXINDEPEN
graph
problem
of
nding
a
maximum
subset
of
nodes
such
for
every
edge,
at
most
one
of
its
endp
graph
problem
of
nding
a
maximum
subset
of
nodes
such
for
every
e
2
Identifying
Intractability
of
a
Problem
through
Redu
We
would
like
to
know
that
the
problem
that
we
are
attempting
is
unlikely
to
have
an
We
We
would
would
like
like
to
to
know
know
that
that
the
the
problem
problem
that
that
we
we
are
are
attempting
attempting
We
would
is
is
like
unlikely
unlikely
to
know
to
to
have
have
that
an
an
the
immediate
immediate
problem
that
solution.
solution.
we
are
The
The
att
solve
problem
Y,
then
we
can
solve
problem
X
as
well.
Therefore,
problem
Y
is
also
impossible
to
solve.
ry
edge,
at
least
of
its
endpoint
is
in
the
subset.
MAXINDEPENDENTSET
isof
athat
ry
at
least
its
endpoint
is
the
subset.
MAXINDEPENDENTSET
is
aat
graph
problem
ofsuch
nding
maximum
subset
of
nodes
su
VERTEXCOVER
iscommon
aof
graph
problem
involves
nding
aSuppose
minimum
subset
ndpoint
is
in
the
subset.
MAXINDEPENDENTSET
isfor
aof
problem
of
finding
ais
maximum
subset
of
nodes
such
that
for
every
edge,
most
one
of
toedge,
know
that
theone
problem
that
are
attempting
is
unlikely
tocalled
have
an
immediate
solution.
The
most
common
way
is
to
apply
anodes
wellknown
technique
called
reduction.
Suppose
we
know
that
problem
X
most
common
way
is
to
apply
ain
wellknown
technique
reduction.
Suppose
we
know
problem
most
way
to
apply
aat
technique
called
reduction.
Suppose
weisthat
know
that
pro
oblem
nding
aone
maximum
subset
such
that
every
edge,
at
one
its
endpoint
in most
XINDEPENDENTSET
is
aproblem
graph
graph
problem
of
ofthat
nding
nding
aawellknown
maximum
maximum
subset
subset
of
of
nodes
nodes
such
that
for
for
every
every
edge,
edge,
at
at
most
one
one
dge,
atof
most
one
of
its
endpoint
in
um
subset
nodes
such
that
forwe
every
edge,
most
one
its
endpoint
ismost
in
the
the
subset.
subset.
Suppose
we
we
already
already
know
know
that
MINVERTEXCOVER
MINVERTEXCOVER
isof
isoX
of
nding
aofsubset
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
the
subset.
Suppose
we
already
know
that
MINVERTEXCOVER
is
athat
NPhard
problem.
we
ci
graph
problem
of
nding
a maximum
subset
of
nodes
such
that
for
every
edge,
atTherefore,
most
one
of
the
subset.
Suppose
we
already
know
that
MINVERTEXCOVER
is
ato
NPhard
problem.
Therefore,
we
the
subset.
Suppose
we
already
know
that
MINVERTEXCOVER
is
aX
NPh
at
the
problem
that
we
are
attempting
is
unlikely
to
have
an
immediate
solution.
The
most
common
way
is
to
apply
a
wellknown
technique
called
reduction.
Suppose
we
most
most
common
common
way
way
is
is
to
to
apply
apply
a
a
wellknown
wellknown
technique
technique
most
called
called
common
reduction.
reduction.
way
Suppose
Suppose
is
apply
we
we
know
a
know
wellknown
that
that
problem
problem
technique
X
is
1
1
maximum
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
1is
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
the
subset.
Suppose
we
already
know
MINVERTEX
at
least
one
of
its
endpoint
is
in
the
subset.
MAXINDEPENDENTSET
is
a
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
its
endpoint
is
in
the
subset.
Suppose
we
already
know
that
MINVERTEXCOVER
is
way
isimpossible
to
apply
ato
wellknown
technique
called
reduction.
Suppose
we
know
that
problem
Xcan
is
impossible
to
solve,
and
we
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
blackbox
.
If
we
solve,
and
we
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
blackbox
.
If
we
impossible
to
solve,
and
we
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
blackbox
.
t.
Suppose
we
already
know
that
MINVERTEXCOVER
is
a
NPhard
problem.
Therefore,
we
show
most
one
of
its
endpoint
is
in
the
the
subset.
subset.
Suppose
Suppose
we
we
already
already
know
know
that
that
MINVERTEXCOVER
MINVERTEXCOVER
is
is
a
a
NPhard
NPhard
problem.
problem.
There
There
hard
problem.
Therefore,
we
can
show
ow
that
MINVERTEXCOVER
is
a
NPhard
problem.
Therefore,
we
can
show
that
that
MAXINDEPENDENTSET
MAXINDEPENDENTSET
is
is
also
also
a
a
NPhard
NPhard
problem
problem
by
by
reduc
reduc
We
would
likewe
toalso
know
that
the
problem
that
we
are
attempting
is aproblems
unlikely
to
have
an
immediate
solu
1problem
1reducing
pose
we
already
know
that
MINVERTEXCOVER
isknow
asolve
NPhard
problem.
Therefore,
can
show
1.solved
that
MAXINDEPENDENTSET
iswe
also
awe
NPhard
problem
by
awe
proble
the
subset.
Suppose
already
that
MINVERTEXCOVER
is
aas
NPhard
problem.
Therefo
that
MAXINDEPENDENTSET
ismost
also
asolve
NPhard
problem
by
reducing
MINVERTEXCOVER
probl
that
MAXINDEPENDENTSET
isreducing
also
apo
apply
a wellknown
technique
called
reduction.
Suppose
we
know
that
problem
XNPhard
isaMINVERTEXCOVER
impossible
to
solve,
and
also
know
that
we
can
solve
problem
X
by
using
Y
apM
impossible
impossible
to
solve,
solve,
and
and
we
also
know
know
that
that
we
can
can
problem
problem
impossible
X
X
by
to
by
using
solve,
using
problem
problem
and
Y
as
know
aproblem
aalso
blackbox
blackbox
that
we
.can
IfIf we
we
solve
can
can
are
using
NPhard
problems
for
illustration.
Recall
NPhard
have
yet
to
be
in
1also
eady
know
that
MINVERTEXCOVER
NPhard
problem.
Therefore,
we
can
show
eady
know
MINVERTEXCOVER
isiswe
aaproblem
NPhard
problem.
Therefore,
we
can
show
that
MAXINDEPENDENTSET
is
also
a by
NPhard
m
subset
of
such
that
for
every
edge,
at
one
of
its
endpoint
is
in
ato
NPhard
problem.
Therefore,
we
can
that
MAXINDEPENDENTSET
ainto
EXCOVER
isnodes
a We
NPhard
problem.
Therefore,
we
can
show
olve,
wethat
also
know
that
we
solve
problem
Xby
by
using
Y
as
aproblem.
blackbox
.YYIf
we
can
solve
problem
Y,
then
we
can
solve
problem
Xshow
as
well.
Therefore,
problem
Ywe
isreducing
also
impossible
to
solve.
solve
problem
Y,
then
we
can
solve
X
as
well.
Therefore,
Y
is
also
impossible
to
solve
problem
Y,
then
we
can
solve
problem
X
asaproblem
well.
Therefore,
problem
isis
also
impossible
to proble
solve
XINDEPENDENTSET
is
also
acan
NPhard
reducing
aNPhard
MINVERTEXCOVER
problem
a solve.
lem.
Therefore,
we
can
show
that
that
MAXINDEPENDENTSET
MAXINDEPENDENTSET
is
is
also
also
a
NPhard
problem
problem
by
by
reducing
a
a
MINVERTEXCOVE
MINVERTEXCOV
MINVERTEXCOVER
problem
into
a
also
aand
NPhard
problem
by
reducing
a
MINVERTEXCOVER
problem
into
a
MAXINDEPENDENTSET
MAXINDEPENDENTSET
problem.
1
most
common
way
is
to
apply
a
wellknown
technique
called
reduction.
Suppose
we
know
that
pro
EPENDENTSET
is
also
a
NPhard
problem
by
reducing
a
MINVERTEXCOVER
problem
into
a
MAXINDEPENDENTSET
problem.
that
MAXINDEPENDENTSET
is
also
a
NPhard
problem
by
reducing
a
MINVERTEXCOVER
MAXINDEPENDENTSET
problem.
MAXINDEPENDENTSET
problem.
e
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
blackbox
.
If
we
can
solve
problem
Y,
then
we
can
solve
problem
X
as
well.
Therefore,
problem
Y
is
also
imp
solve
solve
problem
problem
Y,
Y,
then
then
we
we
can
can
solve
solve
problem
problem
X
X
as
as
well.
well.
Therefore,
Therefore,
solve
problem
problem
problem
Y,
then
Y
Y
is
is
we
also
also
can
impossible
impossible
solve
problem
to
to
solve.
solve.
X
as
well.
T
time
for
more
than
4
decades.
MINVERTEXCOVER
is
a
graph
problem
that
involves
nding
a
minimum
TSET
also
NPhard
problem
byNPhard
reducing
a MINVERTEXCOVER
MINVERTEXCOVER
problem
into
problem
reducing
a aMINVERTEXCOVER
problem
aaaMAXINDETSET
also
aaNPhard
NPhard
problem
reducing
problem
into
problem.
w
that
MINVERTEXCOVER
aby
problem.
Therefore,
show into
blem
byisis
reducing
a problem.
MINVERTEXCOVER
problem
into
a MAXINDEPENDENTSET
Y,
then
we
can
solve
problem
Xisby
as
well.
Therefore,
problem
Y iswe
alsocan
impossible
to solve.
DEPENDENTSET
TEXCOVER
problem
into
asolve,
MAXINDEPENDENTSET
MAXINDEPENDENTSET
problem.
problem.
m.
impossible
tothat
and
weproblem
also know
weimpossible
canitssolve
problem
X the
by using
problem
Y as a blackbox1 .
NDENTSET
problem.
ability
of
a
Problem
through
Reduction
problem.
can
solve
problem
XMAXINDEPENDENTSET
as
well.
Therefore,
Yleast
isthat
also
to
solve.
of
nodes
such
for
every
edge,
at
one
of
endpoint
is
in
subset.
MAXINDEPENDENTPENDENTSET
problem.
T
problem.
T
problem.
also
a NPhard
problem
by
reducing
a
MINVERTEXCOVER
problem
into
a
Wesolve
areWe
using
NPhard
problems
for
illustration.
Recall
that
NPhard
problems
have
yet
to
be
solved
in polynom
polynom
We
are
using
NPhard
problems
for
illustration.
Recall
that
NPhard
problems
have
yet
to
be
solved
in
are
using
NPhard
problems
for
illustration.
Recall
that
NPhard
problems
have
yet
to be solved
in p
We
We
will
will
rst
rst
prove
prove
the
the
following
following
two
two
lemmas.
lemmas.
problem
Y,
then
we
can
solve
problem
Xthat
asfor
well.
Therefore,
problem
Y
isatbe
also
impossible
solve
We
will
rst
prove
following
lemmas.
We
will
rst
prove
the
following
two
lemmas.
Wetwo
will
rst
prove
the
following
two
lemmas.
Wethe
are
using
NPhard
problems
illustration.
Recall
that
NPhard
problems
have
yet
We
We
are
are
using
using
NPhard
NPhard
problems
problems
for
for
illustration.
illustration.
Recall
Recall
that
NPhard
NPhard
are
using
problems
problems
NPhard
have
have
problems
yet
yet
to
to
be
for
solved
solved
illustration.
in
in
polynomial
polynomial
Recall
t
graph
problem
of
nding
aMINVERTEXCOVER
maximum
subset
of
nodes
such
that
for
every
edge,
most
one
of
itsto
endpo
We
will
first
prove
the
following
two
lemmas.
We
will
rst
prove
the
following
two
lemmas.
2
Identifying
Intractability
of
a
Problem
through
m.
2
Identifying
Intractability
of
a
Problem
through
Red
gill
NPhard
problems
for
illustration.
Recall
that
NPhard
problems
have
yet
to
be
solved
in
polynomial
time
for
more
than
4
decades.
MINVERTEXCOVER
is
a
graph
problem
that
involves
nding
a
minimum
sub
time
for
more
than
4
decades.
is
a
graph
problem
that
involves
nding
a
minimum
sub
time
for
more
than
4
decades.
MINVERTEXCOVER
is
a
graph
problem
that
involves
nding
a
minimu
rst
prove
the
following
two
lemmas.
We
We
will
will
rst
rst
prove
prove
the
the
following
following
two
two
lemmas.
lemmas.
two
lemmas.
that we
are
attempting
is unlikely
to
havethe
anfollowing
immediate
solution.
The Intractability of a Pro
prove
the
following
two
lemmas.
2
Identifying
We
will
rst
prove
two
lemmas.
roblems
for
illustration.
Recall
that
NPhard
problems
have
yet
to
be
solved
in
polynomial
time
for
more
than
4
decades.
MINVERTEXCOVER
is
a
graph
problem
that
involves
time
time
for
more
more
than
than
4
4
decades.
decades.
MINVERTEXCOVER
MINVERTEXCOVER
is
is
time
a
a
graph
graph
for
problem
more
problem
than
that
that
4
decades.
involves
involves
nding
MINVERTEXCOVER
nding
a
a
minimum
minimum
subset
subset
is
the
subset.
Suppose
we
already
know
that
MINVERTEXCOVER
is
a
NPhard
problem.
Therefore,
we
c
for
Lemma
Lemma
1.
1.
If
If
S
S
V
V
is
is
an
an
INDEPENDENTSET
INDEPENDENTSET
of
of
graph
graph
G(V,
G(V,
E)
E)
2
Identifying
Intractability
of
a
Problem
through
Reduction
following
two
lemmas.
Problem
through
Reduction
following
lemmas.
than
4technique
decades.
MINVERTEXCOVER
isLemma
a we
graph
problem
that
involves
nding
a,the
minimum
subset
of two
nodes
such
that
for
every
edge,
at
least
one
ofSone
its
endpoint
is
in
the
subset.
MAXINDEPENDENTSET
of
nodes
such
that
edge,
at
least
one
of
its
endpoint
is
the
subset.
MAXINDEPENDENTSET
of
nodes
such
that
every
edge,
at
least
of of
its
endpoint
isE),
in
subset.
MAXINDEPENDENT
Lemma
1.
Ifusing
S
Vfor
anan
INDEPENDENTSET
graph
G(V,
then
VV
Shave
Lemma
1.
If
is
is
an
INDEPENDENTSET
then
is
isisaayet
Lemma
1.
Iffor
Severy
VisSuppose
INDEPENDENTSET
ofgraph
graph
G(V,
E),
then
S
aVERTEXCOVE
VERTEXCOV
1.
Ifthat
problem
V
is
an
INDEPENDENTSET
of
graph
G(V,
E),ofthen
nown
called
reduction.
know
X
isIfin
We
are
NPhard
problems
for
illustration.
Recall
that
NPhard
problems
to
be
inaas
Lemma
1.
S
V
is
an
INDEPENDENTSET
gra
We
would
like
to
know
that
the
problem
that
we
are
attempting
is is
unlikely
to
have
imme
We
would
like
to
know
that
the
problem
that
we
are
attempting
is
unlikely
to
have
an
immediate
des.
is
a
graph
problem
involves
nding
a
minimum
subset
of
nodes
such
that
for
every
edge,
at
least
one
of
its
endpoint
in
the
subset.
MAXIN
of
nodes
such
such
that
that
for
for
every
every
edge,
edge,
at
at
least
least
one
one
of
of
its
its
endpoint
endpoint
of
nodes
is
is
in
such
in
the
the
that
subset.
subset.
for
every
MAXINDEPENDENTSET
MAXINDEPENDENTSET
edge,
at
least
one
of
its
isisend
that
MAXINDEPENDENTSET
is
also
a
NPhard
problem
by
reducing
a
MINVERTEXCOVER
proble
1.
IfVMINVERTEXCOVER
Snodes
V
is
an
INDEPENDENTSET
of
graph
G(V,
E),
then
V
S
is
a
VERTEXCOVER
of
the
Lemma
Lemma
1.
1.
If
If
S
S
V
V
is
is
an
an
INDEPENDENTSET
INDEPENDENTSET
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
V
V
S
Sits
is
isendpoint
asolved
aan
VERTE
VERTE
Vof
S
is
a
VERTEXCOVER
of
the
ENDENTSET
of
graph
G(V,
E),
then
S
is
a
VERTEXCOVER
of
the
graph
graph
G(V,
G(V,
E)
E)
two
lemmas.
1
that
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAXINDEPENDENTSET
is
a
is
an
INDEPENDENTSET
of
graph
G(V,
E),
then
V
S
is
a
VERTEXCOVER
of
the
graph
problem
of
nding
a
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
graph
problem
of
nding
a
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
iui
VERTEXCOVER
of
the
graph
graph
problem
of
nding
a
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endp
graph
G(V,
E)
Lemma
1.
If
S
V
is
an
INDEPENDENTSET
of
graph
G(V,
E),
then
V
S
is
a
VERTEX
G(V,
E)
graph
G(V,
E)
ability
of
a
Problem
through
Reduction
.
at
we
can
solve
problem
X
by
using
problem
Y
as
a
blackbox
.
If
we
can
We
would
like
to
know
that
the
problem
that
we
are
attempting
is
nsing
of
graph
G(V,
E),
then
Vare
Sthe
issuch
VERTEXCOVER
of
the
time
fornding
more
than
4E)
decades.
MINVERTEXCOVER
is
aevery
graph
problem
that
involves
nding
aat
minim
ngraph
INDEPENDENTSET
of
G(V,
E),
then
S
is
aagraph
VERTEXCOVER
of
the
G(V,
E)
G(V,
E),
then
V
Sgraph
away
VERTEXCOVER
ofaMAXINDEPENDENTSET
We
like
to
know
that
problem
that
we
attempting
is
unlikely
to
have
immediate
solution.
The
iswould
unlikely
to
have
an
immediate
The
most
common
way
is
to
apply
amaximum
wellknown
technique
called
reduction.
Suppose
we
most
common
issolution.
to
apply
aV
wellknown
technique
called
Suppose
we
know
that
ry
edge,
at
one
of
its
endpoint
in
the
subset.
is
amost
graph
problem
of
nding
subset
of
such
that
for
every
edge,
most
graph
graph
problem
problem
of
of
nding
ais
athe
maximum
maximum
subset
subset
of
of
nodes
nodes
such
graph
that
that
problem
for
for
every
ofaanodes
edge,
nding
edge,
at
atendpoint
aan
most
maximum
one
one
ofsubset
its
its
endpoint
endpoint
of
nodes
isknow
is in
su
in
MAXINDEPENDENTSET
problem.
V,
E)
aINDEPENDENTSET
VERTEXCOVER
of
the
graph
graph
G(V,
G(V,
E)
of
nding
aleast
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
ofaisreduction.
its
is of
in
thewell.
subset.
Suppose
we
already
know
that
MINVERTEXCOVER
is
NPhard
problem.
Therefore,
we
can
sh
the
subset.
Suppose
we
already
know
that
MINVERTEXCOVER
is
NPhard
problem.
Therefore,
we
can
sh
the
subset.
Suppose
we
already
know
that
MINVERTEXCOVER
a
NPhard
problem.
Therefore,
we
graph
G(V,
E)
ing
Intractability
of
a
Problem
through
Reduction
em
X
as
Therefore,
problem
Y
is
also
impossible
to
solve.
most
common
way
is
to
apply
wellknown
technique
called
reduc
Proof.
Proof.
Let
us
us
assume
assume
that
that
VSuppose
Vis
in
SSXthe
is
is
not
not
aaby
VERTEXCOVER.
VERTEXCOVER.
Ther
Ther
of
nodes
such
that
for
every
edge,
at
least
one
of
itsthat
endpoint
subset.
MAXINDEPENDENT
of
graph
G(V,
E),
then
Vthat
SMINVERTEXCOVER
is
anot
VERTEXCOVER
of
the
Proof.
Let
us
assume
that
is
aaat
VERTEXCOVER.
Therefore,
there
are
two
common
way
is
to
apply
athat
wellknown
called
reduction.
we
know
that
problem
XA,
is
dmost
reduction.
Suppose
we
know
problem
Xis
isnot
impossible
to
solve,
and
we
also
know
that
we
can
solve
problem
X
using
problem
Y
as
aBb
impossible
to
solve,
and
we
also
know
that
we
can
solve
using
problem
Y
as
acan
blackbo
aENDENTSET
maximum
subset
of
nodes
such
that
for
every
edge,
most
one
of
endpoint
is
in
the
subset.
we
already
know
MINVERTEXCOVER
is
atwo
NPhard
problem.
the
thewe
subset.
subset.
Suppose
Suppose
we
we
already
already
know
know
that
MINVERTEXCOVER
the
subset.
is
Suppose
a
aproblem
NPhard
NPhard
we
problem.
problem.
already
know
Therefore,
that
MINVERTEX
we
we
can
show
show
Proof.
Let
us
that
VSuppose
S
VERTEXCOVER.
Therefore,
there
are
B
/
Proof.
Let
us
assume
that
V
Stechnique
is
not
aLet
VERTEXCOVER.
there
are
two
vertices
A,
Let
us
assume
that
Visits
STherefore,
isTherefore,
not
aby
VERTEXCOVER.
Therefore,
that
are
attempting
isassume
unlikely
to
have
an
solution.
The
ppose
we
already
know
that
MINVERTEXCOVER
is
NPhard
problem.
can
show
that
MAXINDEPENDENTSET
isProof.
also
aand
NPhard
problem
by
reducing
MINVERTEXCOVER
problem
int
Proof.
Let
us
assume
that
VMINVERTEXCOVER
STherefore,
is
not
a1vertices
VERTEXCO
that
MAXINDEPENDENTSET
is
also
NPhard
problem
by
reducing
aaknow
MINVERTEXCOVER
problem
int
that
MAXINDEPENDENTSET
isaimmediate
also
aSaS
NPhard
problem
by
reducing
awe
probl
impossible
to
solve,
and
we
also
that
we
can
solve
problem
Xend
by
1
et
us
assume
that
V
S
is
not
a
VERTEXCOVER.
Therefore,
there
are
two
vertices
A,
B
/
V
S
Proof.
Proof.
Let
Let
us
us
assume
assume
that
that
V
V
is
is
not
not
a
a
VERTEXCOVER.
VERTEXCOVER.
Therefore,
Therefore,
there
there
are
are
two
two
vertic
vertic
there
are
two
vertices
A,
B
/
V
S
is
not
a
VERTEXCOVER.
Therefore,
there
are
two
vertices
A,
B
/
V
S
and
there
there
is
is
an
an
edge
edge
connecting
connecting
A
A
and
and
B.
B.
Since
Since
A,
A,
B
B
/
V
V
S,
S,
we
we
graph
problem
of
nding
a
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
vertices
and
there
is
an
edge
connecting
and
.
Since
impossible
to
solve,
and
we
also
know
that
we
can
solve
problem
X
by
using
problem
Y
as
a
blackbox
.
If
we
can
m
X
by
using
problem
Y
as
a
blackbox
.
If
we
can
solve
problem
Y,
then
we
can
solve
problem
X
as
well.
Therefore,
problem
Y
is
also
impossib
ssume
that
V
S
is
not
a
VERTEXCOVER.
Therefore,
there
are
two
vertices
A,
B
/
V
S
solve
problem
Y,
then
we
can
solve
problem
X
as
well.
Therefore,
problem
Y
is
also
impossible
to
so
ready
know
that
MINVERTEXCOVER
is
a
NPhard
problem.
Therefore,
we
can
show
that
MAXINDEPENDENTSET
is
also
a
NPhard
problem
by
reducing
a
MINVERTEX
that
that
MAXINDEPENDENTSET
MAXINDEPENDENTSET
is
is
also
also
a
a
NPhard
NPhard
problem
problem
that
by
by
MAXINDEPENDENTSET
reducing
reducing
a
a
MINVERTEXCOVER
MINVERTEXCOVER
is
also
a
problem
problem
NPhard
into
into
proble
a
a
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
/
V
S,
we
have
A,
B
S.
As
A
and
B
are
co
We
will
rst
prove
the
following
two
lemmas.
Proof.
Let
us
assume
that
V
S
is
not
a
VERTEXCOVER.
Therefore,
there
are
two
vertice
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
/
V
S,
we
have
A,
B
S.
As
A
and
B
are
c
and
is
an
edge
connecting
A
and
B.
A,A
Band
/a VB.Since
S, weA,
have
ow
that
the
problem
that
we
are
attempting
isB
unlikely
to
have
an
immediate
solution.
The
nown
technique
called
reduction.
Suppose
wethere
know
that
problem
XBis
isA,
DEPENDENTSET
is
also
athere
NPhard
problem
by
reducing
atwo
MINVERTEXCOVER
problem
into
is
not
VERTEXCOVER.
Therefore,
there
are
two
vertices
A,
B
/is
SSince
VV
SSMAXINDEPENDENTSET
is
not
aathat
VERTEXCOVER.
Therefore,
there
are
A,
B
//
VVA
S
MAXINDEPENDENTSET
problem.
and
there
anS.
edge
connecting
B
/A
problem.
Therefore,
there
are
two
vertices
A,
/be
V
S
MAXINDEPENDENTSET
problem.
stration.
Recall
NPhard
problems
have
yet
solved
in
polynomial
solve
problem
Y,vertices
then
we
can
solve
problem
X
as
well.
Therefore,
pro
etCOVER.
isBMAXINDEPENDENTSET
an
edge
connecting
A
and
B.
Since
A,
B
/to
S,
we
have
A,
As
B
are
connected
two
vertices
A,
B
/and
Vimpossible
S
and
there
isproblem.
isto
an
an
edge
edge
connecting
connecting
A
A
and
and
B.
B.
Since
Since
A,
B
B
Vby
V
S,
S,
we
we
have
have
A,
A,
B
B Therefore
S.
S. As
As A
AThis
and
and
A,
B.
S.
As
A
and
B
are
connected
and
Since
A,
B
/and
Vwe
S,
we
have
A,
B
S.
As
A
B
are
connected
by
by
an
an
edge,
edge,
we
we
note
note
that
that
S
S
not
not
an
an
INDEPENDENTSET.
INDEPENDENTSET.
Thi
,note
we
have
.V
As
and
and
Since
are
connected
an
edge,
we
note
the
subset.
Suppose
we
already
that
MINVERTEXCOVER
isinto
aand
NPhard
problem.
Therefore,
we
solve
problem
Y,
then
can
solve
problem
Xknow
as
well.
Therefore,
problem
Y
isis
also
impossible
to
solve.
ore,
problem
Y
isNPhard
also
solve.
edge
connecting
A
B.
Since
A,
B
/
V
S,
we
have
A,
S.
As
A
and
B
are
connected
TSET
is
also
a
problem
by
reducing
a
MINVERTEXCOVER
problem
a
MAXINDEPENDENTSET
problem.
MAXINDEPENDENTSET
problem.
MAXINDEPENDENTSET
problem.
1 B that
by
an
edge,
we
that
S
is
not
an
INDEPENDENTSET.
This
is
a
contradiction.
V
there
is
an
edge
connecting
A
and
B.
A,
B
/
V
S,
we
have
A,
B
S.
As
A
and
B
by
an
edge,
we
note
that
S
is
not
an
INDEPENDENTSET.
This
is
a
contradiction.
Therefore
V
by
an
edge,
we
note
S
is
not
an
INDEPENDENTSET.
This
is
a
c
is
to
apply
a
wellknown
technique
called
reduction.
Suppose
we
know
that
problem
X
is
at
we
can
solve
problem
X
by
using
problem
Y
as
a
blackbox
.
If
we
can
NDENTSET
problem.
ecting
Aand
and
B.
Since
A,
B
/This
VVINDEPENDENTSET.
S,
we
have
A,
B
S.
As
A
and
BVSare
are
connected
tifying
Intractability
of
aare
Problem
Reduction
ecting
and
B.
A,
/
V
we
A,
B
S.
As
A
and
B
byaisINDEPENDENTSET.
an
edge,
we
note
that
SVMINVERTEXCOVER
isisisnot
an
INDEPENDENT
stge,
not
aA
VERTEXCOVER.
Therefore,
there
two
vertices
A,
B
/
is
Sconnected
/As
Vwe
S,
we
have
VB
S.
As
A
and
Bhave
are
connected
TEXCOVER
is
aSince
graph
problem
that
nding
aanot
minimum
subset
Lemma
If
SWe
is
INDEPENDENTSET
of
graph
G(V,
E),
then
is
aa VERTEXCOVE
note
that
SA,
is
not
an
This
athrough
contradiction.
Therefore
VSis
S
isyethave
a to be
A
B
are
connected
by
byB
an
an
edge,
edge,
we
we
note
note
that
that
S
S
isis
not
an
an
INDEPENDENTSET.
This
This
aa
contradiction.
contradiction.
Ther
The
that
1.
is
not
an
INDEPENDENTSET.
This
is
contradiction.
Therefore
is
contradiction.
Therefore
S
is
aan
an
INDEPENDENTSET.
isS,
ainvolves
contradiction.
Therefore
V
areducing
VERTEXCOVER.
VERTEXCOVER.
that
MAXINDEPENDENTSET
is
also
NPhard
problem
by
aproblems
prob
are
using
NPhard
problems
for
illustration.
Recall
that
NPhard
problems
yet
to
be
note
that
S
is
not
an
INDEPENDENTSET.
This
is
a
contradiction.
Therefore
V
S
a
We
are
using
NPhard
problems
for
illustration.
Recall
that
NPhard
have
solved
T
problem.
1 This
VERTEXCOVER.
by
an
edge,
we
note
that
S
is
not
an
INDEPENDENTSET.
is
a
contradiction.
There
VERTEXCOVER.
VERTEXCOVER.
we
also
know
can
solve
problem
using
problem
Y connected
asisaablackbox
.is
we can
em
X
as
well.
Therefore,
problem
Ythe
isThis
also
impossible
is
not
an
INDEPENDENTSET.
This
is
contradiction.
Therefore
SS for
isIfaaillustration.
SS one
is
an
INDEPENDENTSET.
is
contradiction.
Therefore
VV
We
will
rst
prove
the
following
two
lemmas.
VERTEXCOVER.
and
B.not
Since
A,
Bathat
/contradiction.
VSiswe
S,
we
have
A,
Bproblem.
XaaS.
As
and
B are
We
will
rst
prove
the
following
two
lemmas.
NTSET.
This
isWe
Therefore
Vby
SA
isto
asolve.
will
rst
prove
following
two
lemmas.
st
of
its
endpoint
in
subset.
MAXINDEPENDENTSET
We
are
using
NPhard
problems
Recall
that NPhard
VERTEXCOVER.
graph
G(V,
E)
COVER.
tion.
Therefore
V
is
athe
VERTEXCOVER.
VERTEXCOVER.
MAXINDEPENDENTSET
Wecan
are
using
NPhard
problems
illustration.
Recall
that
NPhard
problems
have
yet
to
be solved
in involves
polynomial
NPhard
problems
have
yet
to
be
solved
in
polynomial
time
for
more
than
4lemmas.
decades.
MINVERTEXCOVER
issolve.
a problem
graph
problem
that
ndin
ER.
time
for
more
than
4are
decades.
MINVERTEXCOVER
is
aimmediate
graph
that
involves
nding
min
We
will
rst
prove
the
following
two
lemmas.
We
We
will
will
rst
rst
prove
prove
the
the
following
following
two
two
lemmas.
We
will
rst
prove
the
following
two
lemmas.
VERTEXCOVER.
to
know
that
the
problem
that
weisfor
attempting
is unlikely
to
have
an
solution.
en
we
solve
problem
X
as
well.
Therefore,
problem
Y
is
also
impossible
to
Lemma
Lemma
2.
2.
If
If
S
S
V
V
is
is
a
a
VERTEXCOVER
VERTEXCOVER
of
ofThe
graph
graph
G(V,
G(V,
E),
E),a prob
then
the
t
prove
the
following
two
lemmas.
an
INDEPENDENTSET.
This
a
contradiction.
Therefore
V
S
is
a
bset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
time
for
more
than
4
decades.
MINVERTEXCOVER
is
a graph
Lemma
2.
If
S
V
is
a
VERTEXCOVER
of
graph
G(V,
E),
then
V
S
is
an
INDEPENDENTSE
Lemma
2.
If
S
V
is
a
VERTEXCOVER
of
graph
G(V,
E),
then
V
S
is
an
INDEPENDENTS
Lemma
2.
If
S
V
is
a
VERTEXCOVER
of
graph
G(V,
E),
then
V of
time
for
more
than
4
decades.
MINVERTEXCOVER
is
a
graph
problem
that
involves
nding
a
minimum
subset
ph
problem
that
involves
nding
a
minimum
subset
of
nodes
such
that
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAXINDEP
Lemma
1.
If
S
V
is
an
INDEPENDENTSET
of
graph
G(V,
E),
then
V
S
is
a
VERTEXCOVER
of
Lemma
2.
If
S
V
is
a
VERTEXCOVER
of
graph
G
of
nodes
such
that
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAXINDEPENDE
following
two
lemmas.
Lemma
1.
If
S
V
is
an
INDEPENDENTSET
of
G(V,
E),
then
V
S
is
a
VERTEXCOVER
Lemma
2.
If
is
a
VERTEXCOVER
graph
,
then
an
INLemma
1.
If
S
V
is
an
INDEPENDENTSET
graph
G(V,
E),
then
V
S
is
a
VERTEXCOV
nXCOVER
way
to
apply
aLet
wellknown
technique
called
reduction.
Suppose
we
know
that
problem
X SS
isofisisthe
Proof.
usE),
assume
that
VS
is
not
aG(V,
VERTEXCOVER.
Therefore,
there
two
vertices
A,
B
2.
IfVan
Sis
V
is
a SS
VERTEXCOVER
graph
E),
then
Vthat
Sof
is
an
INDEPENDENTSET
Lemma
Lemma
2.
2.
IfIfthe
SSof
VV
is
isS
aaG(V,
VERTEXCOVER
VERTEXCOVER
of
graph
graph
G(V,
G(V,
E),
E),
then
then
VVare
an
anVINDEPEND
INDEPEND
stration.
Recall
that
NPhard
problems
have
yet
to
be
solved
in
polynomial
S
isLemma
INDEPENDENTSET
of
of
graph
G(V,
then
V
is
an
INDEPENDENTSET
of
the
graph
graph
G(V,
E)
E)
at
MINVERTEXCOVER
a
NPhard
problem.
Therefore,
we
can
show
of
nodes
such
for
every
edge,
at
least
one
of
its
endpoint
is
in
t
is
a
VERTEXCOVER
of
graph
G(V,
E),
then
V
S
is
an
INDEPENDENTSET
of
the
Lemma
1.
If
S
V
is
an
INDEPENDENTSET
of
graph
G(V,
E),
then
S
is
a
Lemma
1.
1.
Lemma
1.
If
If
V
V
is
is
an
an
INDEPENDENTSET
INDEPENDENTSET
of
of
graph
graph
G(V,
G(V,
E),
E),
If
then
then
S
V
V
is
S
S
an
is
is
INDEPENDENTSET
a
a
VERTEXCOVER
VERTEXCOVER
of
of
of
the
the
gra
graph
G(V,
E)
Lemma
2.
If
S
V
is
a
VERTEXCOVER
of
graph
G(V,
E),
then
V
S
is
an
INDEPENDE
graph
G(V,
E)
V
graph
G(V,
E)
We
will
rst
prove
the
following
two
lemmas.
1
of
nodes
such
that
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAXINDEPENDENTSET
is
a
thard
is
in
the
subset.
MAXINDEPENDENTSET
is
a
S
V
is
an
INDEPENDENTSET
of
graph
G(V,
E),
then
V
S
is
a
VERTEXCOVER
of
the
graph
problem
of
nding
a
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
VERTEXCOVER
of
graph
G(V,
E),
then
V
S
is
an
INDEPENDENTSET
of
the
VERTEXCOVER
of
graph
G(V,
E),
then
Vmaximum
Sproblems
isB.
an
INDEPENDENTSET
ofhave
the
graph
G(V,
E)
DEPENDENTSET
of
the
graph
graph
G(V,
E)
graph
problem
of
nding
aproblem
of
nodes
for
every
at
most
oneBofare
itscoeV
graph
G(V,
E)
G(V,
E),
then
Vathere
S
isthat
anG(V,
INDEPENDENTSET
ofby
the
graph
G(V,
E)
.subset
solve,
and
we
also
know
we
can
solve
X
using
problem
Ysuch
as
athat
blackbox
.B
Ifedge,
weS.can
and
is
an
edge
connecting
A
and
Since
A,
B
/
V
S,
we
A,
As
A
and
V,
E)
problems
for
illustration.
Recall
that
NPhard
have
yet
to
be
solved
in
polynomial
NDEPENDENTSET
of
the
graph
graph
G(V,
E)
E)
TEXCOVER
is
graph
problem
that
involves
nding
a
minimum
subset
a
NPhard
problem
by
reducing
a
MINVERTEXCOVER
problem
into
a
graph
of is
nding
maximum
subset
nodes
such
that
for
e
ngraph
INDEPENDENTSET
ofaG(V,
graph
G(V,
E),
then
V problem
SThe
is proof
agraph
VERTEXCOVER
of
the
graph
E)
graph
graph
G(V,
G(V,
E)
E)
G(V,
E)athe
graph
E)its
problem
of
nding
maximum
subset
ofis
nodes
such
that
for
every
edge,
atto
one
endpoint
is
for
every
edge,
at
most
one
endpoint
in
Proof.
Proof.
The
proof
is
actually
actually
similar
similar
to
to
the
the
previous
previous
lemma.
lemma.
Let
Let
us
usinassu
assu
the
subset.
we
already
know
that
MINVERTEXCOVER
is
aof
NPhard
problem.
The
the
subset.
Suppose
we
already
know
that
MINVERTEXCOVER
ismost
athat
NPhard
problem.
Therefore,
XCOVER
ofMINVERTEXCOVER
graph
G(V,
E),
then
VSuppose
S
is
an
INDEPENDENTSET
Y,decades.
then
can
solve
problem
X
as
well.
Therefore,
problem
Y
isof
also
impossible
solve.
Proof.
The
is
actually
similar
to
the
previous
lemma.
Let
us
assume
that
V
Sof
not
aVERTEXCOV
INDEPENDE
by
an
edge,
we
note
S
is
not
an
INDEPENDENTSET.
This
is
athat
contradiction.
Therefore
V
4at
is
graph
problem
that
involves
nding
aus
minimum
subset
Proof.
The
proof
isof
actually
similar
to
the
previous
lemma.
Let
assume
Sisits
is
not
avertices
INDEPEND
st
one
ofwe
its
endpoint
is
in
subset.
MAXINDEPENDENTSET
issimilar
aof
Proof.
The
proof
isSuppose
actually
to
the
previous
lemma.
Let
us
assume
tha
Lemma
1.proof
If the
S
Vthat
isa
an
INDEPENDENTSET
graph
G(V,
E),
then
VV
is
aprevious
Proof.
The
proof
is
actually
similar
to
the
previous
lemma.
Let
us
assume
is
the
subset.
we
already
know
that
MINVERTEXCOVER
is
Proof.
Let
us
assume
that
V
S
is
not
a
VERTEXCOVER.
Therefore,
there
are
two
vertices
A,
B
/
V
Proof.
The
proof
is
actually
similar
to
the
lemma.
Proof.
Let
us
assume
that
V
S
is
not
a
VERTEXCOVER.
Therefore,
there
are
two
vertices
A,
B
/
V
Proof.
Let
us
assume
that
V
S
is
not
a
VERTEXCOVER.
Therefore,
there
are
two
A,
B
proof
actually
similar
to
the
previous
lemma.
Let
usa assume
that
V
S
isproblem
not
aA,
INDEPENDENTSET.
Proof.
Proof.
The
The
proof
proof
is
isus
actually
actually
similar
similar
to
to
the
the
previous
previous
lemma.
lemma.
Let
Let
us
us
assume
assume
that
V
V
SSthere
isisis
not
not
aa
IND
IND
the
subset.
Suppose
we
already
know
that
MINVERTEXCOVER
isTherefore,
alemma.
NPhard
problem.
we
can
show
VER
isSprevious
aisis
NPhard
problem.
Therefore,
we
can
show
the
Visthe
not
aus
INDEPENDENTSET.
to
lemma.
Let
us
assume
that
VLet
aA,
SA,
isassume
INDEPENDENTSET.
Therefore,
Therefore,
there
there
are
two
two
vertices
vertices
A,
B
B
reducing
Vtwo
VaVisTherefore,
Sthat
SA
and
there
there
is
an
an
edge
edge
that
MAXINDEPENDENTSET
also
aare
NPhard
by
aand
MINVERTEXCO
that
MAXINDEPENDENTSET
isnot
also
aisthe
NPhard
problem
by
reducing
MINVERTEXCOVER
pr
of
actually
similar
to
the
previous
lemma.
us
that
V
S
is
not
a
INDEPENDENTSET.
Proof.
Let
assume
that
V
S
is
not
a
VERTEXCOVER.
Therefore,
are
two
Proof.
Proof.
Proof.
Let
Let
us
assume
assume
that
that
V
V
S
S
is
is
not
not
a
VERTEXCOVER.
VERTEXCOVER.
Therefore,
Let
us
assume
there
there
that
are
are
two
S
vertices
vertices
is
not
A,
A,
a
VERTEXCO
B
B
/
V
V
S
S
Therefore,
there
are
two
vertices
B
S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
VERTEXCOVER.
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAXINDEPENDENTSET
a
Proof.
The
proof
is
actually
similar
to
previous
Let
us
assume
that
V
S
is
not
a
INDE
Therefore,
there
are
two
vertices
B
S
and
there
is
an
edge
connecting
and
B.
Since
A,
B
bset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
Therefore,
there
are
vertices
A,
B
S
and
there
is
an
edge
conne
not
a
INDEPENDENTSET.
Therefore,
there
two
vertices
and
graph
G(V,
E)
that
Vprevious
San
is
not
aconnecting
VERTEXCOVER.
Therefore,
there
are
two
vertices
A,
B
/NPhard
VB
ysassume
similar
to
the
previous
lemma.
Let
us
assume
that
B.
SA,
is
not
aA,
INDEPENDENTSET.
that
MAXINDEPENDENTSET
isA,
also
aS.
problem
by
reduc
yye,
similar
to
lemma.
Let
assume
that
VV
S
is
not
INDEPENDENTSET.
and
there
is
an
edge
connecting
Aatwo
and
B.
Since
A,
B
V
S,
we
have
A,
B
A,
S.
As
ASVan
and
Band
are
connec
Therefore,
there
are
two
vertices
A,
B
Vedge,
S
and
ther
and
there
is
A
and
B.
Since
A,
B
/a/V
V
we
have
B
As
A
and
B
are
connec
ma.
Let
us
assume
that
Vedge
SB
is
not
aus
INDEPENDENTSET.
and
there
is
an
edge
A
and
Since
B
/S,
V
S,
we
have
B
S.
As
A
B
are
c
there
are
two
vertices
A,
Vthere
STherefore,
and
there
an
edge
connecting
A
and
B.
Since
A,
S,
not
aMAXINDEPENDENTSET
INDEPENDENTSET.
Therefore,
Therefore,
there
are
are
two
vertices
vertices
A,
B
B
V
S
S
and
and
there
there
is
is
an
an
edge
edge
connecting
connecting
A
A
and
and
B.
B.
Sin
Sin
isconnecting
also
NPhard
problem
by
reducing
aand
MINVERTEXCOVER
problem
into
aB
reducing
athe
MINVERTEXCOVER
problem
into
ais
A
and
B.
Since
A,
Vthere
S,
,that
B
VS
S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
S,
we
we
have
have
A,
A,
B
B
/
/
S.
S.
As
As
A
AA,
and
B
B
are
are
connected
connected
by
by
an
edge,
we
we
note
note
MAXINDEPENDENTSET
problem.
MAXINDEPENDENTSET
problem.
ng
NPhard
problems
for
illustration.
Recall
that
NPhard
problems
have
yet
to
be
solved
in
polynomial
eat
are
vertices
A,
B
VB
S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
V
we
S,
tcting
VMINVERTEXCOVER
two
is
not
aan
VERTEXCOVER.
there
are
two
vertices
B
/A,
V
S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
/S,
V
S,
have
A,
B
S.
As
and
and
there
there
is
is
an
edge
edge
connecting
connecting
A
A
and
and
B.
B.
Since
Since
A,
A,
B
B
/
and
V
there
S,
S,
we
we
is
have
an
have
edge
A,
B
B
connecting
S.
S.
As
As
A
A
A
and
and
and
B
B
B.
are
are
Since
connected
connected
A,
/
we
have
A,
B
/
S.
As
A
and
B
are
connected
by
an
edge,
we
note
that
S
is
not
a
VERTEXCOVER.
T
nding
a
maximum
subset
of
nodes
such
that
for
every
edge,
at
most
one
of
its
endpoint
is
in
Therefore,
are
two
vertices
S
there
is
an
edge
connecting
A
and
B.
Sinc
we
have
A,
B
/
S.
As
B
are
connected
by
an
edge,
we
note
that
S
is
not
a
VERTEXCOVER.
is
edge
connecting
and
.
Since
,
have
.
As
and
is
a
NPhard
problem.
Therefore,
we
can
show
we
have
A,
B
/
S.
As
A
and
B
are
connected
by
an
edge,
we
note
that
S
n
edge
connecting
A
and
B.
Since
A,
B
/
V
S,
we
have
A,
B
S.
As
A
and
B
are
connected
ertices
A,
B
S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
S,
emmas.
MAXINDEPENDENTSET
problem.
ertices
A,
B
S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
by
an
edge,
we
note
that
S
is
not
an
INDEPENDENTSET.
This
is
a
contradiction.
Therefore
V
S
we
have
A,
B
/
S.
As
A
and
B
are
connected
by
an
edg
o
the
previous
lemma.
Let
us
assume
that
V
S
is
not
a
INDEPENDENTSET.
by
an
edge,
we
note
that
S
is
not
an
INDEPENDENTSET.
This
is
a
contradiction.
Therefore
V
S
here
is
an
edge
connecting
Aconnected
and
B.
A,
B
Vnot
S,of
by
an
edge,
we
note
that
S
is
not
an
INDEPENDENTSET.
This
isnote
aINDEPENDENTSET.
Therefore
VBi
Lemma
2.
If
S
Vby
isedge,
aSince
VERTEXCOVER
graph
G(V,
E),
then
V
Scontradiction.
is
an
INDEPENDENTSE
B
/
S.
As
A
and
B
are
by
an
edge,
we
note
that
S
is
not
a
VERTEXCOVER.
This
is
a
and
B.
Since
A,
B
S,
we
we
have
have
A,
A,
B
B
/
S.
S.
As
As
A
A
and
and
B
B
are
are
connected
connected
by
by
an
an
edge,
edge,
we
we
note
that
that
S
S
is
is
not
not
a
a
VERTEXC
VERTEXMAXINDEPENDENTSET
problem.
is
not
a
VERTEXCOVER.
This
is
a
eA,
connected
by
an
edge,
we
note
that
S
is
not
a
VERTEXCOVER.
This
is
a
contradiction.
contradiction.
Therefore
Therefore
V
V
S
S
is
is
an
an
INDEPENDENTSET.
Proof.
Let
us
assume
that
V
S
is
a
VERTEXCOVER.
Therefore,
there
are
two
vertices
A,
than
4
decades.
MINVERTEXCOVER
is
a
graph
problem
that
involves
nding
a
minimum
subset
S.
As
A
and
B
are
connected
an
edge,
we
note
that
S
is
not
a
VERTEXCOVER.
This
is
a
ecting
A
and
B.
Since
A,
B
/
V
S,
we
have
A,
B
S.
As
A
and
B
are
connected
by
an
we
note
that
S
is
not
an
INDEPENDENTSET.
This
is
a
contradiction
by
by
an
an
edge,
edge,
we
we
note
note
that
that
by
edge,
note
that
SS
is
not
an
an
INDEPENDENTSET.
INDEPENDENTSET.
This
This
isisedge,
aan
aTherefore
contradiction.
contradiction.
Sshow
isisis
not
Therefore
INDEPENDENT
V
SS isis aa
is
are
connected
by
an
edge,
we
note
that
problem
iscontradiction.
notanaBVERTEXCOVER.
aTherefore
concontradiction.
Therefore
V
Sthat
isand
an
INDEPENDENTSET.
we
already
know
that
MINVERTEXCOVER
isSSan
ais
NPhard
problem.
we
can
we
have
A,VERTEXCOVER.
B
/not
S.
As
A
areisisaTherefore
connected
by
an
we
that
S
isan
not
a VVERTEXC
contradiction.
V
S
is
INDEPENDENTSET.
and
NPhard
problem
aiswe
MINVERTEXCOVER
into
aSwe
contradiction.
V
Therefore,
INDEPENDENTSET.
eVERTEXCOVER.
note
that
S
not
an
INDEPENDENTSET.
This
aVERTEXCOVER.
contradiction.
V
S
is
aINDEPENDENTSE
and
B
are
connected
by
an
we
note
that
isB
not
aan
This
isnote
B
are
connected
by
an
edge,
note
not
VERTEXCOVER.
This
is
VERTEXCOVER.
Therefore
VaaThis
S
an
B
V
note
S
and
is
an
edge
connecting
A
and
B.
Since
S,
VERTEXCOVER.
edge,
we
that
Sby
isreducing
not
aTherefore
This
alemmas.
VERTEXCOVER.
graph
G(V,
E)
tion.
Therefore
Visthere
S
is
an
INDEPENDENTSET.
This
is
aedge,
contradiction.
contradiction.
Therefore
Therefore
V
VA
SS
isis
an
INDEPENDENTSET.
INDEPENDENTSET.
an
INDEPENDENTSET.
We
will
rst
prove
the
following
twoA,A,
lemmas.
and
there
is
an
edge
connecting
and
B.
Since
Bthe
/VV
S,
we
have
A,
B
We
will
rst
prove
the
following
two
that
for
every
edge,
at
least
one
of
its
endpoint
is
in
the
subset.
MAXINDEPENDENTSET
isS.a As A and B are
ENTSET
of
graph
G(V,
E),
then
V
S
is
a
VERTEXCOVER
of
Therefore
V
S
an
INDEPENDENTSET.
S
is
not
an
INDEPENDENTSET.
This
is
a
contradiction.
Therefore
V
S
is
a
tradiction.
Therefore
is
an
INDEPENDENTSET.
VERTEXCOVER.
VERTEXCOVER.
VERTEXCOVER.
VERTEXCOVER.
NDENTSET
is
also
a
NPhard
problem
by
reducing
a
MINVERTEXCOVER
problem
into
a
contradiction.
Therefore
V
S
is
an
INDEPENDENTSET.
Theorem
1.
1.
IfIf SS
ofVThis
V
isis
aaisfollowing
MAXINDEPENDENTSET
MAXINDEPENDENTSET
of
of
graph
graph G(V
G(V
ER.
SSWe
an INDEPENDENTSET.
INDEPENDENTSET.
We
rst
prove
the
two
lemmas.
isis an
connected
by
edge,
we
note
is
aTheorem
VERTEXCOVER.
a G(V,
SET.
Theorem
1.
IfVVfollowing
S
note
Vthat
isthat
graph
E),
then
VV
Sof
isgraph
Theorem
1.
If
S
Vnodes
isaaSaMAXINDEPENDENTSET
MAXINDEPENDENTSET
of
graph
then
S
isa aMINVERTEX
MINVERTE
will
rst
prove
the
two
lemmas.
Theorem
1.of
Ifwill
S of
V
is at
aE),
MAXINDEPENDENTSET
G(V, E),of
t
byan
an
edge,
we
Snot
is that
not
an
INDEPENDENTSET.
This
isis
aMAXINDEPENDENTSET
contradiction.
Therefore
m
of nding
aV
maximum
subset
of
such
for
every
edge,
most
one
of
its
endpoint
is
in
Lemma
2.
S2.
is
a1.
VERTEXCOVER
of
graph
G(V,
E),
then
V
MINVERTEXCOVER
S
an
INDEPENDENTSET
ofoV
Theorem
1.
Ifus
SG(V,
V
isE),
ais
Lemma
2.
IfIf
S
is
a1.
VERTEXCOVER
graph
G(V,
then
V
S
an
INDEPENDENTSET
Lemma
If
SIf
S
V
is
VERTEXCOVER
graph
G(V,
E),
then
V
S
is
an
INDEPENDENTSE
NTSET
problem.
Proof.
The
proof
is
actually
similar
to
the
previous
lemma.
Let
assume
that
V
S
is
not
a
INDEPENDE
m
If
S
is
a
MAXINDEPENDENTSET
of
graph
G(V,
E),
then
V
S
is
a
Theorem
Theorem
If
If
S
S
V
V
is
is
a
a
MAXINDEPENDENTSET
MAXINDEPENDENTSET
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
V
V
S
S
is
is
a
MINMIN
hen
V
S
is
a
MINVERTEXCOVER
NDEPENDENTSET
of
graph
G(V,
E),
then
V
S
is
a
MINVERTEXCOVER
of
of
the
the
graph
graph
G(V,
G(V,
E).
E).
Lemma
1.
If
S
V
is
an
INDEPENDENTSET
of
graph
G(V,
E),
then
V
S
is
a
VERT
Theorem
1.
is
a
MAXINDEPENDENTSET
of
graph
,
then
Lemma
1.
If
V
is
an
INDEPENDENTSET
of
graph
G(V,
E),
then
V
S
is
a
VERTEXC
nS 1.
INDEPENDENTSET.
V
is
a
MAXINDEPENDENTSET
of
graph
G(V,
E),
then
V
S
is
a
MINVERTEXCOVER
Lemma
2.
If
S
V
is
a
VERTEXCOVER
of
graph
G(V,
E),
then
V
an
INDE
Lemma
Lemma
2.
2.
Lemma
2.
If
If
S
S
V
V
is
is
a
a
VERTEXCOVER
VERTEXCOVER
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
If
V
V
S
S
S
V
is
is
is
an
an
a
VERTEXCOVER
INDEPENDENTSET
INDEPENDENTSET
of
graph
of
of
the
the
G
of
the
graph
G(V,
E).
Theorem
1.
If
S
V
is
a
MAXINDEPENDENTSET
of
graph
G(V,
E),
then
S
is
a
MINV
of
the
graph
G(V,
E).
of
the
graph
G(V,
E).
VERTEXCOVER.
uppose
we
that
MINVERTEXCOVER
isVgraph
a
NPhard
problem.
Therefore,
canofAshow
SLemma
graph
VMINVERTEXCOVER
isthen
aalready
VERTEXCOVER
of
graph
G(V,
E),
then
V1.
S
is
the
MAXINDEPENDENTSET
of
graph
G(V,
E),
then
MINVERTEXCOVER
Lemma
Ifand
an
V .INDEPENDENTSET
isis
an
graph
E)
MAXINDEPENDENTSET
of
graph
G(V,
E),
then
VV
SSSof
isis
aaS
MINVERTEXCOVER
graph
G(V,
E)
the
graph
G(V,
E).
graph
G(V,
E)
of
G(V,
E),
then
VE)
graph
SG(V,
is
aG(V,
MINVERTEXCOVER
G(V,
lemmas.
Therefore,
there
are
two
vertices
A,
Bvertices
of
anINDEPENDENTSET
edge
andofB.
Since
A, B
E).
S
aG(V,
of
the
graph
G(V,
E).
E).
1.
Ifgraph
S
know
V of
is
an
INDEPENDENTSET
G(V,
E),
then
V
of
Sconnecting
is aweVERTEXCOVER
ofG(V,
the
G(V,
E),
VE)
S
is
athe
VERTEXCOVER
of
the
graph
E)
isgraph
MINVERTEXCOVER
of
the
graph
graph
G(V,
E)
taph
aisE).
VERTEXCOVER.
Therefore,
there
are Vtwo
A,
B
/ there
Vthat
V
SV
V,
VERTEXCOVER
of
G(V,
E),
then
Proof.
S
is
an
INDEPENDENTSET
the
graph
G(V,
E)
graph
graph
G(V,
G(V,
E)
graph
G(V,
E)
of
the
graph
G(V,
E).
Proof.
We
We
know
know
that
S
S
is
is
a
a
vertex
vertex
cover
cover
by
by
lemma
lemma
1.
1.
The
The
on
o
DEPENDENTSET
is
also
a
NPhard
problem
by
reducing
a
MINVERTEXCOVER
problem
into
a
graph
G(V,
E)
DEPENDENTSET
oflemmas.
graph
G(V,
E),
then
S
is aknow
MINVERTEXCOVER
ve
the following
twoWe
byby
Proof.
know
that
V
SVERTEXCOVER
is
athe
cover
lemma
1.
only
thing
for
us
pro
we
have
A,
Bis
/actually
S.
As
AV
and
BVisthe
are
connected
by
an
edge,
we
note
that
S
is
not
aremains
VERTEXCOVER.
Proof.
We
know
that
S
avertex
vertex
cover
1.aThe
The
only
thing
that
remains
forby
usto
tothin
p
graph
G(V,
E)
Proof.
We
that
Vlemma
S
is
vertex
cover
by
lemma
1.cover
The
only
Lemma
2.
If
S
VA,
isB
a
of
graph
G(V,
E),
then
V
Sisthat
isa
an
INDEPENDENTS
B.
Since
A,
B
/
V
S,
we
have
S.
As
A
and
B
are
connected
Proof.
The
proof
is
actually
similar
to
previous
lemma.
Let
us
assume
that
V
S
is
not
a
INDEPENDENTS
Proof.
We
know
that
V
S
vertex
lemm
Proof.
The
proof
similar
to
previous
lemma.
Let
us
assume
that
V
S
is
not
a
INDEPENDENTS
Proof.
The
proof
is
actually
similar
to
the
previous
lemma.
Let
us
assume
that
V
S
is
not
a
INDEPEND
ENTSET
of
graph
G(V,
E),
then
V
S
is
a
VERTEXCOVER
of
the
Proof.
We
know
that
is
vertex
cover
by
lemma
1.
The
only
thing
that
remains
We
know
that
V
S
is
a
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
prove
is
its
Proof.
Proof.
We
We
know
know
that
that
V
V
SSINDEPENDENTSET.
is
a
anot
vertex
vertex
cover
cover
by
by
lemma
lemma
1.
1.
The
The
only
only
thing
that
that
remains
remains
for
for
ng
that
for
us
to
prove
is
its
vertex
cover
lemma
1.
The
only
that
remains
us
tous
prove
is
its
V
Vlemma
S
S
is
islemma.
not
not
minimum
minimum
vertex
vertex
cover.
cover.
Then,
Then,
t
minimality.
minimality.
Suppose
Suppose
ENDENTSET
problem.
Proof.
Let
us
assume
that
Visalemma.
Sforvertex
not
athe
VERTEXCOVER.
Therefore,
there
are
two
ver
Proof.
Let
us
assume
aisProof.
VERTEXCOVER.
Therefore,
there
are
two
vertices
Ais
w
that
Vremains
Sby
is
a vertex
cover
by
lemma
The
only
thing
that
remains
for
us
to
prove
is
its
Proof.
The
proof
is
actually
similar
to
previous
Let
usand
that
VA,
B
SVTher
is
no
Proof.
Proof.
The
The
proof
proof
isis
actually
actually
similar
similar
to
to
the
the
previous
previous
lemma.
Let
Let
us
The
assume
assume
proof
that
isminimum
actually
V
V
S
Snot
similar
not
not
aassume
athing
INDEPENDENTSET.
to
INDEPENDENTSET.
the
previous
lemma.
Vcontradiction.
thing
S
isSV
not
minimum
cover.
Then,
there
is
another
vertex
cover
S
minimality.
Suppose
contradiction.
Therefore
Vfor
is
an
Proof.
We
know
that
S
is
vertex
cover
by
The
only
thing
that
remains
for
u
VThe
S
is1.
not
minimum
vertex
cover.
Then,
there
isvertex
another
vertex
cover
VV
minimality.
Suppose
INDEPENDENTSET
V
S
is
not
cover.
Then,
there
minimality.
Suppose
graph
G(V,
E)
oof
actually
similar
to
the
previous
lemma.
Let
us
assume
that
V
S
is
athat
INDEPENDENTSET.
STherefore,
is1.
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
prove
is
its
INDEPENDENTSET.
This
is
avertices
Therefore
V
S
is
anot
Proof.
us
assume
V
1.
Sis
is
athere
VERTEXCOVER.
S
aaTherefore,
vertex
cover
by
lemma
1.
only
thing
that
for
us
to
prove
its
Therefore,
there
are
two
vertices
A,
B
VSS
S
and
there
an
edge
connecting
A
B.
Since
V
V
Sis
is
not
minimum
vertex
cov
minimality.
Suppose
and
there
are
two
A,
B
S
there
is
an
edge
connecting
A
B.
Since
A,
B
ma
The
only
thing
that
remains
us
to
prove
is
its
Therefore,
there
two
vertices
A,
B
S
there
is
an
edge
connecting
A
B.
Since
A,
B
that
Let
and
vertices
and
V
isisis
an
INDEPENDENTSET
of
graph
G(V,
E),
then
Vremains
Sand
is
ais
VERTEXCOVER
of
for
us
to
prove
isare
its
minimality.
Suppose
is
not
minimum
vertex
cover.
Then,
V
S
is
not
minimum
vertex
cover.
Then,
there
is
another
vertex
cover
V
S
where
ty.
Suppose
emains
for
us
to
prove
is
its
V
V
S
is
is
not
not
minimum
minimum
vertex
vertex
cover.
cover.
Then,
Then,
there
is
is
another
another
vertex
vertex
cov
co
minimality.
minimality.
Suppose
Suppose
Proof.
Let
us
assume
that
V
S
is
not
a
VERTEXCOVER.
Therefore,
there
are
two
A,
B
/
V
S
the
.
there
are
two
vertices
A,
B
/
V
another
vertex
cover
V
S
where
minimum
vertex
cover.
Then,
there
is
another
vertex
cover
V
S
where
V
V
S
S


<
<
V
V
S,
S,
which
which
implies
implies
that
that
S
S


>
>
S.
S.
By
By
lemma
lemma
2,
2,
S
S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
/
V
S,
we
have
A,
B
S.
As
A
a
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
/
V
S,
we
have
A,
B
S.
As
A
and
B
V
minimum
S
is
not
minimum
vertex
cover.
Then,
there
isS.
another
vertex
cover
VA,
S
where
ppose
ySsimilar
to
the
previous
lemma.
Let
us
assume
that
V
S
not
aedge
INDEPENDENTSET.
Therefore,
there
two
vertices
A,
B
V
S
and
there
is
an
edge
connecting
A
and
Therefore,
Therefore,
there
there
are
two
two
vertices
vertices
A,
A,
B
B
V
Vare
S
Sedge
and
there
there
Therefore,
is
is
an
an
edge
edge
there
connecting
connecting
are
two
A
A
and
and
B.
A,
Since
Since
B
set.
VA,
A,
B
B
and
VVis
ther
S,
S,
V
SB
are
<
V
S,
which
implies
that
S
connecting
>
By
lemma
2,
S
is
an
independent
Sini
V
is
minimum
cover.
Then,
there
isthat
another
vertex
cove
minimality.
Suppose
V
S
//B
<1.
VThe
S,
which
implies
that
Sby
 isan
>
S.
By
lemma
2,
is
an
independent
set.
Therefore,
S
vertex
V
S
S
<
V
S,
which
implies
that
S
vertices
>
S.
By
lemma
2,
S
an
and
re
are
two
vertices
A,
V
S
there
is
an
A
and
B.
B
V
S,
is
not
vertex
cover.
Then,
there
is
another
vertex
cover
SSince
where
and
there
is
an
connecting
A
and
B.
Since
A,
B
/aTherefore,
VSS.
S,
we
S
is
not
minimum
vertex
cover.
Then,
there
is
another
cover
VV
S
we
have
A,
B
S.
As
A
and
B
are
connected
by
an
edge,
we
note
that
S
is
not
aisVVB.
VERTEXCOVER.
This
V

<
V
S,
which
implies
S
aconnected
>
By
le
and
vertex
ertex
cover
by
lemma
only
thing
that
remains
for
us
to
prove
is
its
we
have
A,
S.
As
A
B
are
connected
edge,
we
note
that
S
is
not
ais
VERTEXCOVER.
This
an
S
over.
Then,
there
is
another
cover
V
where
we
have
A,
B
/S
S.
As
A
and
B
are
connected
by
edge,
we
note
that
S
is
not
aais
VERTEXCOVER.
there
is
another
vertex
cover
not
where
, where
which
implies
that
cover
and
Theorem
1.
If
V
is
a
MAXINDEPENDENTSET
of
graph
G(V,
E),
then
S
is
a
MINVERTEX
<
V
S,
which
implies
that
S

>
S.
By
lemma
2,
S
is
an
independent
set.
Therefore,
S
not
vertex
V
S
where
V
V
S
S


<
<
V
V
S,
S,
which
which
implies
implies
that
that
S
S


>
>
S.
S.
By
By
lemma
lemma
2,
2,
S
S
an
an
independent
independent
set.
set.
The
Th
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
/
V
S,
we
have
A,
B
S.
As
A
and
B
are
an
the
S,
we
have
A,
B
S.
As
A
and
B
are
connected
dependent
set.
Therefore,
is
not
a
that
S

>
S.
By
lemma
2,
S
is
an
independent
set.
Therefore,
S
is
not
a
maximum
maximum
independent
independent
set.
set.
This
This
is
is
a
a
contradiction.
contradiction.
Therefore
Therefore
V
V
st
prove
the
following
two
lemmas.
by
edge,
we
note
that
S
is
not
an
INDEPENDENTSET.
This
is
contradiction.
Th
Proof.
The
proof
is
actually
similar
to
previous
lemma.
Let
us
assume
that
S
is
not
INDEPEND
by
an
edge,
we
note
that
S
is
not
an
INDEPENDENTSET.
This
is
a
contradiction.
Therefore
S,
which
implies
that
S
we
>
S.
By
lemma
Sby
isan
an
independent
set.
Therefore,
is
not
ertices
A,A
Band
V
S
and
there
isB
an
edge
Aedge,
and
A,
Vnot
S,
have
A,
B
/connecting
S.
As
A
and
BS
are
connected
by
an
edge,
we
note
that
S Viscover.
not
aisTher
VER
we
we
have
have
A,
A,
B
BB
/
/cover.
S.
S.
As
As
A
A
and
and
B
are
are
connected
connected
by
an
edge,
we
have
we
note
note
that
that
/is
S.
S
S
is
As
is
not
not
A
and
amaximum
aSThis
VERTEXCOVER.
VERTEXCOVER.
Ban
are
This
by
This
isis
edg
aS
aS
maximum
independent
set.
This
iswe
aimplies
contradiction.
Therefore
VB
S
is
minimum
vertex
V
S
<
V
S,
which
that
S

>
S.
By
lemma
2,
S
is
independent
set.
maximum
independent
set.
This
is2,
avertices
contradiction.
Therefore
V
S
isthe
the
minimum
vertex
cover.
are
t
aS.
VERTEXCOVER.
Therefore,
there
two
A,
B
/we
VSince
SB
maximum
independent
set.
This
a
contradiction.
Therefore
S an
the
that
/by
As
are
connected
by
an
edge,
note
that
isB.
not
aA,
VERTEXCOVER.
This
isaconnected
aminimum
implies
that
S

>
S.
By
lemma
2,
S
is
an
independent
set.
Therefore,
S
is
not
a
by
an
edge,
we
note
S
is
an
INDEPENDENTSET.
This
implies
that
S

>
S.
2,
S
is
an
independent
set.
Therefore,
S
is
not
a
contradiction.
Therefore
V
S
is
an
INDEPENDENTSET.
maximum
independent
set.
is
a
contradiction.
Ther
minimum
vertex
Then,
there
is
another
vertex
cover
V
S
where
.
By
lemma
2,
is
an
independent
set.
Therefore,
is
not
a
incontradiction.
Therefore
V
S
is
an
INDEPENDENTSET.
lemma
2,
S
is
an
independent
set.
Therefore,
S
is
not
a
contradiction.
Therefore
V
S
is
an
INDEPENDENTSET.
of
the
graph
G(V,
E).
m
independent
set.
This
is
a
contradiction.
Therefore
V
S
is
the
minimum
vertex
cover.
nt
set.
Therefore,
S
is
not
a
maximum
maximum
independent
independent
set.
set.
This
This
is
is
a
a
contradiction.
contradiction.
Therefore
Therefore
V
V
S
S
is
is
the
the
minimum
vertex
vertex
co
co
an
edge,
we
note
that
S
is
not
an
INDEPENDENTSET.
This
is
a
contradiction.
Therefore
V
S
is
a
T.
This
is
a
contradiction.
Therefore
V
S
is
a
minimum
vertex
cover.
a contradiction.
Therefore
Vedge,
SSSwe
is
the
minimum
vertex
cover.
VERTEXCOVER.
Therefore,
there
are
two
vertices
A,
Band
Sminimum
and
there
isTherefore
ancover.
edge
A
and B. vertex
Since A,
VERTEXCOVER.
VER
graph
G(V,
E),
then
V
SisisVTherefore
is
an
INDEPENDENTSET
of
the
This
amaximum
contradiction.
V
SE),
the
vertex
and
Bof
are
connected
by
an
note
that
SThis
is
not
athen
VERTEXCOVER.
This
avertex
Therefore
S
isabove
antwo
INDEPENDENTSET.
contradiction.
contradiction.
Therefore
Therefore
Vcontradiction.
V
an
an
INDEPENDENTSET.
INDEPENDENTSET.
contradiction.
S
an
me
that
Vis
isBy
not
aINDEPENDENTSET.
VERTEXCOVER.
Therefore,
are
vertices
A, conclude
B
/V
V
Sis
independent
set.
isVisVathere
contradiction.
Therefore
Visconnecting
S
isthat
the
minimum
covB
B.
Since
B
/isS
Vis
S,
we
have
A,
S.
As
A
B
are
connected
isset.
From
From
the
the
above
theorem,
we
we
conclude
that
athe
aINDEPENDENTS
MINVERTEXCO
MINVERTEXCO
SThis
an
INDEPENDENTSET
of
graph
G(V,
V
Stheorem,
athe
VERTEXCOVER
ofeasily
Therefore
V
dependent
is
anminimum
.endent
This
contradiction.
Therefore
S
is
the
minimum
vertex
cover.
set.
This
aVB
contradiction.
Therefore
is
is
minimum
cover.
VERTEXCOVER.
aaA,
contradiction.
Therefore
S
is
the
minimum
vertex
cover.
hat
SVis
V
>
S.
lemma
2,
SS.
isis
an
independent
set.
Therefore,
not
a note
herefore
SS
the
vertex
cover.
From
the
above
theorem,
we
conclude
that
a
MINVERTEXCOVER
can
be
constructed
if
m
vertex
cover.
From
the
above
theorem,
we
conclude
that
a
MINVERTEXCOVER
can
be
easily
constructed
ifwc
VERTEXCOVER.
From
the
above
theorem,
we
conclude
that
a
MINVERTEXCOVER
we
have
A,
B
/
As
A
and
B
are
connected
by
an
edge,
we
that
S
is
not
a
VERTEXCOVER
Theorem
1.We
Sknow
ishave
aBVcontradiction.
MAXINDEPENDENTSET
of
graph
G(V,
E),
then
SifVconclude
iswe
acan
MINVERTEXCOV
From
the
above
theorem,
we
ausconstru
MINV
Sabove
is
an theorem,
INDEPENDENTSET.
Theorem
1.
IfIfwe
S
VVSisthat
is
MAXINDEPENDENTSET
graph
E),
then
VVthen
S
is
aremains
MINVERTEXCOV
Theorem
1.
Ifwe
is
MAXINDEPENDENTSET
of
graph
G(V,
E),
S
isbe
athat
MINVERTE
ea)an
connecting
AMINVERTEXCOVER
and
B.
Since
A,
/V
VSais
S,
we
have
A,
B by
V of
S.
As
A
and
B
are
connected
INDEPENDENTSET.
This
aa2.
Therefore
that
S we
is
aG(V,
Proof.
V
S
is
a
vertex
cover
lemma
1.
The
only
thing
that
for
to
pro
the
conclude
that
a
MINVERTEXCOVER
can
be
easily
constructed
have
a
From
From
the
the
above
above
theorem,
theorem,
we
we
conclude
conclude
that
a
a
MINVERTEXCOVER
MINVERTEXCOVER
can
be
easily
easily
constru
be
easily
constructed
if
a
onclude
that
a
can
be
easily
constructed
if
have
a
MAXINDEPENDENTSET.
MAXINDEPENDENTSET.
Lemma
If
V
is
a
VERTEXCOVER
of
graph
G(V,
E),
then
V
S
is
an
INDEPEN
Lemma
2.
If
S
a
VERTEXCOVER
of
graph
G(V,
E),
then
V
S
is
an
INDEPENDENT
contradiction.
Therefore
V
S
is
the
minimum
vertex
cover.
oveTheorem
theorem,
weIfthat
that
aabove
MINVERTEXCOVER
can
beV easily
constructed
if
we
a E),
Theorem
1.
If graph
S is
can
Vwe
is
a easily
MAXINDEPENDENTSET
then Vconstruc
Sthen
iso
Theorem
1.
1.
Theorem
1.
Ifconclude
SScan
V
V
isiseasily
aTherefore
athe
MAXINDEPENDENTSET
MAXINDEPENDENTSET
of
graph
G(V,
G(V,
E),
E),
IfaififVERTEXCOVER
Swe
then
then
have
V VVisof
a graph
S
MAXINDEPENDENTSET
S isishave
aaG(V,
MINVERTEXCOVER
MINVERTEXCOVER
MAXINDEPENDENTSET.
From
conclude
a Sis
MINVERTEXCOVER
can
be easily
MAXINDEPENDENTSET.
MAXINDEPENDENTSET.
contradiction.
Vtheorem,
S
an
INDEPENDENTSET.
fm,
Vof
MAXINDEPENDENTSET
G(V,
E),
then
m,
we
conclude
ahave
MINVERTEXCOVER
can
be
easily
constructed
2.
Ifgraph
Sthat
then
V
we
conclude
that
a
MINVERTEXCOVER
be
constructed
of
the
graph
G(V,
E).
MAXINDEPENDENTSET.
the
graph
G(V,
VERTEXCOVER
be
constructed
ifofLemma
we
aof
of
graph
G(V,
E).
eSthat
SVis2.
isaminimality.
an
INDEPENDENTSET.
This
ishave
a contradiction.
Therefore
V INDEPENDENTSET
aaisS another
is a of graph
Vgraph
G(V,
S Sof
isisE),
not
minimum
vertex
cover.
Then,
there
vertexG(V,
cover
V S
Suppose
DEPENDENTSET.
sily
constructed
we
aof
MAXINDEPENDENTSET.
MAXINDEPENDENTSET.
Lemma
Ifnot
S1the
an
V
is
aE).
VERTEXCOVER
graph
G(V,
E),
VisaG(V,
MINVERTEXCOVER
SweE).
ishave
an
ofE),
the
E),
then
S
isif
INDEPENDENTSET
of
the
graph
G(V,
E)
graph
G(V,
E)
previous
lemma.
Let
us
assume
that
V
not
a
INDEPENDENTSET.
NDENTSET.
MAXINDEPENDENTSET
of
graph
then
V
S
is
a
MINVERTEXCOVER
the
G(V,
E).
of
of
the
the
graph
graph
G(V,
G(V,
E).
E).
of
the
graph
MAXINDEPENDENTSET.
We
say
that
problem
X
is
reducible
to
problem
Y
assume
that
VMINVERTEXCOVER
S
Therefore,
arehave
two2,vertices
A,independent
B
/ V S set. Therefore, S
G(V,
E).G(V,
T.
graph
G(V,
E)there
T.
is not a VERTEXCOVER.
nclude
that
a Theorem
can
be easily
constructed
if we
a SG(V,
V
Sis
an
< V
If connecting
S,
which
that
S
 >A,
S.
By
lemma
is an
graph
E)
In
In
the
the
beginning
beginning
of
of
this
this
section,
section,
we
we
assume
assume
we
know
know
that
that
MINV
MINV
1.
S
V
is
aimplies
MAXINDEPENDENTSET
ofS,
graph
E),
then
V we
S
aus
MINVERTE
V edge
of
SProof.
and
there
edge
and
B.
Since
B
B
V1.
Proof.
We
know
that
Sthis
is
aA
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
toisprove
prove
We
know
that
VV
S
is
aan
vertex
cover
by
lemma
The
only
thing
that
remains
for
to
is
Proof.
We
know
that
V
S
is
a
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
pis
InProof.
beginning
of
section,
we
assume
we
know
that
MINVERTEXCOVER
is
aisVaNPhard
probl
Inthe
the
beginning
of
this
section,
we
assume
we
know
that
MINVERTEXCOVER
isis
NPhard
prob
VER
graph
G(V,
E),
then
INDEPENDENTSET
of
the
In
the
beginning
of
this
section,
we
assume
we
know
that
MINVERTE
n
connecting
A
and
B.
Since
A,
B
/
V
S,
we
have
A,
S.
As
A
and
B
are
connected
Proof.
The
proof
is
actually
similar
to
the
previous
lemma.
Let
us
assume
that
S
not
aits
IN
In
the
beginning
of
this
section,
we
assume
we
know
The
proof
is
actually
similar
to
the
previous
lemma.
Let
us
assume
that
V
S
not
a
INDEPE
Proof.
We
know
that
V
S
is
a
vertex
cover
by
lemma
1.
The
only
thing
that
rema
Proof.
Proof.
Proof.
We
We
know
know
that
that
V
V
S
S
is
is
a
a
vertex
vertex
cover
cover
by
by
lemma
lemma
1.
1.
The
The
We
only
only
know
thing
thing
that
that
that
V
remains
remains
S
is
a
vertex
for
for
us
us
cover
to
to
prove
prove
by
lemm
is
is
maximum
independent
set.
This
is
a
contradiction.
Therefore
V
S
is
the
minimum
vertex
cover.
e
beginning
of
this
section,
we
assume
we
know
that
MINVERTEXCOVER
is
a
NPhard
problem.
It
is
In
In
the
the
beginning
beginning
of
of
this
this
section,
section,
we
we
assume
assume
we
we
know
know
that
that
MINVERTEXCOVER
MINVERTEXCOVER
is
is
a
a
NPh
NPh
its
XCOVER
is
a
NPhard
problem.
It
is
we
assume
we
know
that
MINVERTEXCOVER
is
a
NPhard
problem.
It
is
good
good
to
to
know
know
as
as
many
many
NPhard
NPhard
problem
problem
as
as
possible.
possible.
This
This
is
is
necessary
necessary
of
the
graph
G(V,
E).
ow
that
V
S
is
a
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
prove
is
its
nected
by
an
edge,
we
note
that
S
is
not
a
VERTEXCOVER.
This
is
a
Proof.
The
proof
isThis
actually
similar
to
the
Let
us
ning
this
section,
we
assume
weS
know
that
MINVERTEXCOVER
isisknow
athat
NPhard
problem.
It
is lemma.
VINDEPENDENTSET.
Sthere
is
not
minimum
vertex
cover.
Then,
there
is
another
vertex
cover
SVassu
wh
minimality.
Suppose
V
is
not
vertex
cover.
Then,
there
is
vertex
V
S
wh
Suppose
V
Sare
isminimum
not
minimum
vertex
cover.
Then,
there
is
another
vertex
cover
minimality.
Suppose
good
to
know
as
many
NPhard
problem
as
This
isthere
necessary
so
that
ifprevious
encounter
aA
proble
is
aofminimality.
VERTEXCOVER
of
graph
G(V,
E),
then
V
Swe
isLet
an
INDEPENDENTSET
of
the
In
the
beginning
of
this
section,
assume
we
that
MINVERTEXCOVER
isnew
a
NPha
good
know
as
many
NPhard
problem
as
possible.
necessary
so
that
ifwe
we
encounter
aV
new
prob
good
to
know
as
NPhard
problem
as
possible.
This
iscover
necessary
so
tha
Proof.
The
proof
isto
actually
similar
to
the
previous
lemma.
us
assume
Vis
not
aproblem
INDEPENDENTSET.
us
assume
that
V
S
is
not
athere
we
note
that
S
is
not
an
INDEPENDENTSET.
This
is
ais
contradiction.
Therefore
Vedge
Sthat
is
aifA
Therefore,
two
A,
B
Swe
and
there
is
an
connecting
B.
sV
section,
we
assume
we
know
that
MINVERTEXCOVER
is
NPhard
problem.
Itanother
is
Since
section,
we
assume
we
know
that
MINVERTEXCOVER
aaas
NPhard
problem.
It
is
good
to
know
as
many
NPhard
problem
as
possible.
This
Therefore,
two
vertices
A,
B
Vmany
S
and
is
an
edge
connecting
and
B.
A
where
w
MINVERTEXCOVER
is
apossible.
NPhard
problem.
Itpossible.
is
S
aencounter
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
prove
is
its
V
Sany
is
not
minimum
cover.
Then,
there
another
minimality.
Suppose
V
Vto
S
S
is
isare
not
not
minimum
minimum
cover.
cover.
Then,
Then,
there
there
is
another
VS
S
vertex
vertex
is
not
cover
minimum
cover
VVis
vertex
Sit
Sand
where
cov
minimality.
minimality.
Suppose
Suppose
minimality.
Suppose
know
many
problem
as
This
isvertices
necessary
so
that
iftwo
encounter
ais
new
X,
we
so
R
isthat
aisas
NPhard
problem.
It
is
good
to
know
know
as
as
many
many
NPhard
NPhard
problem
problem
as
possible.
possible.
This
is
isanother
necessary
so
that
if
we
we
encounter
encounter
aver
ano
nS
n
is
vertex
vertex
tblem
if
we
aThis
new
problem
X,
we
possible.
is
necessary
so
that
ifthat
we
encounter
a>
new
problem
X,
we
can
can
use
use
of
of
the
the
NPhard
NPhard
problems
problems
that
that
we
we
know,
know,
reduce
reduce
it
to
to
probl
prob
NPhard
vertex
This
good
any
necessary
V
not
minimum
vertex
cover.
Then,
there
is
another
vertex
cover
V
S
where
uppose
DEPENDENTSET.
Therefore,
there
are
vertices
A,
B
S
and
there
is
an
edge
many
NPhard
problem
as
possible.
This
is
necessary
so
that
if
we
encounter
a
new
problem
X,
we
V
S

<
V
S,
which
implies
that
S

>
S.
By
lemma
2,
S
is
an
independent
set.
Therefore,
S
is
no
V
S

<
V
S,
which
implies
S

>
S.
By
lemma
2,
S
is
an
independent
set.
Therefore,
S
is
V
S

<
V
S,
which
implies
that
S

S.
By
lemma
2,
S
is
an
independent
set.
Therefore,
can
use
any
of
the
NPhard
problems
that
we
know,
reduce
it
to
problem
X,
and
thus
prove
that
X
is
also
good
to
know
as
many
NPhard
problem
as
possible.
This
is
necessary
so
that
if
we
encounter
a
ne
can
use
any
of
the
NPhard
problems
that
we
know,
reduce
it
to
problem
X,
and
thus
prove
that
X
is
also
can
use
any
of
the
NPhard
problems
that
we
know,
reduce
it
to
problem
X,
From
the
above
theorem,
we
conclude
that
a
MINVERTEXCOVER
can
be
easily
constructed
if
w
Therefore,
there
are
two
vertices
A,
B
S
and
there
is
an
edge
connecting
A
and
B.
Since
A,
B
S,
n
edge
connecting
A
and
B.
Since
A,
B
S,
note
VER.
we
have
A,
B
/
S.
As
A
and
B
are
connected
by
an
edge,
we
note
that
S
is
not
a
VERTEX
hard
problem
as
possible.
This
is
necessary
so
that
if
we
encounter
a
new
problem
X,
Proof.
We
know
that
V
S
is
a
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
pS
hard
problem
as
possible.
This
is
necessary
so
that
if
we
encounter
a
new
problem
X,
we
can
use
any
of
the
NPhard
problems
that
we
know,
reduc
we
have
A,
B
/
S.
As
A
and
B
are
connected
by
an
edge,
we
that
S
is
not
a
VERTEXCOV
we
assume
we
know
that
MINVERTEXCOVER
is
a
NPhard
problem.
It
is
his
is
necessary
so
that
if
we
encounter
a
new
problem
X,
we
S
is
not
minimum
vertex
cover.
Then,
there
is
another
vertex
cover
V
S
where
S

<
V
S,
which
implies
that
S

>
S.
By
lemma
2,
S
is
an
independent
s
V
V
S
S


<
<
V
V
S,
S,
which
which
implies
implies
that
that
S
S


>
>
S.
S.
By
By
lemma
lemma
V
S
2,
2,

S
<
S
V
is
is
an
an
S,
independent
independent
which
implies
set.
set.
Therefore,
that
Therefore,
S

>
S
S
S.
is
is
not
not
By
a
le
a
ny
of
the
NPhard
problems
that
we
know,
reduce
it
to
problem
X,
and
thus
prove
that
X
is
also
NPhard.
V
counter
a
new
problem
X,
we
can
can
use
use
any
any
of
of
the
the
NPhard
NPhard
problems
problems
that
that
we
we
know,
know,
reduce
reduce
it
it
to
to
problem
problem
X,
X,
and
and
thus
thus
prove
prove
that
that
previous
lemma.
Let
us
assume
that
V
S
is
not
a
INDEPENDENTSET.
and
thus
prove
that
X
is
also
NPhard.
ms
that
we
know,
reduce
it
to
problem
X,
and
thus
prove
that
X
is
also
NPhard.
1contradiction.
1have
S,
which
that
S
 know,
>
S.
By
2,
S
isedge,
an
independent
SNPhard.
isYYX,
not
we
A,
B
/problem
S.
As
and
B
connected
byaan
edge,
weisthat
note
NPhard
problems
that
we
reduce
to
problem
X,that
and
thus
prove
Xare
is
also
maximum
independent
set.
This
islemma
contradiction.
Therefore
VXA
Sthat
isTherefore,
the
vertex
cover.
maximum
independent
set.
This
is
aait
contradiction.
Therefore
VX
S
the
minimum
vertex
cover.
maximum
independent
set.
is
aV
Therefore
Vis
Sto
is
theis
minimum
vertex
cover.
We
We
say
say
that
problem
isset.
reducible
reducible
to
to
problem
problem
can
use
any
of
the
NPhard
problems
we
know,
reduce
it
problem
and
thus
prove
X
11
1not
MAXINDEPENDENTSET.
we
have
A,
Bimplies
/we
S.
As
A
and
BTherefore
connected
by
we
note
that
S
is
not
aminimum
VERTEXCOVER.
This
aV
note
that
S
is
aand
VERTEXCOVER.
contradiction.
Therefore
SINDEPENDENTSET.
is
an
INDEPENDENTSET.
dehe
problems
that
we
know,
reduce
to
problem
X,
and
thus
prove
that
X
also
NPhard.
S
is1
not
minimum
vertex
cover.
Then,
there
another
vertex
cover
minimality.
Suppose
We
say
that
problem
X
is
reducible
to
problem
Yathat
problems
that
know,
reduce
ititare
to
problem
X,
and
thus
that
X
isisis
also
NPhard.
We
say
problem
X
is
reducible
to
problem
Y
contradiction.
VThis
Sis
isaNPhard.
an
lem
possible.
This
isthat
necessary
so
that
ifThis
we
encounter
new
problem
X,
we
We
say
that
problem
XV
is
reducible
to
problem
Yprove
uce
itasto
problem
X,
thus
prove
that
X
is
also
90
J.I. Gunawan
3. How to Proceed
Suppose we already know that a problem is unsolvable (i.e. any known algorithm will
not solve this problem in time). In competition, it is impossible to complain that This
is unsolvable, can you eliminate this problem? to the judges, since the judges believe
How
How to
to proceed
proceed
they have a solution. Such a request is absurd when there are already several contestants
have
that problem.
Also,this
in aproblem
major competition
(e.g. ACM International
any
algorithm
will
in
s unsolvable
unsolvable (i.e.
(i.e. who
any known
knownsolved
algorithm
will not
not solve
solve
this
problem
in
Collegiate
Programming
Contest
World
Finals,
IOI),
it
is
unlikely
that the judges have
omplain that
complain
that "This
"This isis unsolvable,
unsolvable, can
can you
you eliminate
eliminate this
this problem?"
problem?"
incorrect
solution.
yy have
have aa solution.
solution. Such
Such aa request
request isis absurd
absurd when
when there
there are
are already
already
blem. Also,
oblem.
Also, inin aa major
major competition
competition (e.g.
(e.g. ACM
ACM International
International Collegiate
Collegiate
How to
isis unlikely
unlikely that
that the
the judges
judges have
have incorrect
incorrect solution.
solution. 3
3.1. Approximation
proceed
Suppose we already know that a problem is unsolvable (i.e. any known algorithm will not solve this pro
time).InInreal
competition,
it iscannot
impossible
to optimal
complainsolution,
that "This
is unsolvable,
can solution
you eliminate this pr
life, when we
find the
we can
try to find the
to can
thethat
judges,
since
the
judges
believe
they
a solution.
request
is absurd
try
to
nd
the
solution
that
isis close
to
the
optimal
all solution,
solution, we
we
can
try
toclose
nd
thethe
solution
that
close
to have
the
optimal
is
to
optimal
solution.
More
specifically,
we Such
try to afind
a solution
that iswhen there are
several
contestants
who
have
solved
problem.
Also, insolution
a major for
competition
(e.g. ACM
isis not
larger
(where
>
1)
the
optimal
not
than
(where
a minimisation
probInternational C
a solution
solution that
that
not
larger than
than
(where
>that
1)) times
times
theoptimal
optimal
lem. The Contest
mostalgorithm
common
Ithat
found
textbooks
the 2approxProgramming
World approximation
it algorithm
is unlikely
theinjudges
haveisincorrect
solution.
most
approximation
IFinals,
in
isis the
most common
common
approximation
algorithm
I found
foundIOI),
in textbooks
textbooks
the
MINVERTEXCOVER
problem,
which
means that the algorithm will not
blem,
that
algorithm
more
twice
blem, which
which means
meansimation
that the
the
algorithm will
will not
not choose
choose
more than
than
twice
choose
more than
twice the
number
of3.1
vertices
than the optimal solution. However, apution.
problems
rarely
occur
in
competitive
lution. However,
However, approximation
approximation
problems
rarely
occur
in
competitive
Approximation
proximation
problems
rarely
occur
in
competitive
programming
(especially IOI). One
eason isis because
reason
because to
to create
create this
this kind
kind of
of problem,
problem, the
the judges
judges have
have to
to
In
real
life,
when
we
cannot
nd
the
optimal
solution,
we
can
try
to
nd
the solution
of
the
reason
is
because
to
create
this
kind
of
problem,
the
judges
have
to knowthat
theis close to the
y that
that the
the contestants
contestants solution
solution isis indeed
indeed approximation.
approximation. However,
However,
solution.
More
specically,
we
try
to
nd
a
solution
that
is
not
larger
than
(where
.1
.1 Approximation
Approximation
1)
theto
optimal
tion.
However,
approximation
problems
rarely
occur
injudges
competitive
intimes
isthe
the
isthis
because
create
this
kind
of
problem,
the
judges
have
to
know
the
optimal
solution
in
order
verify
that
the
solution
isinco
in
know
the
solution
to
verify
that
the
contestants
solution
issolution
indeed
approximation.
Howev
nd
oftextbooks
problem,
judges
have
to
In
real
life,
when
we
cannot
nd
the
optimal
solution,
we
try
toto
nd
the
that
istime).
to
the
optim
ming
Contest
World
Finals,
IOI),
itin
isorder
Programming
unlikely
that
the
Contest
World
have
Finals,
incorrect
IOI),
solution.
it(or
is
unlikely
thatfor
the
judges
have
generating
the
optimal
solution
impossible
(or
takes
acan
long
time).
Since
this
approach
isclose
not
really
suitabl
generating
the
optimal
solution
is
impossible
takes
acontestants
long
Since
this
ap
deed
approximation.
However,
optimal
solution
is
impossible
(or
takes
long
time).
Since
this
approach
is
not
really
suitable
approach
isoptimal
not
really
suitable
for
competitive
programming,
Iaiswill
not
discuss
this
approach
in
detail.
in
textbooks
is
the
ason
is
because
to
create
this
kind
of
problem,
the
judges
have
to
oose
more
than
twice
the
contestants
solution
is
indeed
approximation.
However,
generating
the
optimal
solution
is
impossible
(or
takes
a
long
time).
Since
this
af
generating
the
optimal
solution
is
impossible
(or
takes
a
long
time).
Since
this
approach
is
not
really
suitable
ndeed
approximation.
However,
solution.
More
specically,
we
try
to
nd
a
solution
that
is
not
larger
than
(where
>
1)
times
the
optim
competitive
I will notindiscuss
this approach
competitive
programming,
I 3.1
will in
notdetail.
discuss this approach in detail.
approach
is Inot
suitablethis
forapproach
gramming,
willreally
not programming,
discuss
detail.
Approximation
oose
more
than
twice
that
the
contestants
solution
is
indeed
approximation.
However,
occur
in
competitive
akes
a
long
time).
Since
this
approach
is
not
really
suitable
for
competitive
willdetail.
not discussalgorithm
this approach
in detail.
competitive
I problem.
will
not
discuss
this approach
approach
is not
suitable for
solution
for really
aprogramming,
minimisation
The programming,
most
commonI in
approximation
I found
in textbooks is th
3.1
Approximation
3.1
Approximation
3.2
Pruning
occur
in in
competitive
adetail.
long
Since
approach
isproblem,
not
really
suitable
for
,(or
thetakes
judges
havetime).
toInMINVERTEXCOVER
real
life,this
when
we Understanding
cannot
nd
the
optimal
solution,
we
can
try
to
nd
the
solution
is twic
clos
pproach
2approximation
which
means
that
the
algorithm
will
not
choose
than
Unsolvable
Problem
91 morethat
3.2
Pruning
3.2
Pruning
3.2 solution,
Pruning
,his
judges
have
to
, the
when
we
cannot
nd
the
optimal
In
real
life,
we
when
can
try
we
to
cannot
nd
the
nd
solution
the
optimal
that
is
solution,
close
to
we
the
can
optimal
try
to
nd
the
sol
approach
in
detail.
oximation.
However,
solution.
More
specically,
we
try
to
nd
a
solution
that
is
not
larger
than
(where
>
1)
ti
the
number
of
vertices
than
the
optimal
solution.
However,
approximation
problems
rarely
occur
in
competitiv
This approach is useful in some competitive
problems. In ACM
3.2 International
PruningCollegiate Prog
3.2programming
Pruning
oximation.
However,
More
specically,
we
try
to
nd
a
solution
solution.
that
More
is
not
specically,
larger
than
we
try
(where
to
nd
a
>
solution
1)
times
that
the
is
optimal
not
larger
than
not
really
suitable
for
solution
for
a
minimisation
problem.
The
most
common
approximation
algorithm
I
found
in
This
approach
is
useful
in
some
competitive
programming
problems.
In
ACM
International
Collegiate
Programm
This
approach
useful
in
some
competitive
programming
problems.
In
ACM
Intern
useful
in
some
competitive
programming
problems.
In
ACM
International
Collegiate
Programming
for
this
problem
is
to prune
the
exponential
we
use
findkind
all possible
pathsthe
programming
(especially
IOI).
One of
the
reason
this
of contestant
problem,
havenut(
M
Collegiate
Programming
Contest
(ICPC)
World
Finals
2010,
problemis algorithm
Ibecause
(Robotsto
oncreate
Ice)torequired
the
to judges
count the
2 International
Pruning
This
approach
is
useful
in
some
competitive
programming
problems.
In
ACM
Inte
This
approach
is
useful
in
some
competitive
programming
problems.
In
ACM
International
Collegiate
Programmi
not
really
suitable
for
or
a
minimisation
problem.
The
most
solution
common
for
a
approximation
minimisation
algorithm
problem.
The
I
found
most
in
common
textbooks
approximation
is
the
algor
2approximation
MINVERTEXCOVER
problem,
which
means
that
the
algorithm
will not
choose
Contest
(ICPC)
World
2010,
problem
I the
(Robots
on
required
the
contestant
count
the
numb
Contest
(ICPC)
World
Finals
2010,
problem
Iproblem
(Robots
on
Ice)
the
cont
rnational
Collegiate
Programming
(ACM
ICPC
World
2010
Solutions.
n.d.).
If
atIce)
some
we
know
that
it
isrequired
World
Finals
2010,
problem
I Finals
(Robots
on
Ice)
required
the
contestant
topoint
count
the
number
ofto
know
the
optimal
solution
in Finals
order
to
verify
that
contestants
solution
is
indeed
approximation.
Howeve
he
contestant
to
count
the
number
of
3.2
Pruning
Hamiltonian
Paths
with
constraints
(ACM
ICPC
World
Finals
2010
statement
n.d.),
which
is k
mming
problems.
In
ACM
International
Collegiate
Programming
Contest
(ICPC)
World
Finals
2010,
problem
I
(Robots
on
Ice)
required
the
con
Contest
(ICPC)
World
Finals
2010,
problem
I
(Robots
on
Ice)
required
the
contestant
to
count
the
number
ternational
Collegiate
Programming
mation
MINVERTEXCOVER
problem,
2approximation
which
means
that
MINVERTEXCOVER
the
algorithm
will
not
problem,
choose
which
more
means
than
twice
that
algorithm
the
number
of
vertices
than
the
optimal
solution.
However,
approximation
problems
rarely
occu
impossible
to
visit
the
rest
of
the
unvisited
points,
then
we
can
prune
the
path
and
Hamiltonian
Paths
with
constraints
(ACM
ICPC
World
Finals
2010
problem
statement
n.d.),
which
is
know
Hamiltonian
Paths
with
constraints
(ACM
ICPC
World
Finals
2010
problem
state
ntestant
to
count
the
number
of
thsstatement
with
constraints
(ACM
ICPC
World
Finals
2010
problem
statement
n.d.),
which
is
known
to
generating
the
optimal
solution
is
impossible
(or
takes
a
long
time).
Since
this
approach
is
not
really
suitable
em
n.d.),
which
is
known
to
be a NPhard problem. While nding all possible paths is impossible, the solution for this problem isf
rogramming
problems.
In
ACM
International
Collegiate
Programming
obots
on
Ice)
required
the
contestant
to
count
the
number
of
Hamiltonian
Paths
with
constraints
(ACM
ICPC
World
2010
problem
sta
Hamiltonian
Paths
with
constraints
(ACM
ICPC
Finals
2010
problem
statement
n.d.),
which
is known
to
count
the
number
er
of competitive
vertices
than
the
optimal
solution.
the
number
However,
approximation
vertices
than
problems
optimal
rarely
solution.
occur
inproblems
competitive
approximation
prob
backtrack
immediately.
itof
ispossible
not
very
suitable
for
IOI.
Usually,
IOI
programming
(especially
IOI).
One
of
the
reason
is(ACM
because
to
create
this
kind
of Solutions
problem,
thp
be
athe
NPhard
While
nding
all
paths
is
impossible,
the
solution
for
this
problem
issolutio
to
be
aHowever,
NPhard
problem.
While
nding
all
possible
paths
isFinals
impossible,
the
tement
n.d.),
which
isproblem.
known
to
roblem.
While
nding
all
possible
paths
isuse
impossible,
the
solution
this
problem
isHowever,
to
prune
programming,
Iof
will
not
discuss
this
approach
inthe
detail.
eontestant
solution
for
this
problem
isalgorithm
to
prune
ICPC
World
Finals
2010
n.d
exponential
we
to
nd
allWorld
possible
paths
I
(Robots
on
Ice)
required
the
contestant
to
count
the
number
of
World
Finals
2010
problem
statement
n.d.),
which
is
known
to
be
a
NPhard
problem.
While
nding
all
possible
paths
is
impossible,
the
solu
be
a
NPhard
problem.
While
nding
all
possible
paths
is
impossible,
the
solution
for
this
problem
is
to
pru
tatement
n.d.),
which
is
known
to
require
deep
analysis
from
the
contestant.
It
is
rare
that
we
can
get
Accepted
by
only
ming
(especially
IOI).
One
of
the
reason
programming
is
because
(especially
to
create
this
IOI).
kind
One
of
of
problem,
the
reason
the
is
judges
because
have
to
to
create
this
kind
know
the
optimal
solution
in
order
to
verify
that
the
contestants
solution
is
indeed
approxim
ICPC
World
Finals
2010
Solutions
n.d.).
the
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
ICPC
World
the
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
tion
for
thiswe
problem
is we
toall
prune
World
Solutionspoints,
n.d.). If
at we can prune theFip
algorithm
usepoint
to nd
possible
(ACM ICPC
World
Finals
2010
Solutions
n.d.).
If atitpaths
some
know
that
is impossible
to visit
the Finals
rest of2010
the unvisited
then
CPC
World
Finals
2010
problem
statement
n.d.),
which
is
known
to
legiate
Programming
paths
is
impossible,
the
solution
for
this
problem
is
to
prune
ICPC
World
the
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
ICPC
World
Finals
2010
Solutions
n.d.).
the
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
ution
for
this
problem
is
to
prune
hacking
a
complete
search
algorithm.
Therefore,
we
will
not
discuss
this
technique
optimal
solution
in prune
order
that
know
the
contestants
solution
solution
isorder
indeed
tocan
that
the
contestants
solution
is Ifintr
approximation.
However,
generating
thethe
optimal
solution
is impossible
(or
takes
averify
long
time).
Since
this
approach
is analy
not
some
we
know
that
itsome
is
impossible
to
visit
the
of
the
unvisited
then
we
can
prune
the
path
point
we
know
that
itrest
isinimpossible
to
visitpoints,
the
rest
ofand
the
unvisited
points,
Finals
2010
Solutions
n.d.).
Ifverify
at
know
that
it backtrack
ispoint
impossible
to
rest
ofthe
the
unvisited
points,
then
we
prune
the
path
points,
then
we
can
thevisit
path
and
immediately.
However,
itoptimal
is
not
very
suitable
for
IOI.
Usually,
IOI
problems
require
deep
3.2
Pruning
legiate
Programming
ssible
paths
is
impossible,
the
solution
for
this
problem
is
to
prune
count
the
number
of
ICPC
World
Finals
2010
Solutions
n.d.).
If
at
ble
paths
(ACM
some
point
we
know
that
it
is
impossible
to
visit
the
rest
of
the
unvisited
points,
in
detail.
some
point
we
know
that
it
is
impossible
to
visit
the
rest
of
the
unvisited
points,
then
we
can
prune
the
path
d
Finals
2010
Solutions
n.d.).
If
at
g then
the
optimal
solution
impossible
(or
generating
takes
acan
the
optimal
time).
Since
solution
this
is
approach
impossible
(or
takes
reallyfor
asuitable
long
time).
fordeep
Since
thisa
competitive
programming,
Ilong
will
not
discuss
this
approach
inisIOI
detail.
immediately.
However,
it IOI.
isimmediately.
not
very
suitable
for
IOI.
Usually,
problems
require
analysis
backtrack
However,
it
is
not very
suitable
IOI.
Usually,
IOI
probl
webacktrack
canthe
prune
the
path
ediately.
However,
it deep
isisnot
very
for
Usually,
IOI
problems
require
deep
analysis
from
OI
problems
require
analysis
from
contestant.
Itand
is suitable
rare
that
we
get
Accepted
by
only
"hacking"
anot
complete
search
algorithm.
There
count
the
number
of
ICPC
World
Finals
2010
Solutions
n.d.).
If
at
possible
paths
(ACM
),
which
is
known
to
he
rest
of
the
unvisited
points,
then
we
can
prune
the
path
and
backtrack
immediately.
However,
it get
is
not
very
suitable
for
Usually,
IOI pro
backtrack
immediately.
However,
itcan
is
not
very
for
IOI.
Usually,
problems
require
deep
analysis
fros
s,
then
we
can
prune
the
path
and
This
approach
is
useful
in
some
programming
problems.
In
ACM
International
Collegiate
ve
Ican
will
not
this
competitive
approach
in
programming,
I we
will
not
discuss
this
approach
inIOI.
detail.
the
contestant.
ItTherefore,
isdiscuss
rare
that
we
get
Accepted
by
only
"hacking"
aIOI
complete
search
algorithm.
Therefore
the
contestant.
Itdetail.
issuitable
that
can
Accepted
by only
"hacking"
aProgrammin
complete
blems
require
deep
analysis
from
It programming,
is rare
that
we
get
Accepted
by
only
arare
complete
search
algorithm.
Therefore,
we
mplete
search
algorithm.
we
will
not
discuss
this
technique
in"hacking"
detail.
),
which
is
known
to
isit
the
rest
of
the
unvisited
points,
then
we
can
prune
the
path
and
problem
is
to
prune
itable
for
IOI.
Usually,
IOI
problems
require
deep
analysis
from
the
contestant.
It
is
rare
that
we
can
get
Accepted
by
only
"hacking"
a
complete
the
contestant.
It
is
rare
that
we
can
get
Accepted
by
only
"hacking"
a
complete
search
algorithm.
Therefore,
w
roblems
require
deep
analysis
from
Contest
(ICPC)
World
Finals
2010,
problem
I
(Robots
on
Ice)
required
the
contestant
to
count
the
number
o
will
notindiscuss
this technique
in detail.
discuss this technique in 3.2
detail. Pruning
ethis
search
algorithm.
Therefore,
we will not
technique
detail.
3.3.
Finding
Small
problem
is
todiscuss
prune
ry
for
IOI.
Usually,
IOIconstraints
problems
require
deep
fromin2010
n.d.).
If Paths
at
dSolutions
bysuitable
only
a Therefore,
complete
search
algorithm.
Therefore,
weFinals
will
not
discuss
thisanalysis
technique
detail.
will "hacking"
not
this
technique
in3.2
detail.
te
search
algorithm.
weConstraints
Hamiltonian
with
(ACM
ICPC
World
problem
statement
n.d.),
which
is
known
t
Pruning
3.2 Pruning
3.3
Finding
Small
Constraints
n.d.).
Ifand
atproblem.
epted
bythe
"hacking"
complete
Therefore,
we
nSolutions
prune
path
This aapproach
useful algorithm.
inall
some
competitive
problems.
In for
ACM
Collegia
be
aonly
NPhard
Whileis search
nding
possible
paths isprogramming
impossible,
the
solution
thisInternational
problem is to
prun
3.3
Finding
Small
Constraints
3.3
Finding
Small
Constraints
3.3
Finding
Small
Constraints
ints
noach
prune
the
path
and
is
useful
in
some
competitive
programming
This
approach
problems.
is
useful
In
in
ACM
some
International
competitive
Collegiate
programming
Programming
problems.
In
ACM
Inte
e deep
fromContest
(ICPC)
World
Finals
2010,
problem
I
(Robots
on
Ice)
required
the
contestant
to
coun
ICPC
World
Finals
2010
Solutions
n.d.).
IfNa
theanalysis
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
Suppose
there
an
NPhard
problem
with
large
N
that
is
impossible
to
solve
exponentially
(e.g.
Suppose
thereisis
an
NPhard
problem
large
that
is
impossible
to
solve
expo3.3 Finding Small Constraints
3.3 Finding Small Constraints
e
deep
analysis
from
ICPC)
World
Finals
2010,
problem
I
Contest
(Robots
(ICPC)
on
Ice)
World
required
Finals
the
2010,
contestant
problem
to
count
I
(Robots
the
number
on
Ice)
required
of
the
co
rithm.
Therefore,
we
Hamiltonian
Paths
with
constraints
(ACM
ICPC
World
Finals
2010
problem
statement
n.d.),
w
Suppose
there
is
an
NPhard
problem
with
large
N
that
is
impossible
to
solve
exponentially
(e.g.
N
>
Suppose
there
is
an
NPhard
problem
with
large
N
that
is
impossible
to
solve
is
an
NPhard
problem
with
large
N
that
is
impossible
to
solve
exponentially
(e.g.
N
>
50).
some
point
we
know
that
it
is
impossible
to
visit
the
rest
of
the
unvisited
points,
then
we
can
prune
the
path
an
o
solve
exponentially
(e.g.
N
>
50).
nentially we
(e.g.
Sometimes
should
also look
formay
other
small
Sometimes
should also).look
for otherwe
small
constraints
that
help.
Forconstraints
example, a SUBSETSUM
gs Small Constraints
Suppose
there
is
an
NPhard
problem
with
large
N
that
is
impossible
to
solv
Suppose
there
is
an
NPhard
problem
with
large
N
that
is
impossible
to
solve
exponentially
(e.g.
N
>
rithm.
Therefore,
we
an
Paths
with
constraints
(ACM
Hamiltonian
Paths
with
constraints
(ACM
ICPC
World
Finals
2010
problem
statement
n.d.),
ICPC
which
World
is
Finals
known
2010
to
problem
sta
be
a
NPhard
problem.
While
nding
all
possible
paths
is
impossible,
the
solution
for
this
Sometimes
we
should
also
look
for
other
small
constraints
that
may
help.
For
example,
a
SUBSETSUM
pro
Sometimes
we
should
also
look
for
other
small
constraints
that
may
help.
For
exam
ve
exponentially
(e.g.
N
>
50).
hould
also
look
for
other
small
constraints
that
may
help.
For
example,
a
SUBSETSUM
problem
backtrack
immediately.
However,
it isa SUBSETSUM
notand
verywill
suitable
for
IOI.isUsually,
problems
fro5
For example,
SUBSETSUM
problem
may help.
For
example,
problem
considered
an
NPhard
probding
Small
Constraints
isathat
considered
an NPhard
problem,
not be
solvable
with NIOI
= 100.
Whenrequire
we
aredeep
givenanalysis
the constr
N
that
is
impossible
to
solve
exponentially
(e.g.
N
>
50).
Sometimes
we
should
also
look
for
other
small
constraints
that
may
help.
For
exw
Sometimes
we
should
also
look
for
other
small
constraints
that
may
help.
For
example,
a
SUBSETSUM
proble
olve
exponentially
(e.g.
N
>
50).
2
hard
problem.
While
nding
all
possible
be
a
paths
NPhard
is
impossible,
problem.
While
the
solution
nding
for
all
this
possible
problem
paths
is
is
to
impossible,
prune
the
solu
ICPC
World
Finals
2010
Solu
the
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
considered
anwill
NPhard
and
will
not100.
be
N
100.
When
we
are
given
constraint
isthat
considered
an
NPhard
problem,
and
will
not
solvable
with
=the
100.
When
ample,
aiscontestant.
SUBSETSUM
problem
NPhard
problem,
and
will
not
beproblem,
solvable
with
Nsmall
=
When
wewith
are
given
thebe
constraint
that
not
be
solvable
with
. solvable
When
we
are
given
the
constraint
allNusing
thewe
It
is
rare
that
we
can
get
Accepted
by
only
a=problem
complete
search
algorithm.
Therefore,
When
are
given
constraint
alllem,
the and
elements
inside
the
array
are
(e.g.
[0, "hacking"
100]),
this
can
be that
solved
O(N
X )w
D
large
N
that
is
impossible
to
solve
exponentially
(e.g.
N
>
50).
2
straints
that
may
help.
For
example,
a
SUBSETSUM
problem
2
is
considered
an
NPhard
problem,
and
will
not
be
solvable
with
N
=
100.
When
is
considered
an
NPhard
problem,
and
will
not
be
solvable
with
N
=
100.
When
we
are
given
the
constraint
th
2
example,
a
SUBSETSUM
problem
ICPC
World
Finals
2010
Solutions
n.d.).
If
at
ICPC
World
ential
algorithm
we
use
to
nd
all
possible
the
exponential
paths
(ACM
algorithm
we
use
to
nd
all
possible
paths
(ACM
some
point
we
know
that
it
is
impossible
to
visit
the
rest
of
the
unvisited
points,
then
we
can
pru
all
the
elements
inside
the
array
are
small
(e.g.
[0,
100]),
this
problem
can
be
solved
using
O(N
X
)
Dyna
all
the
elements
inside
the
array
are
small
(e.g.
[0,
100]),
this
problem
can
be
so
nsan
we
given
the
constraint
that
the
elements
inside
the
array
are
small
(e.g.
),
this
problem
can
be
solved
using
inside
the
array
are
small
(e.g.
[0,
100]),
this
problem
can
be
solved
using
O(N
X
)
Dynamic
will
not
discuss
this
technique
in
detail.
beare
solved
using
O(N
X
)
Dynamic
Programming, where X is the upper bound of the elements inside the array. Even though the running
tim
2 can be
lltsolvable
constraints
that
example,
arest
SUBSETSUM
problem
with
Nupper
100.
When
we
are
given
the
constraint
that
2 where
all
thepoint
elements
array
are
small
(e.g.
[0,
100]),
this
problem
all
the
elements
the
array
are
small
(e.g.
[0,
this
problem
can
solved
using
O(N
Xconstraint.
) Dynam
en
weknow
are
given
the
constraint
that
we
that
it=may
isX
impossible
to
visit
some
the
of
we
the
know
unvisited
itvery
points,
is
impossible
then
we
to
can
visit
prune
the
rest
the
of
path
the
and
unvisited
points
backtrack
immediately.
However,
it
not
suitable
for
IOI.
Usually,
IOI
problems
require
de
Programming,
X
isof
the
upper
bound
ofinside
the
elements
inside
array.
Even
though
the
running
time
o
Programming,
where
Xisthat
is
the
bound
of
thebe
elements
inside
the
array.
Even
help.
Dynamic
Programming,
where
100]),
isthe
the
upper
bound
of
the
elements
inside
solved
using
O(N
)inside
Dynamic
where
X
is
the
bound
ofFor
the
elements
inside
array.
Even
though
thestill
running
time
offor
the
y.
Even
though
the
running
time
the
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
is
fast
enough
the
given
2 constraint that
2can
ot
be
solvable
with
N
=
100.
When
we
are
given
the
ally
(e.g.
N
>
50).
0,
100]),
this
problem
be
solved
using
O(N
X
)
Dynamic
Programming,
where
X
is
the
upper
bound
of
the
elements
inside
the
array.
Eve
Programming,
where
X
is
the
upper
bound
of
the
elements
inside
the
array.
Even
though
the
running
time
of
e
solved
using
O(N
X
)
Dynamic
immediately.
However,
it
is
not
very
backtrack
suitable
for
immediately.
IOI.
Usually,
However,
IOI
problems
it
is
not
require
very
suitable
deep
analysis
for
IOI.
from
Usually,
IOI
pro
the
array.
Even
though
the
running
time
of
the
algorithm
is
exponential
to
the
size
of
the
contestant.
It
is
rare
that
we
can
get
Accepted
by
only
"hacking"
a
complete
search
algorithm
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
is
still
fast
enough
for
the
given
constraint.
Ano
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
is
still
fast
enough
fo
n
though
the
running
time
of
the
onential
size
the this
input,
the algorithm
is still
enough
the too
given
constraint.
nough
forto the
given
constraint.
Another
way
to of
apply
technique
is when
the fast
value
of N for
is Constraints
not
large
(e.g. NAnother
< 40). For example, whilt
3.3
Finding
2 Small
ally
(e.g.
N
>
50).
e.g.
[0,
100]),
this
problem
can
be
solved
using
O(N
X
)
Dynamic
BSETSUM
problem
elements
inside
the
array.
Even
though
the
running
time
of
the
N"hacking"
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
still
fast
enough
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
is
still
fast
enough
for
the
constraint.
Anoth
N
ven
though
the
running
time
of
the
the
input,
the
algorithm
is
still
fast
enough
for
the
given
constraint.
Another
way
N/2
stant.
It
is
rare
that
we
can
get
Accepted
the
contestant.
by
only
"hacking"
It
is
rare
a
that
complete
we
can
search
get
Accepted
algorithm.
by
Therefore,
only
we) (e.g.
a complete
will
discuss
technique
inin
detail.
way
to
apply
this
technique
isis)to
when
therun
value
of Nsecond,
tooFor
large
<isuse
40).
For
example,
while
O4
way
apply
this
technique
isnot
when
the
value
ofNN
not
too
large
N
<
the
givenalgorithm
Another
isfor
isconstraint.
when
the
value
of
Nthis
not
too
large
(e.g.
Nis <
40).
example,
while
O(2
)tois
Ntechnique
< 40).
For
example,
while
O(2
fornot
N
= 36
is
unlikely
to
one
we
can,
for(e.g.
instance,
agiven
O(2
Meet
In
The
BSETSUM
problem
f
the
elements
inside
the
array.
Even
though
the
running
time
of
the
N/2
n
the
constraint
that
e
algorithm
is
still
fast
enough
for
the
given
constraint.
Another
N
N/2
way
to
apply
this
technique
is
when
the
value
of
N
is
not
too
large
(e.g.
N
<a
way
to
apply
this
technique
is
when
the
value
of
N
is
not
too
large
(e.g.
N
<
40).
For
example,
while
O(2
N/2
hscuss
for
the
given
constraint.
Another
there
is
an
NPhard
problem
with
large
N
that
is
impossible
to
solve
exponentially
(e.g.
N
>
50
apply
this
technique
is
when
the
of
is
not
too
large
(e.g.
).
For
exN/2
this
technique
in
detail.
will
not
discuss
this
technique
in
detail.
for
N
=
36
is
unlikely
to
run
in
one
second,
we
can,
for
instance,
use
a
O(2
)
Meet
In
The
M
algorithm
for
N
=
36
is
unlikely
to
run
in
one
second,
we
can,
for
instance,
use
<ce,
40).
For
example,
while
O(2
)
=
36Suppose
is
unlikely
to
run
in
one
second,
we
can,
for
instance,
use
a
O(2
)
Meet
In
The
Middle
use
aalgorithm
O(2
)
Meet
In
The
Middle
for solving a problem like SUBSETSUM.
While O(2
) is still exponential
to N , it is much fas
2 algorithm
N
N/2
N
n
the
constraint
that
the
algorithm
is
still
fast
enough
for
the
given
constraint.
Another
N/2
N/2
geut,
O(N
X
)
Dynamic
N
is
not
too
large
(e.g.
N
<
40).
For
example,
while
O(2
)
N/2
N/2
algorithm
for
=
unlikely
to
one
can,
instance,
use
ample,
while
While
algorithm
for
isis
unlikely
to run
run
in
second,
we
can,
for
= 36
isa unlikely
run
one
second,
we
can,
for
instance,
use
aa O(2
)solution.
In The
Midd
<
For)to
example,
while
O(2
)than
Sometimes
also
look
for
other
small
constraints
that
For
example,
athan
proble
N
NSUBSETSUM
algorithm
solving
problem
like
SUBSETSUM.
While
O(2
)help.
still
exponential
to
,Meet
much
faster
algorithm
for
solving
a36problem
likemay
SUBSETSUM.
While
O(2
)itfor
isis still
exponent
a 40).
O(2
Meet
InN
The
Middle
lving
aalgorithm
problem
like
SUBSETSUM.
O(2
)Nissolve
still
exponential
to
N
,isof
itin
isN
much
faster
xponential
N
,we
itfor
isshould
much
faster
Nto
that
itin
can
is
twice
the
range
using
O(2
)N
3.3
Finding
Small
Constraints
2N/2O(2 ), and the range of N/2
N
N/2
N/2
gese
O(N
X
)
Dynamic
ue
of
N
is
not
too
large
(e.g.
N
<
40).
For
example,
while
O(2
)
N
N
N and
running
time
of
the
ond,
we
can,
for
instance,
a
O(2
)
Meet
The
Middle
N
for
use
a
Meet
In
The
Middle
algorithm
for
solving
a
problem
like
algorithm
for
solving
a
problem
like
SUBSETSUM.
While
O(2
)
is
still
expone
algorithm
for
solving
a
problem
like
SUBSETSUM.
While
O(2
)
is
still
exponential
to
N
,
it
is
much
faster
thN
N
a
O(2
)
Meet
In
The
Middle
is
considered
an
NPhard
problem,
will
not
be
solvable
with
N
=
100.
When
we
are
given
the
constraint
tha
),
the
range
oftwice
NO(2
that
canthe
solve
isusing
twice
range
of solve
N Finding
using
a O(2
)range
solution.
and
of N
that
can
is twice
the
of
N using a O(2
toofO(2
N)N
,solution.
itthat
is and
much
faster
than
range
it can
solve
isFinding
the),itrange
of range
NConstraints
a the
O(2
)it solution.
gntial
a O(2
3.3
Small
3.3
Small
Constraints
N/2
N/2
Nit
N
Nfaster
2
running
time
of
the
second,
we
can,
for
instance,
use
a
O(2
)
Meet
In
The
Middle
ne(2
constraint.
Another
Suppose
there
is
an
NPhard
problem
with
large
N
that
is
impossible
to
solve
exponentially
SUBSETSUM.
While
is
still
exponential
to
,
it
is
much
than
.eWhile
O(2
)
is
still
exponential
to
N
,
is
much
faster
than
N
O(2
),
and
the
range
of
N
that
it
can
solve
is
twice
the
range
of
N
using
a
O(
O(2
),
and
the
range
of
N
that
it
can
solve
is
twice
the
range
of
N
using
a
O(2
)
solution.
nential
to
N
,
it
is
much
faster
than
all
the
elements
inside
the
array
are
small
(e.g.
[0,
100]),
this
problem
can
be
solved
using
O(N
X
)
Dynam
) solution.
N/2
3.4
Finding
Special
Cases
N
N
nthere
constraint.
Another
isWhile
an NPhard
large
Suppose
isimpossible
an
NPhard
to
solve
problem
exponentially
with
large
(e.g.
N
N
is>a
impossible
50). time
toofsol
range
oftoN
that
itmuch
can
solve
isinside
twice
the
range
ofthough
that
using
SUM.
O(2
), problem
isand
still
exponential
N that
, there
it
is
faster
than
ample,
while
O(2
)where
Sometimes
we
should
also
look
for
other
small
constraints
that
may
help.
For
example,
a SUBSE
ice
the
range
of
NN using
aXthe
O(2
) solution.
O(2
)Programming,
solution.
iswith
the
upper
bound
ofis
the
elements
the
array.
Even
the
running
th
3.4
Finding
Special
Cases
3.4
Finding
Special
Cases
3.4
Finding
Special
Cases
es
N solution.
N
ample,
while
O(2
)
sMeet
should
also
look
for
other
small
Sometimes
constraints
we
that
should
may
help.
also
look
For
for
example,
other
small
a
SUBSETSUM
constraints
that
problem
may
help.
For
ex
iswe
twice
the
range
of
N
using
a
O(2
)
solution.
In TheThis
Middle
is considered
an size
NPhard
and
will
not
be
solvable
with
N
=
100.
When
we
are
given
th
algorithm
is is
exponential
the
of 3.4
theproblem,
input,
the
algorithm
is
still
fast
enough
for
the
given
constraint.
Anoth
the
most to
suitable
approach
inFinding
IOI,
and
thus
is
the
main
focus
of
this
paper.
To
solve
IOI
200
Finding Special Cases
Special 3.4
Cases
In
The
Middle
red
an
NPhard
problem,
and
willIsland
not
isinside
be
considered
solvable
with
an
NPhard
NNapproach.
=
100.
When
and
we
are
willnd
given
not
be
the
solvable
constraint
with
N
=
100.
When
tMeet
issuitable
much
faster
than
all
the
elements
the
array
are
small
(e.g.
[0,
100]),
this
problem
can
bethat
solved
using
O(
This
is
the
most
suitable
approach
in
IOI,
and
thus
isproblem,
the
main
focus
of
paper.
To
solve
2008
IsN
This
isthe
the
most
suitable
approach
in
IOI,
and
thus
is
the
main
focus
of
this
pa
ting
approach
in IOI
IOI,
and
thus
is
main
focus
of
paper.
To
solve
2008
Island
way
to
apply
this
technique
is
the
value
of
isthis
not
too
large
(e.g.
NIOI
<
40).
For
example,
while
O(2
this
paper.
To
solve
2008
and
IOI
2014
Friend,
wewhen
need
to
use
this
We
must
athis
special
constraint
inIOI
the
probl
Special
Cases
2
This
isin
the
most
suitable
approach
inthis
IOI,
and
thus
main
focus
ofcan
this
N/2
This
issolve
the
most
suitable
approach
IOI,
and
thus
isthe
the
main
focus
of
this
paper.
To
solve
IOI
2008
Isla
tpaper.
is much
faster
than
ments
inside
the
array
are
small
(e.g.
allto
the
[0,
100]),
elements
this
inside
problem
can
array
be
are
solved
small
(e.g.
O(N
[0,
100]),
Xis
)the
Dynamic
problem
be
n.
Programming,
where
X
is
upper
of
the
elements
inside
array.
Even
though
the
run
and
IOI
2014
we
need
to
use
this
approach.
We
must
nd
athe
special
constraint
in
the
problem
and
IOI
2014
Friend,
we
need
to
use
approach.
We
must
nd
special
c
To
IOI
2008
Island
Friend,
we
need
to
use
this
approach.
We
must
nd
a bound
special
constraint
inusing
problem
such
algorithm
for
N
=Friend,
36
is
unlikely
run
inthe
one
second,
we
can,
for
instance,
use
athe
O(2
)this
Meet
InaThe
Midd
pecial
constraint
in
the
problem
such
Finding
Special
Cases
that
this
constraint
allows
the
problem
to
be
solvable
in
polynomial
time.
We
can
check
whether
an
ad
hus
is
the
main
focus
of
this
paper.
To
solve
IOI
2008
Island
and
IOI
2014
Friend,
we
need
to
use
this
approach.
We
must
nd
a
special
N/2
and
IOI
2014
Friend,
we
need
to
use
this
approach.
We
must
nd
a
special
constraint
in
the
problem
su
s.aint
paper.
To
solve
IOI
2008
Island
n.
ming,
where
X
is
the
upper
bound
of
Programming,
the
elements
inside
where
the
X
array.
is
the
Even
upper
though
bound
the
of
the
running
elements
time
inside
of
the
the
array.
Eve
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
is
still
fast
enough
for
the
given
con
that
this
constraint
allows
the
problem
to
be
solvable
in
polynomial
time.
We
can
check
whether
an
additi
that
this
constraint
allows
the
problem
to
be
solvable
in
polynomial
time.
We
ca
constraint
in the
problem
such
the
problem
toan
solvable
polynomial time.
WeO(2
can check
whether
an additional
algorithm
for
solving
a be
problem
likeinSUBSETSUM.
While
) is still
exponential
to N , it is much faster tha
Weallows
can check
whether
additional
nd
thus
theinto
main
focus
of
this
paper.
Tothe
solve
IOI
2008
Island
ach.
WeisNmust
nd
asize
special
constraint
in
problem
such
that
this
constraint
allows
the size
problem
togiven
be
solvable
in polynomial
time.
We
N algorithm
that
this
constraint
the
problem
to
be
solvable
invalue
polynomial
time.
can
check
an
addition
al
constraint
the
problem
is exponential
the
ofallows
thesuch
input,
algorithm
the
algorithm
is exponential
istwice
still
fast
to
enough
for
of
input,
constraint.
the
Another
is
enough
way
to
apply
this
technique
is
the
ofofN
not
too
large
Nwhether
< still
40).fast
For
examp
can
check
whether
an
additional
O(2
), and
the
range
of
N
that
it can
solve
iswhen
the
range
Nisthe
using
aWe
O(2
) (e.g.
solution.
N
N/2
pproach.
We
must
nd
a
special
constraint
in
the
problem
such
able
in
polynomial
time.
We
can
check
whether
an
additional
eply
canthis
check
whether
an
additional
technique
isalgorithm
when
thefor
value
N
toisisapply
not too
thistolarge
technique
when
< 40).
the
For
value
example,
of N
iswhile
not too
O(2
<
N way
=of36
unlikely
run (e.g.
in oneisNsecond,
we
can,
for
instance,
use large
a)O(2(e.g.) N
Mee
Irvin
GUNAWAN
N/2 N/2
eolve
solvable
inJonathan
polynomial
time.
Weone
can
check
whether
an
additional
IOI=2008
Island
for
N
36
is
unlikely
to
run
in
algorithm
second,
we
for
can,
N
=
for
36
instance,
is
unlikely
use
to
a
run
O(2
in
one
)
Meet
second,
In
The
we
can,
Middle
for
instance,
use
algorithm
for
solving
a
problem
like
SUBSETSUM.
While
O(2
)
is
still
exponential
to
N
,
it
is
Jonathan Irvin GUNAWANJonathan
Irvin Finding
GUNAWANSpecial Cases
GUNAWAN
3.4
N/2
N/2 N
olve
IOI
2008
Island
n
problem
suchO(2
Irvin
GUNAWAN
forthe
solving
a problem
likeNSUBSETSUM.
algorithm
for
O(2
solving
is
a problem
still
exponential
to range
N , it of
is much
faster
O(2
than
) is
still expone
Jonathan
Irvin
GUNAWAN
), and the Jonathan
rangeWhile
of N
that
it )can
solve
is like
twiceSUBSETSUM.
the
NWhile
using
a O(2
) solution.
N
N
n
the
problem
such
hether
an
additional
is the
approach
in), the
IOI,
and
thus
the
main
of this
paper.theTorange
solveofIOI
2008 Islan
nd theThis
range
of Nmost
thatsuitable
it can solve
isO(2
twice
andrange
the range
of Nisof
using
N that
a O(2
itfocus
can
) solution.
solve
is twice
N using
aO
hether
an IOI
additional
and
2014 Friend, we need to use this approach.
We
must
nd
a
special
constraint
in
the
problem
suc
3.4 Finding Special Cases
that this constraint allows
the
problem
to
be
solvable
in
polynomial
time.
We
can
check
whether
an
addition
3.4 Finding Special Cases
3.4 Finding Special Cases
This is the most suitable approach in IOI, and thus is the main focus of this paper. To solve
e most suitable approach
in 2014
IOI, and
This
thus
iswe
is
thethe
most
main
focus
approach
this paper.
in IOI,
Tomust
and
solve
thus
IOIisa2008
the
main
Island
focus of this
and IOI
Friend,
need
tosuitable
use
thisof
approach.
We
nd
special
constraint
in th
014 Friend,
we
need
to
use
this
approach.
and
IOI
2014
We
must
Friend,
nd
we
a
need
special
to
constraint
use
this
approach.
in
the
problem
We
must
such
nd
a
special
this constraint allows the problem to be solvable in polynomial time. We can check wheth
Jonathan Irvin that
GUNAWAN
constraint allows the problem to be that
solvable
this in
constraint
polynomial
allows
time.theWe
problem
can check
to bewhether
solvableaninadditional
polynomial time. We
Irvin GUNAWAN
s forget
value
of
Nonly
on
awhether
MacBook
Pro
(Retina,
13inch,
Early
2015)
be a NPhard
problem.
While
nding
allthe
possible
paths
impossible,
the solution
for
We
will
give
we
one"hacking"
example
a special
case
in
a with
NPhard
problem.
have
a function
with the
can
Accepted
by
aofcomplete
search
algorithm.
Therefore,
weSuppose
following
formula
the
the
subset.
subset.
Suppose
Suppose
we
we already
already
know
know
that
that
MINVERTEXCOVER
MINVERTEXCOVER
isis aa NPhard
NPhard problem.
problem. Therefore
Therefor
1,
n
=
1
n
=
2
We
We
will
will
rst
rst
prove
prove
the
the
following
following
two
two
lemmas.
lemmas.
We
will
rst
prove
the
following
two
lemmas.
N following
N/2
ICPC
World
Finals
2
the
exponential
algorithm
we
use
to
nd
all
possible
paths
(ACM
f
(n)
=
formula
We
will
give
we
one
example
of
a
special
case
in
a
NPhard
problem.
Suppose
we
have
a
function
with
the
) and O(2
) SUBSETSUM
algorithm running time
foraavarious
sizes. by
This
etail.
1,1,input
nn=
1MINVERTEXCOVER
n
=MINVERTEXCOVER
1nthe
that
MAXINDEPENDENTSET
isproblem.
is also
also
NPhard
NPhard
problem
problem
by
reducing
reducing
aawith
We
willone
rstexample
prove that
the
We
will
give
we+
one
example
of
a2impossible
special
case
a NPhard
problem.
Suppose
we
=2have
1then
naw
=
1,invisit
=n=1=22points,
nn=
f two
(n
lemmas.
1)
f (n
2),
n
>(n)
ve we
of following
aMAXINDEPENDENTSET
special
case
in
awe
NPhard
Suppose
we
have
a1,
function
f
(n)
=
f
=
some
point
know
that
it
is
to
the
rest
of
the
unvisited
following
formula
ortoLemma
each
value
of
on
MacBook
Pro the
(Retina,
13inch,
Early
2015)
be solvable
polynomial
time
using
reduction
proof
problem
(withf1,1)
(n)
=
f (n)
=
Lemma
1.
1.
Lemma
1.of Ifthe
Ifin
If N
SS
VVa is
is an
an
INDEPENDENTSET
INDEPENDENTSET
of
of graph
graph
S
G(V,
G(V,
VE),
E),
then
an
then
VV
2),
SS2),
isis n
aanVERTEXCOVER
VERTEXCOVER
of
of the
theE
n = of
1 graph
n = 2G(V,
MAXINDEPENDENTSET
problem.
problem.
foriginal
1)
++
fINDEPENDENTSET
>
f(n
(n
is
f(n
(n
2(n
n following
= 1 nbacktrack
=formula
2
mula n = 1 n = 2MAXINDEPENDENTSET
fE),
(n)
=not
fa
(n
1)IOI.
+>2fto
22),IOI
nthe
>2
fto
(n
1)
+
fVERTEXCOVER
(n
2),
nknow
>
1,
n
=
1
n
=
2
immediately.
However,
it
is
very
suitable
for
Usually,
problems
r
the
sequence
F
=
{f
(n)}
,
and
we
dene
F
(N
)
to
be
the
rst
N
terms
of
F
.
We
want
t),
and
check
whether
the
proof
still
holds
given
the
additional
constraint
the
problem.
mma
1.
If
S
V
is
an
INDEPENDENTSET
of
graph
G(V,
then
V
S
is
of
N/2
graph
graph
G(V,
G(V,
E)
E)
graph
G(V,
E)
n=1
3.3
Finding
Small
Constraints
)),
and
SUBSETSUM
algorithm
running
time for various
f (n This
1) + f (n 2), n > 2
f (n) =
n+O(2
>
2(n )2),
input sizes.
1)
f
n
>
2
We
consider
the
sequence
F
=
{f
(n)}
,
and
we
dene
F
(N
)
to
be
the
rst
N
terms
of
F
.
We
consider
the
sequence
F
=
{f
(n)}
,
and
we
dene
F
(N
)
to
be
the
rst
N
terms
of
F
We
consider
the
sequence
,
and
we
define
to
be
the
first
the
contestant.
It
is
rare
that
we
can
get
Accepted
by
only
"hacking"
a
complete
search
1,
n
=
1
n
=
2
can
create
a
partition
of
F
(N
)
into
two
disjoint
multisets
A
and
B
such
that
the
sum
of
all
elements
n=1
n=1
ffollowing
(n
1)
+
f=
(n
original
2),F n=1
n {f
>
2 we
hbe
G(V,
E) in
We
consider
the
sequence
=
(n)}
, and we
dene
F=(N
) to
rs
consider
the
sequence
{f
(n)}
, and
dene
F (N
)
tonbe
the
rstbeNthe
term
n=1
We
will
willWe
rst
rst
prove
prove
the
the
following
two
lemmas.
lemmas.
each
value
ofus
Nassume
on aWe
MacBook
Pro
13inch,
Early
solvable
polynomial
time
reduction
proof
of
the
(with1,
n
=
2A,
fS
(n)
=
problem
1,
n two
=F
1of
n2015)
=
2Therefore,
Proof.
Proof.
Proof.
Let
Let
us
assume
that
that
Vusing
VB
Sthe
is(Retina,
is
not
not
VERTEXCOVER.
VERTEXCOVER.
Let
us
assume
Therefore,
that
Vthere
there
dene
SReduction
are
is
are
two
a 1vertices
vertices
VERTEXCOVER.
A,
B
B
/
/that
VN
V
The
SS s
We
consider
the
sequence
F
=
{f
(n)}
, into
and
we
Ftwo
(N
)A
be
the
rst
term
whether
we
can
create
partition
of
F
)partition
multisets
A
and
B
such
the
ntifying
ntifying
Intractability
Intractability
of
of
a
a
Problem
Problem
through
through
Reduction
N
)to
tothe
be
the
rst
Nto
terms
of
F
.
We
want
toaathis
know
with
large
N
that
whether
isof
impossible
can
create
to
solve
a(n
partition
exponentially
F(N
(N
(e.g.
)into
into
Ntwo
two
>
50).
disjoint
multisets
and
B
such
that
the
case
terms
.we
We
want
to
know
whether
we
can
create
adisjoint
partition
ofnot
to
into
two
will
not
discuss
technique
in
detail.
n=1
al
sum
of
all
elements
in
fpartition
(n)
=
ample
of
a
special
in
a
NPhard
problem.
Suppose
we
have
a
function
with
the
f
(n)
=
f
1)
+
f
(n
2),
n
>
2
dblem
we
dene
F
(N
)
be
the
rst
N
terms
of
F
.
We
want
to
know
whether
we
can
create
a
of
F
(N
)
into
two
disjoint
multisets
A
and
B
whether
we
can
create
a
of
F
(N
)
two
disjoint
multisets
A
and
B
such
tha
and
check
whether
the
proof
still
holds
given
the
additional
to
the
problem.
We
consider
thedisjoint
sequence
{f
,create
and
we
dene
(N
)F
to
be
rst
N
terms
of
Fthe
.BWe
want
know
n=1
fin
(n
1)
+the
f (n
2),
nAs
>
2Since
of.
Let
us
that
Vconnecting
is=
not
aV+
VERTEXCOVER.
Therefore,
there
are
vertices
A,
/are
V a
fF
(n
1)
fiscan
(n
2),
nA,
>
and
and
there
there
isconstraints
is an
an
edge
edge
connecting
A
A(n)}
and
and
B.
B.
Since
Since
and
there
B
B2
/constraint
/is
VVF
an
edge
S,
S,
we
we
connecting
have
have
A,
A,
B
Btwo
A
and
S.
S.
As
B.
A
A
and
and
B
A,
B
B
are
/a
connected
connected
V
S, we
whether
aA,
partition
of
(N
)problem
into
two
disjoint
multisets
A
and
BSto
such
th
Vwe
and
such
that
the
sum
of
all
elements
in
is
equal
toV
sum
inthat
Amultisets
is
equal
to
the
sum
of
all
elements
in
B
multisets
A assume
and
B
such
the
sum
of
all
elements
small
in
that
A
isS
may
equal
help.
to
the
For
sum
example,
ofsum
all
aof
elements
SUBSETSUM
B
Lemma
Lemma
1.
1.
If
If
SS
is
an
an
INDEPENDENTSET
INDEPENDENTSET
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
V
S
S
is
is
VERTEXC
VERTEXo other
two
disjoint
multisets
A
and
B
such
that
the
sum
of
all
elements
in
A
is
equal
to
the
sum
of
all
elements
in
B
in
A
is
equal
to
the
all
elements
in
B
whether
can
create
a partition
of
F
(N
),the
into
two
disjoint
multisets
A
and
Bnot
such
that
the
ofwant
all
elements
We
the
sequence
F
=
{f
(n)}
and
we
dene
Fwe
(N
)This
to
be
the
rst
N
terms
of
F
.sum
We
toSSknow
ke
ke
to
to will
know
know
that
that
the
the
problem
problem
that
that
we
we
are
are
attempting
attempting
is
unlikely
unlikely
to
to
have
have
an
an
immediate
immediate
solution.
solution.
The
The
there
isconsider
edge
connecting
A
and
B.
Since
A,
Bsum
/{f
Vis
S,
have
B
S.
As
and
B
are
connected
n=1
by
by
an
an
edge,
edge,
we
we
note
note
that
that
an
edge,
note
that
S
S
isis
not
an
an
INDEPENDENTSET.
INDEPENDENTSET.
This
is
is
athat
aof
S
contradiction.
contradiction.
isF
INDEPENDENTSET.
Therefore
Therefore
V
of
all
elements
in
not
.sequence
eand
solvable
inwe
polynomial
time
using
the
reduction
proof
of
the
original
problem
(within
A
iswe
equal
to
of
all
elements
inA,
B
not
be
solvable
with
N
=the
100.
When
we
are
given
the
constraint
graph
graph
G(V,
G(V,
E)
E)
ks
like
a an
classic
PARTITION
problem.
PARTITION
problem
is3.3
by
reduction
from
SUBSETWe
consider
Fby
=
(n)}
,aNPhard
and
we
dene
(N
)Aan
to
beConstraints
the
rst
N Vterms
ofisisThi
Faa.
he
sequence
F
=
{f
(n)}
,
and
dene
F
(N
)
to
be
the
rst
N
terms
F
.
We
want
to
know
Finding
Small
n=1
n=1
mple
of
a
special
case
in
a
NPhard
problem.
Suppose
we
have
function
with
the
in
A
is
equal
to
the
sum
of
all
elements
in
B
whether
we
can
create
a
partition
of
F
(N
)
into
two
disjoint
multisets
A
and
B
such
that
the
sum
of
all
elements
2
on
on
way
way
is
to
to
apply
apply
a
a
wellknown
wellknown
technique
technique
called
called
reduction.
reduction.
Suppose
Suppose
we
we
know
know
that
that
problem
problem
X
X
is
is
n
edge,
we
note
that
S
is
not
an
INDEPENDENTSET.
This
is
a
contradiction.
Therefore
V
S
is
a
This
looks
like
a
classic
PARTITION
problem.
PARTITION
problem
is
NPhard
by
VERTEXCOVER.
VERTEXCOVER.
ndVERTEXCOVER.
check
the
proof
still
holds
given
the
additional
constraint
to) two
the
problem.
This
like
classic
PARTITION
PARTITION
problem
isin
bybyreduct
are
small
100]),
this
This
problem
looks
like
can
aThis
be
solved
using
O(N
X
Dynamic
PARTITION
problem
isNPhard
NPhard
reduc
1,value
na=
1classic
=PARTITION
2like
efore,
for whether
a partition
large[0,
of(N
N
itlooks
is
unlikely
to
be
toofA
nd
an
algorithm
that
nds
B
ansuch
whether
can
create
a
partition
(N
)problem.
into
disjoint
multisets
A problem
and
B
that
the
su
an
create
a(e.g.
of
F
), we
into
two
disjoint
multisets
Bproblem.
such
that
the PARTITION
sum
ofA
all1and
elements
looks
aFand
classic
PARTITION
problem.
is by
NP
This
looks
like
an able
classic
PARTITION
problem.
isproblem
NPhard
1PARTITION
in
Af (n)
isand
equal
to
the
sum
ofTherefore,
all
elements
in
B
=
Proof.
Proof.
Let
Let
us
us
assume
assume
that
that
VVlarge
Svalue
Svalue
isisby
not
not
aN
aNVERTEXCOVER.
VERTEXCOVER.
Therefore,
Therefore,
there
are
are
two
two
vertices
vertices
A
ooN
solve,
solve,
and
we
we
also
also
know
know
that
that
we
we
can
can
solve
solve
problem
problem
XX
by
using
using
problem
problem
YY
as
as
ato
a blackbox
blackbox
..nd
Ifnd
Ifthere
we
we
can
can
Suppose
there
is
an
NPhard
problem
with
large
N
that
is
impossible
to
solve
expo
reduction
from
SUBSETSUM.
Therefore,
for
a
large
value
of
,
it
is
unlikely
to
be
TEXCOVER.
This
looks
like
a
classic
PARTITION
problem.
PARTITION
problem
is
NPhard
by
SUM.
for
a
large
of
,
it
is
unlikely
to
be
able
to
an
algorithm
that
n
problem
is
NPhard
by
reduction
from
SUBSETer
bound
of
the
elements
SUM.
inside
Therefore,
the
array.
for
Even
a
though
the
of
running
,
it
is
time
unlikely
of
the
be
able
to
an
algorithm
that
y.
However,
this
sequence
is
dened
in
a
very
special
way,
in
the
sense
that
F
is
dened
using
the
in
A
is
equal
to
the
sum
of
all
elements
in
B
toLemma
the
sum
of
all
elements
in
B
em.
PARTITION
problem
is
NPhard
by
reduction
from
SUBSETSUM.
Therefore,
for
a
large
value
of
N
,
it
is
unlikely
to
be
able
to
nd
an
at
SUM.
Therefore,
for
a
large
value
of
N
,
it
is
unlikely
to
be
able
to
nd
an
algorithm
f
(n
1)
+
f
(n
2),
n
>
2
Lemma
2.
2.
Lemma
2.
If
If
S
S
V
V
is
is
a
a
VERTEXCOVER
VERTEXCOVER
of
of
graph
graph
G(V,
G(V,
If
S
E),
E),
then
V
then
is
V
a
V
VERTEXCOVER
S
S
is
is
an
an
INDEPENDENTSET
INDEPENDENTSET
of
graph
G(V,
of
E),
of
the
the
the
This
looks
like
a
classic
PARTITION
problem.
PARTITION
problem
is
NPhard
by
reduction
from
SUBSETand
and
there
there
is
an
an
edge
connecting
connecting
Asequence
and
and
B.
B.
Since
Since
A,
A,
B
B
/
/away.
Vconstraints
Vvery
S,
S,
we
we
have
have
A,
A,
B
Bthe
S.
S.
As
Asalgorithm
A
Athat
and
and
B
B
ancan
m
m
Y,
then
we
we
can
solve
solve
problem
problem
XXedge
as
as
well.
well.
Therefore,
Therefore,
problem
problem
isisefficient
also
also
impossible
impossible
to
to
solve.
able
find
an
algorithm
that
finds
we
and
for
in
an
However,
this
sequence
Sometimes
we
should
also
look
other
that
may
help.
For
example,
le
ofthe
athen
special
case
into
aecient
NPhard
problem.
Suppose
have
aYY
function
with
the
SUM.
Therefore,
for
aA
value
of
N
,small
it
is
tosolve.
be
able
nd
an
ecient
way.
However,
this
sequence
isin
dened
in
way,
into
sense
that
is
ble
to
nd
algorithm
that
nds
A
and
B
in
an
way.
However,
this
is
dened
in
aunlikely
very
special
way,
in
the
ofY,
input,
the
algorithm
isis
still
fast
enough
for
the
given
Another
F
ned
recurrence.
we
should
inspect
the
formula
more
unlikely
be
able
tofor
nd
an
algorithm
that
nds
Alarge
and
Bconstraint.
an
ecient
way.
However,
this
sequence
is
dened
in
a very
special
way,
inFan
the
ecient
However,
this
sequence
is
dened
inalgorithm
aspecial
very
special
way,
insense
the
sense
th
mma
2.
Ifto
Slooks
V,Therefore,
is
aan
VERTEXCOVER
of
graph
G(V,
E),
then
Vproblem
S
isclosely.
an
INDEPENDENTSET
of
the
1,E)
n)way.
=
1be
nNPhard
=
2recurrence
graph
graph
G(V,
G(V,
E)
graph
G(V,
E)
SUM.
Therefore,
a
large
value
of
N
,
it
is
unlikely
to
be
able
to
nd
an
that
nds
A
and
B
in
This
like
a
classic
PARTITION
problem.
PARTITION
is
NPhard
by
reduction
from
SUBSETN
F
=
{f
(n)}
and
we
dene
F
(N
to
the
rst
N
terms
of
F
.
We
want
to
know
by
by
an
edge,
edge,
we
we
note
note
that
that
S
S
is
is
not
not
an
an
INDEPENDENTSET.
INDEPENDENTSET.
This
This
is
is
a
a
contradiction.
contradiction.
Therefo
Therefo
is
defined
in
a
very
special
way,
in
the
sense
that
is
defined
using
the
aforementioned
is
considered
an
problem,
and
will
not
be
solvable
with
N
=
100.
When
we
are
n=1
ecient
way.
However,
this
sequence
is dened
in
a recurrence
very
special
way,
inmore
the
th
aforementioned
recurrence.
Therefore,
should
inspect
the
formula
closely.
way,
the
that
F
issense
dened
using
the
en
the
value
ofPARTITION
Nsense
isway,
not
aforementioned
too
large
(e.g.
recurrence.
<
40).
Therefore,
For
example,
we
should
while
O(2
inspect
)inspect
the
recurrence
more
closely.
fin
(n)
= in special
This
looks
like
aN
classic
PARTITION
problem.
PARTITION
problem
isformula
NPhard
bysense
reductio
secial
like
aa classic
problem.
PARTITION
problem
iswe
NPhard
by
reduction
from
SUBSETed
very
in
the
that
F
ismultiples
dened
using
the
aforementioned
recurrence.
Therefore,
we
should
inspect
recurrence
aforementioned
recurrence.
Therefore,
we
should
the
recurrence
more
hsing
G(V,
E)
ecient
way.
However,
this
sequence
dened
a of
very
special
way,
in
sense
that
F
isthe
dened
the
Any
consecutive
subsequence
of
Finstance,
with
length
three
can
be
partitioned
into
two
multisets
SUM.
Therefore,
afclosely.
large
value
of
N
it
is
unlikely
to
be
able
to
nd
anthe
algorithm
that
nds
Aformula
andusing
informu
ancc
fproblems
(n
1)for
+
(n
2),
nRecall
>
2is,should
recurrence.
Therefore,
we
inspect
the
recurrence
formula
more
closely.
N/2
artition
of
Fformula
(N
) into
two
disjoint
multisets
Athat
and
Bin
such
that
the
sum
of
all
elements
VERTEXCOVER.
VERTEXCOVER.
sing
NPhard
NPhard
problems
for
for
illustration.
illustration.
Recall
that
NPhard
NPhard
problems
problems
have
have
yet
yet
to
to
be
be
solved
solved
in
in
polynomial
polynomial
all
the
elements
inside
the
array
are
small
(e.g.
[0,
100]),
this
problem
can
beB solved
aforementioned
recurrence.
Therefore,
we
should
inspect
the
recurrence
formula
more
recurrence
more
o
run
in
one
second,
we
can,
for
use
a
O(2
)
Meet
In
The
Middle
Proof.
Proof.
Proof.
The
The
proof
proof
is
is
actually
actually
similar
similar
to
to
the
the
previous
previous
lemma.
lemma.
The
proof
Let
Let
us
us
is
assume
assume
actually
that
that
similar
V
V
to
S
S
is
the
is
not
not
previous
a
a
INDEPENDENTSET.
INDEPENDENTSET.
lemma.
Let
us
assu
SUM.
for
a be
large
value
of Nan, italgorithm
isFF
unlikely
to nds
bemultiples
able
to nd
anan
algorithm
that nd
ore,aforementioned
for a large
value
of
Nformula
, Therefore,
it is
unlikely
to
able
to nd
that
A and
Bthree
in
uld
inspect
the
recurrence
more
closely.
Any
consecutive
subsequence
of
with
length
of
can
partitioned
Lemma
3.sequence
Any
subsequence
of
with
length
multiples
of
canbebeEven
partitione
Lemma
3.
recurrence.
Therefore,
we
inspect
the
recurrence
formula
closely.
m.
ecient
way.
However,
this
isisisnwhere
dened
special
way,
in
the
sense
that
Fthree
isof
dened
using
the
N/2
fe SUBSETSUM.
all
elements
in
B
than
than
44proof
decades.
decades.
MINVERTEXCOVER
MINVERTEXCOVER
aashould
graph
graph
problem
problem
that
that
involves
involves
nding
nding
aaFmore
minimum
minimum
subset
subset
Programming,
X
is
the
upper
bound
of
the
elements
inside
the
array.
thoug
Any
consecutive
subsequence
of
with
length
multiples
of
three
c
1,
n
=
1consecutive
=
2Therefore,
Lemma
3.
Any
consecutive
subsequence
ofconnecting
F
with
length
multiples
three
can
be
part
Lemma
3.
ere
While
O(2
) SS
isthe
still
exponential
toin
Nathere
,very
itin
is
much
faster
than
of.
The
is
actually
similar
to
previous
lemma.
Let
us
assume
that
V
S
is
not
a
INDEPENDENTSET.
=
{f
(n)}
,
and
we
dene
F
(N
)
to
be
the
rst
N
terms
of
F
.
We
want
to
know
Lemma
3.
Any
consecutive
subsequence
of
with
length
multiples
of
three
can
be
Therefore,
Therefore,
there
there
are
are
two
two
vertices
vertices
A,
A,
B
B
V
V
S
S
and
and
there
there
is
is
an
an
are
edge
edge
two
connecting
vertices
A,
A
A
B
and
and
V
B.
B.
S
Since
Since
and
A,
A,
there
B
B
is
V
Van
S,
S,
ecient
way.
However,
this
sequence
is
dened
in
a
very
special
way,
in
the
sense
that
Fedg
is
n=1
However,
this
sequence
is
dened
in
a
very
special
way,
the
sense
that
F
is
dened
using
Lemma
Lemma
2.
2.
If
If
V
V
is
is
a
a
VERTEXCOVER
VERTEXCOVER
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
V
V
S
S
is
is
an
an
INDEPENDEN
INDEPENDEN
f
(n)
=
Any
consecutive
subsequence
of
F
with
length
multiples
of
three
can
be
par
Lemma
3.
of
equal
sum.
ltiples
of
three
can
be
partitioned
into
two
multisets
of
equal
sum.
aforementioned
recurrence.
Therefore,
we
should
inspect
the
recurrence
formula
more
closely.
Ninto
ch
h
that
that
for
for
every
every
edge,
edge,
at
at
least
least
one
one
of
of
its
its
endpoint
endpoint
is
is
in
in
the
subset.
subset.
MAXINDEPENDENTSET
MAXINDEPENDENTSET
is
is
a
a
algorithm
is
exponential
to
the
size
of
the
input,
the
algorithm
is
still
fast
enough
for
the
with
length
multiples
of
three
can
be
partitioned
two
multisets
of
equal
sum.
of
equal
sum.
t any
can
solve
is)(n
twice
the
of
N
using
O(2
)with
solution.
fA,
1)
+
frange
(n
2),
n
>
2AaSlength
into
two
multisets
of
equal
refore,
there
are
two
vertices
A,
B
and
there
issum.
an
edge
connecting
Ais
and
B.
Sinceby
A,F
Binto
V
This
S,
tion
ofhave
F (NA,
into
two
disjoint
multisets
and
such
that
the
sum
ofwhich
allclosely.
elements
we
we
have
B
B
/
/partitioned
S.
S.
As
As
A
A
and
and
B
are
are
connected
connected
we
by
by
have
an
an
edge,
edge,
A,formula
B
we
/we
S.
note
note
As
that
A
that
and
SSwe
B
iscan
not
not
are
adenote
connected
a partitioned
VERTEXCOVER.
VERTEXCOVER.
by
an
edge,
This
we isnote
is aa
Any
consecutive
subsequence
of
FB
length
multiples
of
three
be
two
multisets
Lemma
3.
consecutive
subsequence
of
F
with
multiples
of
three,
will
=
aforementioned
recurrence.
Therefore,
we
should
inspect
the
recurrence
formula
more
closely.
ed
recurrence.
Therefore,
we
should
inspect
the
recurrence
more
graph
graph
G(V,
G(V,
E)
E)
of
equal
sum.
cem
PARTITION
PARTITION
problem
istechnique
NPhard
reduction
from
SUBSETm
of
ofA,
nding
nding
aB
aproblem.
maximum
maximum
subset
subset
of
of
nodes
nodes
such
such
that
that
for
for
every
every
edge,
edge,
at
atF
most
most
one
one
of
ofisan
its
its
endpoint
endpoint
is
isthree,
in
inThiswhich
way
tois
apply
this
isby
when
the
value
of
NVERTEXCOVER.
not
too large
(e.g.
N
<
40).
F
note
Pick
any
consecutive
subsequence
of
F
with
length
multiples
of
three,
we
wiw
Proof.
Pick
any
consecutive
subsequence
of
with
length
multiples
of
which
we
Proof.
ave
B
/
S.
As
A
and
B
are
connected
by
an
edge,
we
that
S
is
not
a
is
a
l
elements
in
contradiction.
contradiction.
Therefore
Therefore
V
V
S
S
is
an
an
INDEPENDENTSET.
INDEPENDENTSET.
contradiction.
Therefore
V
S
is
INDEPENDENTSET.
of
equal
sum.
+{f1),
f (a + ,2),
...f
(b)}
for
some
a
< Pick
b.
We
can
Fof
into
Any
consecutive
subsequence
ofsubsequence
Fpartition
with
length
multiples
of
three
can
into
two multisets
Lemma
3.and
Pick
any
consecutive
subsequence
ofbeof
Fpartitioned
with
length
multiples
of thr
Proof.
Proof.
any
consecutive
subsequence
of
F
with
length
multiples
ofwe
three,
which
we
(n)}
we
dene
F
(N
)
to
be
the
rst
N
terms
of
F
.
We
want
to
know
Proof.
Pick
any
consecutive
with
length
multiples
three,
which
n=1
ge
value
of
N
,
it
is
unlikely
to
be
able
to
nd
an
algorithm
that
nds
A
and
B
in
an
Any
consecutive
subsequence
of
F
with
length
multiples
of
three
can
be
partitioned
Lemma
3.
Suppose
Suppose
we
we
already
already
know
know
that
that
MINVERTEXCOVER
MINVERTEXCOVER
is
is
a
a
NPhard
NPhard
problem.
problem.
Therefore,
Therefore,
we
we
can
can
show
show
ny consecutive
subsequence
of
F(a+
with
length
multiples
of
three
partitioned
into
multisets
algorithm
for
N+2),
=
36
is
unlikely
tocan
run
inb.
one
second,
wetwo
can,
use
awhich
O(2
Proof.
Proof.
The
The
proof
isis1),
actually
actually
similar
similar
to
to
the
the
previous
previous
lemma.
lemma.
Let
us
uspartition
assume
assume
that
that
Vinto
Vinstance,
SSof
isis not
not
aa INDEPE
INDEP
any
consecutive
subsequence
of
FLet
with
length
multiples
three,
Proof.
{f
fby
(a
1),
f{f
+
...f
(b)}
for
some
aabe
<
We
can
F
into
multiples
of
three,
which
we
will
by
F
=
{f
(a),
fproof
+
f(a
(a
2),
...f
(b)}
for
some
<
b.
We
can
Ffor
radiction.
Therefore
Vdisjoint
(a),
S
isthree,
an
INDEPENDENTSET.
denote
of
3.4
Finding
Special
Cases
F
with
length
multiples
of
which
we
will
denote
by
F
=
(aTheorem
+
1),
(a
+
2),
...f
(b)}
for
some
a
<SS
We
can
partition
into
=Pick
{f
(a),
ffin
(a
+
1),
ff(a
+
2),
...f
(b)}
for
some
apartition
<
b.b..isisWe
partition
FF F
into
F
will
denote
for
some
We
can
parti
on
of equal
F (N
)sum.
into
two
multisets
A
and
B
such
that
the
sum
of
allisE),
elements
N/2
b
a(a
2(a),
bE),
a
an
2We
any
consecutive
subsequence
of
F
with
length
multiples
of
three,
which
we
will
denote
by
=
Proof.
A
Theorem
Theorem
1.
1.
1.
If
If
S
S
V
V
is
is
a
MAXINDEPENDENTSET
MAXINDEPENDENTSET
of
of
graph
graph
If
S
G(V,
G(V,
V
a
MAXINDEPENDENTSET
then
then
V
V
a
a
MINVERTEXCOVER
MINVERTEXCOVER
of
graph
G(V
is
sequence
is
dened
in
a
very
special
way,
the
sense
that
F
is
dened
using
the
of
equal
sum.
Pick
NDEPENDENTSET
NDEPENDENTSET
is
is
also
also
a
a
NPhard
NPhard
problem
problem
by
by
reducing
reducing
a
a
MINVERTEXCOVER
MINVERTEXCOVER
problem
problem
into
into
a
a
algorithm
for
solving
a
problem
like
SUBSETSUM.
While
O(2
)
is
still
exponential
to
Therefore,
Therefore,
there
there
are
are
two
two
vertices
vertices
A,
A,
B
B
V
V
S
S
and
and
there
there
is
is
an
edge
edge
connecting
connecting
A
and
and
B.
B.
Since
Since
{f
(a),
f
+
1),
f
(a
+
2),
...f
(b)}
for
some
a
<
b.
can
partition
F
into
rtition
F can
into
ARTITION
problem.
PARTITION
from
SUBSETA
=
{f
(a +
3k),
0 into
k problem}isNPhard
{f (a + 1by
+ reduction
3k), 0 bkb
}
<
b.
We
partition
F
tion
into
2 2
elements
in
B
2so
a
b
2
N
N
3
3
{f
(a),
fIfPick
(a
+
1),
f
(a
+
2),
...f
(b)}
for
some
a
<
b.
We
can
partition
F
into
orem
1. graph
Swe
thus
Vproblem.
is
a
MAXINDEPENDENTSET
of
graph
G(V,
E),
then
V
S
is
a
MINVERTEXCOVER
of
of
the
the
graph
G(V,
G(V,
E).
E).
of
the
graph
G(V,
E).
any
consecutive
subsequence
of
F
with
length
multiples
of
three,
which
we
will
denote
by
F
=
Proof.
Therefore,
should
inspect
the
recurrence
formula
more
closely.
h
in
IOI,
and
is
the
main
focus
of
this
paper.
To
solve
IOI
2008
Island
PENDENTSET
PENDENTSET
problem.
b
2
b
2
b
O(2
),
and
the
range
of
N
that
it
can
solve
is
twice
the
range
of
N
using
a
O(2
)
we
we have
havetoA,
A,
B
Bable
/
/Fany
S.
S.
As
A
A=and
and
B
B(a
are
are
connected
connected
by
by
an
an
edge,
edge,
we
note
note
that
S+
isis1three,
not
not
a k+
VERTEXCOV
VERTEXCO
Alength
{f{f
(a
+
3k),
0+
k{f
}}we
(a
+that
11+
0+
}
=
+
3k),
0
{f
{f
(a
+
+S3k),
3k),
0
ak
valueconsecutive
of N , it is subsequence
unlikely
be
toAs
nd
an
algorithm
that
nds
A
and
B
in
an
Pick
consecutive
subsequence
of
Fwhich
with
length
multiples
of
which
we
wil
Proof.
A
=
(a
+
3k),
0
}
{f
(a
1
+
3k),
0
A
=
{f
(a
3k),
0
{f
(a
3k),
0
any
of
with
multiples
of
three,
we
will
denote
by
F
=
b
2
b
2
3
3
b
2
3
3
he
graph
G(V,
{f1(a),
fisapproach.
(a
+E).
1),
f
(a
+
2),
...f
(b)}
some
a}.
<sense
b.an
We
can
partition
F using
into3 the } {f
this
We
must
nd
afor
special
constraint
in 3k),
the
problem
such
use
a
2 3k),
b
ain
2
3 (a
A
=
{f
(a
+
0
+
1
+
3k),
0
contradiction.
contradiction.
Therefore
Therefore
V
V
S
S
is
is
an
INDEPENDENTSET.
INDEPENDENTSET.
a
+
+
0
k
}
B
=
{f
(a
+
2
+
3k),
0
sequence
dened
in
a
very
special
way,
the
that
F
is
dened
b
a
2
b
2
e Proof.
subsequence
of(b)}
F 1that
with
of
three
can
be
partitioned
two
{f
(a),
f0(a
(a
+
1),
f0(a
+
2),
(b)}
for
athat
<1into
b.
partition
F into
{f
(a
+
+ 3k),
kisproblem
}...f
1),
f (a +} We
2),
...f
for
some
a
<
We
can
partition
FWe
into
Proof.
Proof.
We
know
know
that
Vlength
V{f
S
S+multiples
is
ab.
a vertex
vertex
cover
by
by
lemma
lemma
know
1.
1.(a
The
The
only
only
thing
thing
that
a vertex
for
uslemma
to
to prove
prove
1. is
The
is its
itso
bVbWe
aS
acan
RTITION
problem.
PARTITION
isk cover
NPhard
by
reduction
from
SUBSET3is2
3
}3k),
some
{f
+
3k),
0multisets
remains
A
3k),
{f
b cover
a for
2}byus
b
2that
2remains
oblem
to be
solvable
in =
polynomial
time.
can
check
additional
rst
rst
prove
the
the
following
following
two
two
lemmas.
lemmas.
3 prove
3We
}.ka
B3B
=
(a
+
22+
0+
k+k+
}.k
=
{f
(a
+
+whether
3k),
0
an
3.4
Finding
Special
Cases
herefore,
we
should
inspect
the
recurrence
formula
more
closely.
3
3
b
a
2
b
2
}.
B
=
{f
(a
2
+
3k),
0
}.
B
=
{f
(a
+
2
3k),
0
of.
We
know
that
V
S
is
a
vertex
cover
by
lemma
1.
The
only
thing
that
remains
for
us
to
prove
is
its
b
2
V
V
S
S
is
is
not
not
minimum
minimum
vertex
vertex
cover.
cover.
Then,
Then,
V
there
there
S
is
is
is
another
another
not
minimum
vertex
vertex
cover
vertex
cover
V
V
cover.
S
S
where
Then,
where
minimality.
minimality.
Suppose
Suppose
minimality.
Suppose
3graph
alueb
of aN, 2it is unlikely
to{f
be1.
able
algorithm
that
nds
B
in
ank3G(V,
Theorem
Theorem
1.
Sto
isan
MAXINDEPENDENTSET
MAXINDEPENDENTSET
of
of
G(V,
E), 3then
then}VV
SS isisb a
a MINVE
MINVE
A as
=
(a
+
3k),
0VV2kis
kaaba2
}+22{f
02
E),
a2
b+A10and
a+
2a3graph
b 3k),
bIfIfS
nd
}.
B =b{f
(a
+(a
3k),
k
ll have
the
sum,
for
every
0a
{fsame
3(a
a3k),
isanother
}.
33k),
3 3k),
A
=
{f
+
0
{f
(a
+
1
+
0
k
A
=
(a
+
3k),
0
1
+
0
k
}
V
S
is
not
minimum
vertex
cover.
Then,
there
vertex
cover
V
S
where
mality.
Suppose
3
V
V
S
S


<
<
V
V
S,
S,
which
which
implies
implies
that
that
S
S


>
>
V
S.
S.
S
By
By

<
lemma
lemma
V
2,
2,
S,
S
S
which
is
an
an
implies
independent
independent
that
S
set.
set.

>
Therefore,
Therefore,
S.
By
lemma
S
S
is
is
not
not
2, S
aa}
If
If
S
S
V
V
is
is
an
an
INDEPENDENTSET
INDEPENDENTSET
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
V
V
S
S
is
is
a
a
VERTEXCOVER
VERTEXCOVER
of
of
the
the
quence
is
dened
in
a
very
special
way,
in
the
sense
that
F
is
dened
using
the
ba2
ba2
}.
B
=
{f
(a
+
2
+
3k),
0
of
of
the
the
graph
graph
G(V,
G(V,
E).
E).
This
ismultiples
the
suitable
approach
in
IOI,
and
thus
is =
the main ba2
focus of this paper.
ubsequence
of F of
with
length
multiples
of most
three
can
be
partitioned
into
two
multisets
3
3
3
B
will
have
the
same
sum,
as
for
every
0
Aand
and
B
will
have
the
same
sum,
as
for
every
0
ve subsequence
FA
with
length
of
three,
which
we
will
denote
by
F
ba2
3
3
will
as for
3
3 3 0 k
b
2
A
and
B
will
have
the
same
sum,
as
for
every
A
and
B
have
the
same
sum,
every
0
Smaximum
 < V
should
S,
which
that
S(a
>
lemma
2,
S
is
independent
isspecial
not a constr
maximum
independent
independent
set.
set.
This
This
a3k),
aacontradiction.
contradiction.
maximum
Therefore
Therefore
independent
VVan
this
S
S
isisapproach.
the
This
minimum
isset.
a ba2
contradiction.
vertex
vertex
cover.
V S
3 SaTherefore
3Therefore,
E)
E)
erefore,
weba2
the
formula
closely.
3k)
Bb.fimplies
=
{f
+
2 is
+
0S.
kBy
more
b set.
athe
2minimum
(a
+(a
3k)
+
+
1F
+
=
f (a
+sum,
2 }.
+
and
IOI
we
need
to 3k)
use
must cover.
nd
bfis
2Friend,
Arecurrence
and
B2014
will
have
the
same
as
for
every
0
k We
..f
(b)}
for
some
a2inspect
<
We
can
partition
into
3 thing
3
0
k
}.
B
=
{f
(a
+
2
+
3k),
0
ba2
}.
B
=
{f
(a
+
+
3k),
0
Proof.
Proof.
We
We
know
know
that
that
V
V
S
S
is
is
a
a
vertex
vertex
cover
cover
by
by
lemma
lemma
1.
1.
The
The
only
only
thing
that
that
remains
remains
for
for
us
us
imum
independent
set.
This
is
a
contradiction.
Therefore
V
S
is
the
minimum
vertex
cover.
3
A and B will have the same
sum,
asconstraint
for every allows
0k
fthe
+
fto
+
1f1+
+
3k)
=
+
+
3k)
f(a(aproblem
3k)
f(a(a
+solvable
+3k)
3k)
=ffpolynomial
f(a(a+
+12f2+
3k)
that
this
be
in
time.
We
can
3(a
3+3k)
fmultisets
(a
3k)
fif3k)
(a
2 +che
fthere
(a+
++
3k)
+
(a
1+
+
3k)
=
(a+
+MINVERTEXCO
+
From
Fromthat
the
the
theorem,
we
we
conclude
conclude
that
that
aaTherefore,
From
MINVERTEXCOVER
MINVERTEXCOVER
the
above
theorem,
can
can
we
be
be
conclude
easily
easily
constructed
that
a
we
we+have
have
a3k
a
bsequence
of
FofVabove
with
multiples
of 3Vthree
can
be
partitioned
into
two
us
us
assume
assume
that
Vabove
with
Slength
Satheorem,
isislength
not
not
aaSuppose
VERTEXCOVER.
VERTEXCOVER.
Therefore,
there
are
are
two
two
vertices
vertices
A,
A,
B
Bconstructed
/
/isVV
SS2=+ifvertex
subsequence
F
multiples
of
three,
which
we
will
denote
by
F
=
ba2
V
S
S
is
is
not
not
minimum
minimum
vertex
vertex
cover.
cover.
Then,
Then,
there
there
is
another
another
vertex
cover
cover
minimality.
minimality.
Suppose
b
2
b
2
(a + 1 + 3k) = f (a + 2 + 3k)
=
f (a
+
2B
+
3k)
A
and
will
have
the
same
sum,
as 1for
every
0kk 3 f (a}+ 3k) + fba2
f
(a
+
1
+
3k)
=
f
(a
+
2
+
3k)
a
+
3k),
0
k
{f
(a
+
+
3k),
0
ba2
vin
GUNAWAN
From
the
above
theorem,
we
conclude
that
a
MINVERTEXCOVER
can
be
easily
constructed
if
we
have
a
MAXINDEPENDENTSET.
MAXINDEPENDENTSET.
an
anMAXINDEPENDENTSET.
edge
edge
connecting
connecting
and
B.
B.
Since
Since
B
Binto
/3k)
/same
Vimplies
V+
fsum,
S,
S,
we
we
have
A,
A,
B
Bf
S.
S.
As
A
and
and
B
B is
are
are
connected
A
and
B
have
as
for3k)
every
0
+A
and
will
will
have
the
for
have
thesome
sameasum,
as
forcan
every
0 S,
kA,
the
fA,
(a
+
(athat
+as
1have
+
(aBy
+klemma
2As
3k)
(b)}
for
<V
b. A
We
partition
F
V
S
<
<
V
V
S,
which
which
that
S
S
3every
>
>=
S.
S.
By
lemma
2, SS
is
an
anconnected
independent
independent set.
set. Theref
Theref
3 S
32,
3implies
Jonathan
Irvin
Jonathan
IrvinGUNAWAN
GUNAWAN
XINDEPENDENTSET.
we
we note
note that
that SS maximum
ismaximum
is not
not
an
INDEPENDENTSET.
INDEPENDENTSET.
This
This
is
is
a
a
contradiction.
contradiction.
Therefore
Therefore
V
V
S
S
is
is
a
a
Jonathan
Irvin
GUNAWAN
Jonathan
Irvin
GUNAWAN
b an
a
2
f
(a
+
3k)
+
f
(a
+
1
+
3k)
=
f
(a
+
2
+
3k)
independent
independent
set.
set.
This
Thiswhich
isis aa contradiction.
contradiction.
Therefore
Therefore
SS isis the
the minimum
minimum vertex
vertex cover.
cover
V
ubsequence
of0
multiples
three,
we
denote
F
=V
bFkwith
af(a
2length
bthe
will
2 MINVERTEXCOVER
}.
a + 2In
+ the
3k),
Jonathan
Irvin
GUNAWAN
f(a
+
3k)
+ fof(athis
+by1section,
+ 3k)
=we
f (a
2NPhard
+we
3k)know
+
1ofassume
+
3k)
f
(a
+
2abeginning
+
3k)
Jonathan
Irvin
GUNAWAN
the
beginning
of
of
this
this
section,
section,
we
we
assume
we
In
know
know
that
that
assume
isis+
aa NPhard
problem.
problem.
that MINV
ItIt isis
OVER.
OVER.
+
3k),
0In
k beginning
}+
3k)
{f
(a f+(a1 +
+
0 =kwe
}MINVERTEXCOVER
3
3k),
Jonathan
Irvin
GUNAWAN
b)} for some a < b. 3We
canthe
partition
Ftheorem,
into we
3isisthat
From
From
the
above
above
theorem,
we conclude
conclude
that
aa MINVERTEXCOVER
MINVERTEXCOVER
can
can
be
be easily
easily
constructe
n the
beginning
of
this
section,
we
assume
wepossible.
know
that
MINVERTEXCOVER
is aencounter
NPhard
Itisconstructe
isnecessary
good
good
to
to know
know as
as many
many
NPhard
NPhard
problem
problem
as
as
possible.
good
to
This
This
know
necessary
necessary
as many
NPhard
so
so that
that ififproblem
we
we
encounter
as possible.
aaproblem.
new
new
This
problem
problem
X,
X, we
we
ba2
Jonathan
Irvin
GUNAWAN
b
2
me
sum,
as
for
every
0
If
If
S
S
V
V
is
is
a
a
VERTEXCOVER
VERTEXCOVER
of
of
graph
graph
G(V,
G(V,
E),
E),
then
then
V
V
S
S
is
is
an
an
INDEPENDENTSET
INDEPENDENTSET
of
of
the
the
MAXINDEPENDENTSET.
MAXINDEPENDENTSET.
3
by
the
construction
of
the
function.
dn to
many
problem
possible.
This
that if X,
we
encounter
a new
problem
X, we
bof
aNPhard
NPhard
2
bisreduce
necessary
a of
2itit the
Jonathan
Irvin as
GUNAWAN
can
can
use
useas
any
the
the
NPhard
problems
that
that we
we know,
know,
can use
reduce
any
to
tosoproblem
problem
NPhard
X,
problems
and
and thus
thusthat
prove
prove
wethat
that
know,
XX is
reduce
is also
also
NPhard.
it
NPhard.
to prob
}.problems
+
2GUNAWAN
+know
3k),
0any
kof
3k), 0 k
}3 {f (a + 1 + 3k), 0 k
}
E)
E)
use
any
of
the
NPhard
problems
that
we
know,
reduce
it
to
problem
X,
and
thus
prove
that
X
is
also
NPhard.
3
3
11We
1
f (a
3k)problem
+ f (aXX+isis1reducible
+ 3k) =to
(a + 2 Y
+
We
say
say+
that
that
problem
reducible
tofproblem
problem
Y 3k)We say that problem X is reducible to problem Y
the
the
beginning
beginning of
of this
this section,
section, we
we assume
assume we
we know
know that
that MINVERTEXCOVER
MINVERTEXCOVER isis aa NPhard
NPhard
In
a
2ba2
um, as
for everysimilar
0b
kIn
proof
proof
isisthat
actually
actually
to
to the
the
previous
lemma.
lemma.
Let
Let us
us assume
assume that
that VV
SS isis not
not aa INDEPENDENTSET.
INDEPENDENTSET.
We
X is reducible
to problem
Y
}.3previous
2 +say
3k),
0 problem
k similar
good
good3 to
to know
know as
as many
many NPhard
NPhard problem
problem as
as possible.
possible. This
This isis necessary
necessary so
so that
that ifif we
we encounter
encounter aa new
new
here
here are
two
vertices
vertices
A,
B
3k)
VV
SSfand
and+there
there
isis an
an edge
edge connecting
connecting A
A and
and B.
B. Since
Since A,
A,B
B VV
S,
S,
fare
(atwo
+ 3k)
+ fcan
(aA,
+
1Bany
+
=
(a
2 + problems
3k)
can
use
use
any
of
of
the
the
NPhard
NPhard
problems
that
that
we
we
know,
know,
reduce
reduce
it
it
to
to
problem
problem
X,
X,
and
and
thus
thus
prove
prove
that
that
XX ii
ba2
B
B
/
/as
S.
S.for
As
Asevery
A
A and
and
B
Bkare
are
connected
by
by an
an edge,
edge, we
we note
note that
that SS isis not
not aa VERTEXCOVER.
VERTEXCOVER. This
This isis aa
m,
0
connected
3
11We
We
say
that
that problem
problem XX isis reducible
reducible to
to problem
problem YY
n.
n. Therefore
Therefore VV
SS isis
an
ansay
INDEPENDENTSET.
INDEPENDENTSET.
ICPC
World
Finals
2010
Solutions
n.d.).
at problem.
we
use
tosolvable
nd
all
possible
paths
(ACM
to be
in
polynomial
time
using
the
reduction
ofgiven
the
original
problem
(withemadditional
constraint),
and
check
whether
the
proof
stillproof
holds
the
additional
constraint
to the problem.
onstraint),
and
check
whether
the
proof
still
holds
given
the
additional
constraint
toIfthe
re
that
we
can2
get
Accepted
by
only
"hacking"
a complete
search
algorithm.
Therefore,
we through
ollowing
formula
2
Identifying
Identifying
Intractability
Intractability
of
a
Problem
of
a
Problem
through
Reduction
Redu
is
impossible
to
visit
the
rest
of
the
unvisited
points,
then
we
can
prune
the
path
and
int), and check whether the proof still holds given the additional constraint to the problem.
causes ainproblem
to be solvable in polynomial time using the reduction proof of the original problem (withchnique
detail.
wever,
it
is
not
very
suitable
for
IOI.
Usually,
IOI
problems
require
deep
analysis
from
e one
will example
give
we one
ofwhether
a in
special
inproblem.
a NPhard
problem.
Suppose
we havewith
a function
with the
editional
of a example
special
case
a NPhard
Suppose
weadditional
have
a function
the problem.
constraint),
and
check
thecase
proof
still
holds
given
the
the
We
likewould
to
know
likeonly
that
to know
the problem
that
that
problem
we
are
that
attempting
we
are
attempting
unlikely
unlikely
havetoan
to
immediate
have an immediate
solution. solu
The
1,athe
n=
1is
n = constraint
2is to
at
weformula
canwould
getaWe
Accepted
by
"hacking"
complete
search
algorithm.
Therefore,
we
example
of
special case
in a NPhard
problem.
Suppose
we
have
a
function
with
the
ing
f (n) = Understanding Unsolvable Problem
93
most
common
most
common
way
is
to
way
apply
is
to
a
wellknown
apply
a
wellknown
technique
technique
called
reduction.
called
reduction.
Suppose
Suppose
we
know
we
that
know
problem
that
pro
X
i
Finding
Small
f (n 1) + f (n 2), n > 2
ue in detail.3.3by the
construction
of
theConstraints
function.
case
of
1
1
l give
we oneimpossible
example
asolve,
special
in
a know
NPhard
problem.
Suppose
we
have
ausing
function
with
the
impossible
to
solve,
to
and
we
also
and
know
we
also
that
we
can
that
solve
we
can
problem
solve
X
problem
by
using
X
problem
by
Y
problem
as
a
blackbox
Y
as
a
blackbox
.
If
we
can
.
by
the
construction
of
then function.
by
construction
of
the
bysequence
the
construction
of time
the
function.
function.
1,
1
=
2rst
1,
n
=dene
1then
solve
n F=
2n
) SUBSETSUM
algorithm
running
for
various
input
sizes.
This
the
We
consider
the
=
{f
, and
weX
(N
)=well.
to
bebe
the
ofimpossible
F
We impossible
want
to know
NPhard
with
large
Ncan
that
is
impossible
to
exponentially
(e.g.NY
Nterms
>
50).
Theorem
2.FIf
=
is(n)}
divisible
by
three,
can
partitioned
two
multisets
ormula
n=1
fwe
(n)
fthe
(n)function.
=
solveproblem
problem
Y,
problem
then
Y,
then
solve
we
can
problem
solve
problem
as
well.
X
Therefore,
as
Therefore,
problem
problem
isinto
also
is .also
to solve.
to solve
Theorem
2.
If
N
is
divisible
by
three,
then
F
(N
)
can
be
partitioned
into Y
two
multisets
of equal
sum.
nstruction
of solve
by
the
construction
of
the
function.
by
the
construction
of
the
function.
1,
n
=
1
n
=
2
3.3
Finding
Small
Constraints
f
N
on
a
MacBook
Pro
(Retina,
13inch,
Early
2015)
f
(n
1)
+
f
(n
2),
n
>
2
fpartition
(n
N
1)
+
fSUBSETSUM
(n
2),
n >algorithm
2then
hether
can
asum.
of
Fthat
(Nfunction.
)may
into
two
disjoint
A
suchproblem
that
the
sum
allpartitioned
elements
ofcreate
equal
also
lookwe
small
constraints
For
acan
SUBSETSUM
N
N/2
Theorem
2.example,
IfF
N
is)) can
divisible
by
then
F
(N
) canof
be
int
by
the
of
the
Theorem
2.
IfIf
by
three,
(N
be
partitioned
into
two
multisets
of
equal
f for
(n)
=
Theorem
2.
N
is
divisible
byhelp.
three,
then
Fmultisets
(N
beand
partitioned
into
two
multisets
of
equal sum.
sum.
omparison
ofother
O(2
)construction
and
O(2
) divisible
running
time
forBthree,
various
input
sizes.
This
is
by
construction
of
the
function.
fthe
(n
the
1)
+
felements
(n
2),
n
>
2
by
the
construction
of
the
function.
by
construction
of
the
function.
by
the
construction
of
the
function.
nrd
A
is
equal
to
the
sum
of
all
in
B
problem,
and
will
not
be
solvable
with
N
=
100.
When
we
are
given
the
constraint
that
Proof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
F
with
length
multiples
of
three.
By
lemm
2.
If
N
is
divisible
by
three,
then
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
1,
n
=
1
n
=
2
Theorem
2.
If
N
is
divisible
by
three,
then
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
by
the
construction
of
the
function.
Theorem
2.
Ifthen
N
isthe
divisible
by
three,
F>
(N
) problems
can
partitioned
into
two mult
is run
100
times
for
each
value
N, and
on
a(N
MacBook
13inch,
Early
2015)
nsider
the
F
=
we
dene
FPro
(N
)(Retina,
the
rst
terms
of
F
.be
We
want
totoknow
We=sequence
are
using
We
are
NPhard
using
problems
NPhard
problems
for
illustration.
for
Recall
Recall
NPhard
that
problems
NPhard
have
yet
to
have
be of
yet
solved
be
in polynomia
solved
in p
quence
F
{fProof.
(n)}
,N
and
we
dene
F three,
) to
to
beillustration.
rst
Nabe
terms
ofthen
FN
We
want
tomultiples
know
rd
problem
with
large
that
isof
impossible
solve
exponentially
(e.g.
50).
If
{f
is=(n)}
divisible
by
to
isthat
prefix
of
.N
with
length
n=1
fN
(n)
2 length
Proof.
Ifof
N(N
is))F
divisible
bybe
three,
then
Finto
(N multiples
)multiples
is amultisets
prex
F equal
with
length
Theorem
2. is
Ifdivisible
N
isn=1
divisible
by
three,
can
partitioned
two
of
sum.
Proof.
IfIf
by
three,
then
F
is
aa )prex
of
F
of
three.
By
Proof.
N
is[0,
divisible
by
three,
then
Fthen
(N
is(N
prex
of
F with
with
length
of of
three.
By lemma
lemm
the
array
are
small
(e.g.
100]),
this
problem
can
be
solved
using
O(N
X
)to
Dynamic
can
be
partitioned
into
two
multisets
equal
sum..
f
(n
1)
+
f
(n
2),
n
>
2
eer
F
=
{f
(n)}
,
and
we
dene
F
(N
)
to
be
the
rst
N
terms
of
F
.
We
want
know
polynomial
time
using
the
reduction
proof
of
the
original
problem
(withwe
can
create
a
partition
of
F
(N
)
into
two
disjoint
multisets
A
and
B
such
that
the
sum
of
all
elements
three.
By
lemma
3,
can
be
partitioned
into
two
multisets
of
equal
sum.
time
for
more
time
for
than
more
4
decades.
than
4
decades.
MINVERTEXCOVER
MINVERTEXCOVER
is
a
graph
is
problem
a
graph
that
problem
involves
that
nding
involves
a
nding
minimum
a
minimu
subse
ate
a
partition
of
F
(N
)
into
two
disjoint
multisets
A
and
B
such
that
the
sum
of
all
elements
ook
for
other
small
constraints
that
may
help.
For
example,
a
SUBSETSUM
problem
Theorem
If
N
divisible
bypartitioned
three,
then
(N
)be
can
be
partitioned
into
of equa
n=1
Theorem
2.can
IfF
N
is))F
by
three,
then
F
(N
)two
besum.
partitioned
Theorem
2.
N
is)divisible
divisible
by
three,
Fsum..
(N
can
be
partitioned
into
two
multisets
of three.
equal
sum
Theorem
2.
IfIfN
N
is
by
three,
then
(N
can
partitioned
into
two
multisets
of
equal
sum
Nfunction.
isthe
divisible
by
three,
then
F2.
(N
istwo
aisIfproblem.
prex
of
multiples
of
By
lemma
3,can
Fmultisets
(N
)of
Ifelements
is
then
F
(N
)problem
isdivisible
a prex
of
length
Byin
Theorem
2. be
IfProof.
N
isthe
divisible
bydivisible
three,
then
(N
)then
be
partitioned
into
two
multisets
of
equal
can
beFF
into
two
ofprex
equal
sum..
Proof.
Nby
isthree,
divisible
bylength
three,
then
Fmultisets
(N
)three.
isF
awith
of
F multiples
with
length
multiples
can
be
partitioned
into
multisets
of
equal
can
be
partitioned
into
two
multisets
ofwith
equal
sum..
looks
like
classic
PARTITION
PARTITION
isthe
NPhard
by
reduction
from
SUBSETX
isThis
upper
bound
of
inside
the
array.
Even
though
the
running
time
of
the
then
Fnodes
(N
)will
can
partitioned
into
two
multisets
of
equal
sum.
partition
ofthe
Fcan
(N
)aholds
into
two
disjoint
multisets
Athen
and
Bequal
such
that
the
sum
of
allin
elements
ther
the
proof
still
given
the
additional
constraint
to
the
problem.
s
equal
to
sum
of
all
elements
in
B
of
of
such
nodes
that
such
for
every
that
for
edge,
every
at
least
edge,
one
at
least
of
its
one
endpoint
of
its
endpoint
is
in
subset.
is
the
MAXINDEPENDENTSET
subset.
MAXINDEPENDENT
is a
e
sum
of
all
elements
in
B
oblem,
and
not
be
solvable
with
N
=
100.
When
we
are
given
the
constraint
that
Proof.
If
N
is
divisible
by
three,
F
(N
)
is
a
prex
of
F
with
length
multiples
of
three.
By
lemma
then
F
(N
)
be
partitioned
into
two
multisets
of
sum.
3.the
If
N
1 be
(mod
3),
F
(N
))to
bebeof
partitioned
into
two
multisets
of(withequal
sum.
er
the
F
=
{f
(n)}
,can
and
we
dene
Fusing
(N
to
be
the
rst
Nofconstraint.
terms
of
FAnother
. We
want
to
know
artitioned
intoofTheorem
two
ofalgorithm
equal
sum..
asequence
problem
toofmultisets
be
solvable
in
polynomial
time
the
reduction
proof
ofalgorithm
the
original
problem
nto
two
multisets
sum.
Theorem
3.
If
,three,
cannot
cannot
partitioned
into
two
multisets
of
can
be
partitioned
into
two
multisets
of
equal
sum..
into
two
multisets
equal
sum..
n=1
UM.
Therefore,
aequal
large
value
of
N
,ispartitioned
it
is
unlikely
be
able
to
an
that
nds
A
Bfunction.
inBy
anlengt
lauses
tothe
the
size
the
input,
still
fast
enough
for
the
given
sible
by
three,
then
F
(N
)100]),
can
be
partitioned
into
two
multisets
equal
sum.
Proof.
If
N
isthe
divisible
by
then
F
(N
)partitioned
isO(N
and
prex
of
F
with
length
multiples
of
three.
By
2
by
the
construction
the
Proof.
Ifnodes
N
is
divisible
by
three,
then
F
(N
)of
isbe
aone
prex
of
F
with
Proof.
N
is
divisible
by
three,
then
F
(N
is
aF
prex
of
F
with
length
multiples
ofand
three.
By
lemm
Proof.
IfIf
N
is
divisible
by
three,
then
F
(N
))of
is
a
prex
of
F
with
length
multiples
of
three.
lemm
by
the
construction
of
the
function.
by
construction
the
function.
by
construction
of
the
function.
of
all
elements
infor
B
graph
problem
graph
of
problem
nding
of
a
nding
maximum
a
maximum
subset
of
subset
such
nodes
that
such
for
every
that
for
edge,
every
at
most
edge,
at
most
of
its
one
endpoint
of
its
endp
is
in
Proof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
with
length
multiples
three.
By
lemma
3,
F
(N
array
are
small
(e.g.
[0,
this
problem
can
be
solved
using
X
)
Dynamic
Theorem
3.
If
N
1
(mod
3),
F
(N
)
cannot
partitioned
into
two
m
can
be
partitioned
into
two
multisets
of
equal
sum..
Theorem
3.
If
N
1
(mod
3),
F
(N
)
cannot
be
into
two
multisets
of
equal
sum.
the
construction
of
the
function.
Theorem
3.
If
N
1
(mod
3),
F
(N
)
cannot
be
partitioned
into
two
multisets
of
equal
sum.
ecient
aHowever,
partition
ofofFN
(N
into
two
disjoint
multisets
A and
Bexample,
the sum
all
elements
equal
sum.
Fcan
(N))create
isway.
a prex
prex
ofand
F check
with
length
multiples
ofstill
three.
By
lemma
3,
Fsuch
(N
)that
itional
constraint),
whether
the
proof
holds
given
the
additional
constraint
toNofFthe
problem.
this
sequence
is
dened
in
athat
very
special
way,
in
the
sense
that
is
dened
using
the
not
F (N
nique
is
when
the
value
is)inside
too
large
(e.g.
N
<
40).
For
while
O(2
)elements.
F
(N
is
a
of
F
with
length
multiples
of
three.
By
lemma
3,
)contains
can
be
partitioned
into
two
multisets
of
equal
sum..
n.
can
be
partitioned
into
two
multisets
of
equal
sum..
can
be
partitioned
into
two
multisets
of
equal
sum..
can
be
partitioned
into
two
multisets
of
equal
sum..
Proof.
Suppose
F
(N
)
=
F
(N
)
f
(1).
Note
that
F
(N
)
N
1
Since
N
1
(m
3.
If
N
1
(mod
3),
F
(N
)
cannot
be
partitioned
into
two
multisets
of
equal
sum.
l
case
in
a
NPhard
problem.
Suppose
we
have
a
function
with
the
th
multiples
of
three.
By
lemma
3,
F
(N
)
Theorem
3.
If
N
1
(mod
3),
F
(N
)
cannot
be
partitioned
into
two
multisets
of
equal
sum.
his
looks
like
a
classic
PARTITION
problem.
PARTITION
problem
is
NPhard
by
reduction
from
SUBSETthe
subset.
the
Suppose
subset.
we
Suppose
already
we
know
already
that
know
MINVERTEXCOVER
MINVERTEXCOVER
is
a
NPhard
is
a
NPhard
problem.
problem.
Therefore,
Therefore,
we
can
show
we
can
be
partitioned
into
two
multisets
of
equal
sum..
a
classic
PARTITION
problem.
PARTITION
problem
is
NPhard
by
reduction
from
SUBSEThe
upper
bound
of
the
elements
the
array.
Even
though
the
running
time
of
the
Theorem
3.
If
N
1
(mod
3),
F
(N
)
cannot
be
partitioned
into
two
multisets
of
e
yis
three,
then
F
(Nall
is
a3.
prex
of
F1 )can,
with
length
multiples
ofby
three.
By
lemma
3,
FNMiddle
(N
)1of
ual
to the
sum
of
elements
in
B
of
equal
sum..
three,
Fdivisible
Theorem
2.
Ifthen
Nsum.
is
by
three
N/2
=
Theorem
2.
If
N
istwo
divisible
by
three,
(N
) can
be
part
(N
Theorem
2.
If
N
is)divisible
divisible
by
three,
then
F(N
(N
)fis
can
be
partitioned
into
two
multisets
equal
sum.
Theorem
2.
If
N
divisible
then
F
(N
)two
can
be
partitioned
into
two
multise
Proof.
Suppose
F
(N
)
F
(N
)
f
(1).
Note
that
F
(N
)
contains
N
forementioned
recurrence.
Therefore,
we
should
inspect
recurrence
formula
more
closely.
Theorem
If
N
(mod
3),
F
(N
)
cannot
be
partitioned
into
multisets
of
equal
sum.
the
Proof.
Suppose
F
(N
=
F
(N
)
(1).
Note
that
F
(N
)
contains
elements.
Since
N
1
(m
unlikely
to
run
in
one
second,
we
for
instance,
use
a
O(2
)
Meet
In
The
Proof.
Suppose
F
(N
)
=
F
(N
)
f
(1).
Note
that
F
)
contains
N
1
elements.
Since
N
1
(m
heorem
2.
If
N
is
by
three,
then
F
)
can
be
partitioned
into
multisets
of
equal
f
equal
sum..
Proof.
Suppose
.
Note
that
contains
elements.
n.
haveN
0
(mod
3).
By
lemma
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
The
sic
PARTITION
problem.
PARTITION
problem
is
NPhard
by
reduction
from
SUBSETTherefore,
for
aoflarge
of3.NIfis,case
itstill
is
unlikely
to
be
able
to nd
an
algorithm
that
nds
Awith
and the
Bofin
an sum.
that
that
MAXINDEPENDENTSET
is
also
aNPhard
NPhard
is
also
aproblem.
NPhard
problem
by
problem
reducing
by
reducing
ahave
MINVERTEXCOVER
aB
MINVERTEXCOVER
problem
into
probla
or
asize
large
value
N
,sum..
itvalue
is
unlikely
be
able
to
nd
an
algorithm
that
nds
and
in multisets
an
he
ofMAXINDEPENDENTSET
the
input,
the
algorithm
fast
enough
the
given
constraint.
Another
one
wo
multisets
equal
(mod
3),into
Theorem
N
1two
(mod
3),
cannot
be
partitioned
into
two
equal
give
we
example
of
a1fSuppose
special
in
we
a)N
function
N
hree,
then
Fof
)Fcan
partitioned
multisets
sum.
Theorem
If)F
N
13).
FA
(N
cannot
be
partitioned
into
two
m
Theorem
3.
N
3),
13).
(mod
3),
F)F(N
(N
)F
cannot
be
partitioned
into
two
multisets
ofbe
equal
sum.
Theorem
3.
IfIfWhile
N
1to
3),
F
)for
cannot
be
partitioned
two
multisets
of
equal
sum.
3.
rtitioned
into
two
multisets
of
equal
sum.
of
uppose
Flike
(N
)(N
=
(N
)be
elements
Note
that
(N
contains
1be
elements.
Since
1)F)can
(mod
3),
we
Proof.
F
(N
)have
=
Fstill
(N
)sum.
(1).
Note
that
FA
(N
)elements
contains
1sum.
elements.
Since
N
Theorem
3.
If
N
(mod
F
(N
)aF
cannot
be
partitioned
into
two
multisets
equal
haveN
1F
(mod
By
lemma
3,
Ftwo
(N
be
partitioned
into
tw
Proof.
Suppose
(N
)f(N
=0)equal
(N
)Suppose
(1).
Note
that
Fof
(N
contains
N
1sum.
element
N/2
equal
problem
SUBSETSUM.
O(2
is
exponential
to
N
,fpartitioned
it
isof
much
faster
than
haveN
11sequence
0(1).
(mod
3).
By
lemma
3,
F
(N
can
into
multisets
of
equal
The
Since
,into
we
.(mod
By
lemma
3,
is(N
can
haveN
all
0not
(mod
By
lemma
3,
(N
)N
can
be
partitioned
into
two
multisets
of
sum.
The
Nin
sum
of
in
F
(N
)
is
even.
However,
the
sum
all
in
)
=
F
(N
)
+
f
(1),
wh
arge
value
of
N
,
it
is
unlikely
to
be
able
to
nd
an
algorithm
that
and
B
an
))ever,
cannot
be
partitioned
into
two
multisets
of
equal
too
nds
Proof.
If
N
divisible
by
three,
nt
way.
However,
this
is
dened
in
a
very
special
way,
in
the
sense
that
F
is
dened
using
the
MAXINDEPENDENTSET
MAXINDEPENDENTSET
problem.
problem.
this
sequence
is
dened
in
a
very
special
way,
in
the
sense
that
F
is
dened
using
the
is
when
the
value
of
N
is
large
(e.g.
N
<
40).
For
example,
while
O(2
)
Proof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
F(m
w
Proof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
F
with
length
multiples
of
three.
By
lemma
3,
F
(N
)then
Proof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
F
with
length
multiples
of
Any
consecutive
subsequence
of
F
with
length
multiples
of
three
can
be
partitioned
into
two
multisets
emma
3.
Proof.
Suppose
F
)
=
F
(N
)
f
(1).
Note
that
F
(N
)
contains
N
1
elements.
Since
N
1
(N
oof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
F
with
length
multiples
of
three.
By
lemma
3,
F
(N
)
cannot
be
partitioned
into
two
multisets
of
equal
sum.
oks
like
a
classic
PARTITION
problem.
PARTITION
problem
is
NPhard
by
reduction
from
SUBSEThree,
then
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
ormula
1ofN
03),
(mod
3).
By
lemma
3,
F
(N
)F
can
partitioned
into
two
of
equal
sum.
Therefore,
multisets
of
equal
sum.
haveN
1very
(mod
3).
By
lemma
3,equal
FTherefore,
(N
)multisets
can
be
into
two
equal
sum
of
all
elements
F
)F
is
even.
However,
the
sum
of
all
elements
haveN
multiples
1))way,
0using
(mod
3).
By
lemma
3,dened
(N
can
be
partitioned
into
multisets
partitioned
into
two
multisets
of
equal
sum.
the
sum
of
all
elements
in
twice
(N
partitioned
that
can
solve
is
the
range
of
N
aaformula
O(2
)partitioned
solution.
sum
of
all
elements
in
)be
is
However,
the
of
all
elements
in
(N
=
F
(N
)of
+
ff(1),
wh
in
the
0
sum
of
all
elements
in
F
(N
is
However,
the
sum
of
all
elements
in
F
(N
)multisets
=
F
(N
)contains
+Since
(1),
wh
we
(N
by
the
construction
the
function.
nSuppose
=
1
n
=
2special
mod
F
(N
cannot
be
partitioned
two
multisets
of
sum.
because
F
(N
)=
is
even
while
fsum
(1)
isinto
odd.
Therefore,
there
is
no
to
partition
F
(N
).
Proof.
Suppose
F
(N
=
F
(N
)(1).
(1).
Note
that
F
(N
))1can
contains
1)equal
elements.
N
this
sequence
dened
in
a
in
the
sense
that
Fsum
is
using
the
of
N/2
f
be
partitioned
into
two
multisets
mentioned
recurrence.
Therefore,
should
inspect
the
recurrence
formula
more
closely.
then
F
(N
)itaSuppose
is
ais
prex
of
F
with
length
three.
By
lemma
3,
F
(N
)way
Proof.
Suppose
F
(N
)F
=
F
)
felements.
(1).
Note
that
FN
)1two
Proof.
Suppose
F
(N
)of
=
F
(N
)even.
Note
that
(N
)(N
contains
N
1F
elements.
Since
N
The
(m
Proof.
F
(N
)into
=
(N
)even.
ffof
(1).
Note
that
F
(N
)into
contains
N
1N
elements.
Since
N
11N
(m
urrence.
Therefore,
we
should
inspect
the
recurrence
more
closely.
ikely
to
run
in)multiples
one
second,
we
can,
for
instance,
use
O(2
Meet
In
The
with
length
three.
By
lemma
3,
can
be
two
multisets
of
sum..
can
be
partitioned
into
two
equal
sum..
can
be
partitioned
two
of
equal
sum..
frefore,
equal
sum.
Proof.
F
(N
)all
F
(N
)unlikely
fF
(1).
Note
that
F
))an
contains
N
Since
(mod
w
haveN
1of
0multisets
(mod
3).
By
lemma
3,
F
(N
)(N
can
be
partitioned
into
two
of(N
equal
into
Middle
be
partitioned
two
multisets
of
equal
sum..
sum.3),
for
large
value
of
N
,elements
it
is
to
be
able
to
nd
algorithm
that
nds
Amultisets
and
B
in
an
elements
multisets
of
ln).
elements
in
F
)
is
even.
However,
the
sum
of
all
in
F
(N
)
=
F
(N
)
+
f
(1),
which
is
odd
1).
Note
that
F
(N
)
contains
N
1
elements.
Since
N
1
(mod
3),
we
sum
in
F
(N
)
is
even.
However,
the
sum
of
all
elements
in
)
=
F
(N
)
+
f
(p
is
even.
However,
the
sum
of
all
elements
in
,
which
is
because
F
(N
)
is
even
while
f
(1)
is
odd.
Therefore,
there
is
no
way
to
(N
sum
of
all
elements
in
F
(N
)
is
even.
However,
the
sum
of
all
elements
in
F
(N
)
=
because
F
(N
)
is
even
while
f
(1)
is
odd.
Therefore,
there
is
no
way
to
partition
F
(N
).
by
the
construction
of
the
function.
because
F
(N
)
is
even
while
f
(1)
is
odd.
Therefore,
there
is
no
way
to
partition
F
(N
).
more
N/2
Note
that
F
(N
)
contains
N
1
elements.
Since
N
1
(mod
3),
we
haveN
0
(mod
3).
By
lemma
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum
ce.
Therefore,
we
should
inspect
the
recurrence
formula
closely.
hen
F
(N
)
is
a
prex
of
F
with
length
multiples
of
three.
By
lemma
3,
F
(N
)
sets
of
equal
sum..
haveN
0
(mod
3).
By
lemma
3,
F
(N
)
can
be
partitioned
into
tw
haveN
0
(mod
3).
By
lemma
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
Th
We
will
rst
We
prove
will
rst
the
prove
following
the
following
two
lemmas.
two
lemmas.
haveN
0
(mod
3).
By
lemma
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
Th
em
SUBSETSUM.
O(2
) (N
is
still
tobe
Npartitioned
, nitthe
is
faster
than
n
1)
+
f (n
2),
nisWhile
>
213).is
F(N
1Theorem
elements.
Since
N
haveN
be
1this
0sequence
By
lemma
3,
Fexponential
(N
)(1)
can
be
partitioned
into
two
of
equal
sum.
Therefore,
th
(mod
sum
all
elements
F
)while
is
even.
However,
the
sum
of
all
elements
in to
F
(N
)two
=
F
) +). f3),
(1),F (N
wh
1,two
n
=
1to
=
2much
like
N
ay.
However,
dened
inwith
very
special
way,
in
sense
that
F
is
dened
using
the
Ifof
N
divisible
by
three,
then
F
(N
))multiples
can
two
multisets
equal
sum.
while
Any
subsequence
of
Fwe
length
of
three
can
partitioned
into
multisets
ma
3.
=
(N
)is)can
fconsecutive
(1).
Note
that
Finto
(N
)
contains
N
1
elements.
Since
N
1into
(mod
3),
we
Theorem
4.
If
2is
(mod
3).
F
(N
can
be
partitioned
into
two
multisets
of
equal
sum.
subsequence
of
F
with
length
of
can
be
partitioned
into
two
multisets
F
) Pick
even
while
f1(mod
is=
odd.
Therefore,
there
is
no
way
partition
F
(N
).
,nsecutive
(N
partitioned
multisets
of
equal
sum.
Therefore,
the
odd
because
in
is3),
even
length
is
odd.
Therefore,
there
is
no
way
partition
because
Fsubsequence
(N
)(N
even
f
is
odd.
there
ismultisets
no
way
to
partition
F
(N
Theorem
3.
Ifin
N
1)(N
(mod
because
Faof
(N
)be
is
even
while
fTherefore,
(1)
is
Therefore,
there
is
no
way
partition
F
Theorem
3.
If
N
1be
(mod
3),
Fwe
(N
)of
cannot
be
partitioned
i(
F
Theorem
3.
If2.
N
(mod
3),
F
)F
cannot
partitioned
into
two
multisets
of
equal
sum.
any
consecutive
with
multiples
of
three,
which
will
denote
by
F
=
roof.
odd.
to
multiples
multisets
N
Theorem
3.
If
N
1three
(mod
3),
F
(N
)the
cannot
be
partitioned
into
two
of
equ
f(1)
(n)
heorem
3.
Ifsolve
N
1
(mod
3),
F
(N
)
cannot
be
partitioned
into
two
multisets
of
equal
sum.
,ets
F of
(N
)can
can
be
partitioned
into
two
multisets
of
equal
sum.
Therefore,
the
3.4
Finding
Special
Cases
sum
all
elements
in
F
(N
)
is
even.
However,
sum
of
all
elements
F
(N
=
F
(N
)
+
f
equal
sum..
range
(N
of
sum
of
all
elements
in
F
(N
)
is
even.
However,
the
sum
of
all
elements
sum
of
all
elements
in
(N
)
is
even.
However,
the
sum
of
all
elements
in
F
(N
)
=
F
(N
)
+
f
(1),
w
sum
of
all
elements
in
F
(N
)
is
even.
However,
the
sum
of
all
elements
in
F
)
=
F
(N
)
+
f
(1),
w
that
it
is
twice
the
of
N
using
a
O(2
)
solution.
wo
multisets
of
equal
sum.
Therefore,
the
sum
of
all
elements
in
F
(N
)
is
even.
However,
the
sum
of
all
elements
in
F
(N
)
=
F
(N
)
+
f
(1),
which
is
od
Theorem
4.
If
know
2then
(mod
3).
F
(N
)
can
be
partitioned
intomultisets
twoofmult
because
F
(N
)Sinto
is
while
ff3).
(1)
is (N
odd.
Therefore,
there
no
way
tothen
partition
F is
(N
).sum.
F
Theorem
4.
If
N
22N
(mod
F
(N
)) +
can
be
partitioned
into
two
multisets
of
equal
Theorem
2.
If+
N
is
divisible
by
three,
Fis
(N
)closely.
can
be
partitioned
into
two
o(
Theorem
4.
If
N
(mod
3).
(N
can
be
partitioned
into
two
multisets
of
equal
sum.
recurrence.
Therefore,
we
should
inspect
the
recurrence
formula
more
E),
tive
subsequence
of
F
with
length
multiples
of
three
can
be
partitioned
into
two
multisets
feven
(n
1)
(n
n
>
2Nto
we
dene
Fsum
)of
be
the
rst
terms
of
F
We
want
ual
sum.
By
lemma
3,
Ff(N
(N
)to
can
be
partitioned
into
two
multisets
of
equal
sum.
Therefore,
the
.of
However,
the
all
elements
in
F
(N
)
=
F
)
f
(1),
which
is
odd
F
(N
)
cannot
be
partitioned
two
multisets
of
equal
sum.
Lemma
1.
Lemma
1.
If
S
V
If
is
an
INDEPENDENTSET
V
is
an
INDEPENDENTSET
of
graph
of
G(V,
graph
G(V,
then
E),
V
S
is
V
a
VERTEXCOVER
S
a
VERTEXCOV
the
dand
into
two
multisets
equal
sum.
.2),
foned
(a),
f
(a
+
1),
(a
+
2),
...f
(b)}
for
some
a
<
b.
We
can
partition
F
into
(N
sum
elements
in
F
(N
)4.
=
F
) B.
+
fSince
(1),
which
isof
odd
(N
because
F
(N
is(1).
even
while
f3).
(1)
is
odd.
Therefore,
is
no
way
to
partition
F=
(NFF
).
If=2N
by
then
F
(N
)Therefore,
is
a
prex
ofcan
F
with
length
multiples
of
three.
By
lemma
3,
is
there
Fway
F
(N
)contains
isSuppose
even
while
fiselements.
(1)
odd.
Therefore,
there
no
to
because
FF
(N
is
even
while
(1)
isto
odd.
Therefore,
there
no
way
to
partition
F
(N
).
because
F
(N
)f)which
is
even
while
fffbecause
(1)
is
odd.
Therefore,
there
way
to
partition
F
).
divisible
Proof.
(N
now
Proof.
Assign
(1)
A
and
(2)
fisbe
(1)
=
f
we
are
partition
(N
4.
If
N
(mod
3).
(N
))three,
can
be
partitioned
into
two
multisets
sum.
sHowever,
inProof.
F
(N
)the
F
(N
)Theorem
+
fno
(1),
is
odd
4.
If
N
2Note
(mod
F
(N
)(N
partitioned
into
multisets
equal
sum.
Proof.
Suppose
F
(N
)multisets
(N
)F
f) )(=
IOI,
because
F
(N
)of
is
while
f)to
(1)
is
odd.
there
to
partition
F
(N
).into
)3).
Theorem
Ifthat
N
2=
FN
(N
)equal
can
be
partitioned
two
of
equ
(N
)no
=
F
(N
)Since
(1).
Note
that
(N
) con
Suppose
F
(N
)all
=
F
(N
)
fall
F
(N
)paper.
N
1is
N
1of
(mod
3),
we
Proof.
Suppose
Fin
(N
)(N
F
(1).
Note
that
Ftwo
(N
)ftrying
contains
N
is13),
elements.
ble
approach
in
and
thus
is
main
focus
of
this
To
solve
IOI
2008
Island
nto
disjoint
multisets
A
and
B
such
that
the
sum
of
all
elements
oof.
Suppose
Fthere
(N
){f
=even
F
(N
fthe
(1).
Note
that
FFAssign
contains
F
1(2),
elements.
Since
N
1to
(mod
we
(N
)two
is
even.
However,
the
sum
of
elements
(N
))(mod
=
F
(N
)fno
+
fway
(1),
which
is
odd
FProof.
(N
)Therefore,
cannot
be
partitioned
into
two
multisets
of
equal
sum.
dd.
is
way
to
partition
F
(N
).
graph
G(V,
graph
E)
G(V,
E)
are no
we
denote
Proof.
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
f
(2),
Theorem
4.
If
N
2
(mod
3).
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
Any
consecutive
subsequence
of
F
with
length
multiples
of
three
can
be
partitioned
into
two
multisets
.onsecutive
r
the
sequence
F
=
(n)}
,
and
we
dene
to
be
the
rst
N
terms
of
F
.
We
want
to
know
Proof.
Assign
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
partition
F
(N
)
=
Theorem
4.
If
.
can
be
partitioned
multisets
of
equal
Proof.
If
N
is
divisible
by
three,
then
F
(N
)
is
a
prex
of
F
with
length
multiples
of
thre
dd.
Therefore,
there
is
no
way
to
partition
F
(N
).
Proof.
Assign
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
partition
F
(N
)
=
can
be
partitioned
into
two
multisets
of
equal
sum..
Pick
any
consecutive
subsequence
of
F
with
length
multiples
of
three,
which
we
will
by
F
=
n=1
subsequence
of
F
with
length
multiples
of
three,
which
we
denote
by
Fthe
bnd
aa2
23).
blemma
a 1obtain
2=
f(mod
(1)
3).
fapproach.
(2).
F
(N
)We
will
have
N
elements.
Since
N
2will
(mod
3),
we
N
0By
(mod
3).
partition
F
).
haveN
3,
0function.
3).
lemma
f (1).
Note
F
(N
) Since
contains
N
12
elements.
Since
Nlemma
1be
(mod
3),
we
by
the
construction
of
1
ontains
10that
elements.
(mod
3),
we
haveN
0partitioned
(mod
By
F(mod
(N
) 2equal
can
be
partition
1N
1
(mod
3).
By
3,1
F
(N
)can
can
be
partitioned
into
two
multisets
equal
sum.
Therefore,
the mu
3.4
Finding
Special
Cases
haveN
0to
(mod
By
3,
Fthe
(N
)3).
can
be
partitioned
into
two
multisets
of3
we
need
to
use
this
must
special
constraint
in
problem
such
BhaveN
veN
0(N
By
lemma
3,
F
(N
)(mod
be
partitioned
into
two
multisets
of
equal
sum.
Therefore,
the
hile
fTheorem
(1)
is
odd.
Therefore,
there
is
no
way
partition
F
(N
).
Theorem
4.
Ifpartitioned
N
3).
F
(N
)A
can
into
two
multisets
of
sum.
be
Theorem
4.
If
N
2B
(mod
3).
F
(N
)of
be
partitioned
into
two
Theorem
4.
Iflemma
NN
(mod
3).
F
(N
can
be
partitioned
into
two
multisets
of
equal
sum.
Theorem
4.
If
N
22
(mod
3).
F
(N
)})we
can
partitioned
into
two
multisets
of
equal
sum.
A
=
{f
(a
+
3k),
0
k
{f
(a
+
1
+
3k),
0
}
can
ssign
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
(2),
are
now
trying
to
partition
F
(N
)
=
F
(N
)
Proof.
Assign
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
partition
F
4.
If
N
2
(mod
3).
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
f
(1)
f
(2).
F
(N
)
will
have
N
2
elements.
Since
N
2
(mod
3),
we
Proof.
Assign
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
um.
can
create
a
partition
of
F
(N
)
into
two
disjoint
multisets
and
such
that
the
sum
of
all
elements
sum.
f
(1)
f
(2).
F
(N
)
will
have
N
2
elements.
Since
N
2
(mod
3),
we
obtain
N
0
(mod
3).
can
be
into
two
multisets
of
equal
sum..
f
(1)
f
(2).
F
(N
)
will
have
N
2
elements.
Since
N
2
(mod
3),
we
obtain
N
0
(mod
3).
utive
subsequence
FF
length
multiples
of
we
will
denote
by
F
with
even.
,aum
(a
+
1),
f(b)}
for
some
aHowever,
<
b.
We
can
partition
F
into
2),
...f
some
acontains
<
b.
We
can
partition
Fthree,
into
a which
3,+for
F2),
(N
) (N
can
be
partitioned
into
multisets
of
equal
which
our
theorem.
3two
3of
(1).
Note
Fof
(N
)(b)}
N
1
elements.
Since
N
1elements
(mod
3),
we
)ff+
can
be
partitioned
into
two
multisets
of
equal
sum.
sum
of
all
elements
inwhich
Fthe
)(N
is (N
ma
3,
F
(N
)(athat
can
be
partitioned
into
two
multisets
of
equal
Therefore,
the
Proof.
Proof.
Let
us
assume
Let
us
that
assume
V
that
S
is
not
S
athe
VERTEXCOVER.
is
not
VERTEXCOVER.
Therefore,
Therefore,
there
are
two
are
two
A,
vertices
B
/odd
V)even.
A,
BF
S
oned
two
multisets
of
equal
sum.
Therefore,
the
sum
of
in
F(N
(N
)implies
is
sum
of
ofinto
all
elements
in...f
(N
)fis
is
even.
the
sum
of
all
elements
in
F(N
)=
=
F (N
(N
)+
+fHowever,
fvertices
(1),
sum
all
elements
in
F
(N
)sum.
isall
However,
the
sum
all
elements
in(N
Fis
=
ows
problem
to
be
solvable
in
polynomial
time.
We
can
check
whether
additional
Proof.
Assign
(1)
and
fN
(2)
to
B.
Since
feven.
(1)
=
fsum,
(2),
we
are
now
trying
to
partition
F
)all
=
be
m
of
all
elements
F
even.
However,
sum
of
all
elements
in
F
F
)there
(1),
which
odd
)2).
can
partitioned
into
two
multisets
of
equal
of
Theorem
3.
If
N
1
(mod
3),
FA
(N
)V
cannot
be
partitioned
into
two
multisets
of
equal
sum.
sum.
in
F
Fthe
(N
)for
will
have
N
2)We
elements.
Since
2N
(mod
3),
we
obtain
Ninto
which
2an
0multisets
(mod
3).
By
lemma
ultisets
of
equal
sum.
pproach
IOI,
and
thus
is
the
main
focus
of
this
paper.
To
solve
IOI
2008
Island
fbe
(1)
fAssign
(2).
Fto
(N
)two
will
have
equal
2to
elements.
Since
N
2)
(mod
3),
we
obtain
N
iswhich
2obtain
0F
(mo
Theorem
2.
If
N
is
divisible
by
three,
then
(N
)
3,
F
(N
)
can
be
partitioned
two
of
equal
sum,
f
(1)
f
(2).
(N
)
have
N
2
elements.
Since
N
2
(mod
3),
we
N
al
to
the
sum
of
all
elements
in
B
in
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
implies
our
theorem.
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
implies
theorem.
our
will
impl
2
),
...f
(b)}
some
a
<
b.
can
partition
F
into
mod
3).
F
(N
)
can
partitioned
into
multisets
of
equal
sum.
Proof.
f
(1)
to
A
and
f
(2)
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
partition
ma
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
sum.
Therefore,
the
because
F
(N
)
is
even
while
f
(1)
is
ven.
However,
sum
of
all
in
F
(N
)Since
F
(N
)B
+
fno
(1),
which
is
odd
Assign
fno
to
A
and
to
Since
fby
(1)
=
f
(2),
weF
are
Proof.
Assign
f)a2elements
(1)
A0with
and
fis
(2)
to
Since
(1)
=
(2),
we
are
now
trying
to
partition
F
(N
)no
and
is
an
there
edge
isF
connecting
an
connecting
A
and
B.
A
Since
and
A,
/(1)
VF
A,
B
S,
/
we
V
have
S,
A,
we
B
S.
A,
As
Bnotwo
A
S.
and
As
B
A
are
connected
B
are
cs
Proof.
Assign
f(N
(1)
to
A
and
f
(2)
to
B.
Since
ffway
(1)
ffpartition
(2),
we
are
now
trying
to
(N
all
elements
in
Fthe
(N
)problem
=
(N
+
(1),
odd
because
(N
)=
is
even
while
fB.
(1)
is
odd.
Therefore,
there
is(N
Proof.
Assign
f23k),
to
and
(mod
to
. 3),
Since
,(2)
we
are
now
trying
to
because
Fthere
(N
iseven
even
while
fisedge
(1)
is
odd.
Therefore,
there
to
F
(N
).
because
F
(N
)Proof.
even
while
f
(1)
is
odd.
Therefore,
there
is
way
to
partition
F
kcause
any
consecutive
subsequence
length
multiples
of
three,
which
will
F
=
Proof.
Assign
f3,
to
A
and
ftoF
(2)
to
B.
fB.
(1)
=
f(N
(2),
we
are
now
trying
to
partition
Fpartition
(N
=
F
(N
))n
f)is
(1)
f(1)
(2).
F
)isof
will
N
2=
elements.
Since
N
2whether
(mod
3),
we
obtain
N
2theorem.
0)and
(mod
3).
bwhich
2sum,
bwe
ahave
2denote
blem.
PARTITION
NPhard
by
reduction
from
SUBSET is
}.
B
=
{f
(a
+
+
k
F
(N
)and
while
f
(1)
odd.
Therefore,
there
is
way
to
partition
F
(N
).
b
2
Theorem
3.
If
N
1
F
)
cannot
be
partitioned
into
multisets
of
equal
two
have
Therefore,
solving
this
problem
is
reduced
to
checking
N
1
(mod
3).
We
can
solve
this
can
be
partitioned
into
multisets
of
equal
which
implies
our
theorem.
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
partition
F
(N
)
=
F
(N
)
eed
to
use
this
approach.
We
must
nd
a
special
constraint
in
the
problem
such
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
implies
our
k
F
)San
can
be
partitioned
into
two
multisets
equal
sum,
which
implies
our
theo
are
(a
+
Aby
{f
(a
0note
}+
{f
+
1f(N
+
3k),
0This
}contradiction.
3felements.
A
{f
(a
+
3k),
0we
}<
(N
{f
(a
+
1
3k),
}
3k),
B.
Since
(1)
=
(2),
we
now
trying
tofNote
partition
(N
)(1),
F
)
F
(N
)an
=
F
(N
)f)partition
felements.
fpartition
(2).
F0F
(N
)
will
have
N
2a1
elements.
Since
N
22
(mod
3),
we
sum
of
all
elements
in
F
(N
)
=
F
(N
)
+
which
isk22Ifis
odd
Proof.
Suppose
F
)will
=be
F
(N
)N
(1).
contains
elements.
Since
12whether
(mod
3),
we
there
f
)ven.
is=
odd.
Therefore,
is
no
way
to
F
).
(2).
F
)equal
will
have
N
2of
elements.
N
23).
(mod
3),
f=
(1)
(2).
F
(N
will
have
N(1)
2that
Since
N
(mod
3),
we
obtain
N(mod
then
(mod
3).
by
an
edge,
an
edge,
we
that
that
S3,
not
is
INDEPENDENTSET.
not
an
INDEPENDENTSET.
This
contradiction.
is
Therefore
Therefore
Slemm
is
Vowa1
partition
.
into
will
reduced
Since
fthe
(1)
ff(N
(2).
F
(N
))kis
will
have
N
2(N
elements.
Since
N
(mod
3),
obtain
00V
(mod
3).
no
way
to
partition
Fknote
(N
).
1),
f(2)
(a
2),
...f
(b)}
some
a
b.
We
can
F
now
trying
to
partition
F
(N
=
F
(N
Proof.
N
is
divisible
by
three,
F
(N
)N
is
a(N
b2(N
2)3),
bto
a=
2(N
fHowever,
f+
fto
(2).
F
)fafor
have
2
Since
2in
(mod
3),
we
obtain
N
2Since
0N
By
whether
Therefore,
solving
this
problem
to
checking
3,
F
(N
)
can
partitioned
into
two
multisets
of
sum,
implies
our
theorem.
s+
unlikely
to
be
able
to
nd
that
nds
A
and
B
an
Therefore,
solving
this
problem
is
reduced
checking
N
1a
(mod
3).
We
can
solve
this
3(1)
3elements.
Therefore,
solving
this
problem
is
reduced
to
checking
whether
N
)we
1sum.
(mod
3).
We
can
solve
this
3more
3have
and
f(1)
to
B.
Since
(1)
=
falgorithm
(2),
we
are
now
trying
toN
partition
F
(N
)which
=
Fequal
(N
We
will
provide
examples
of
special
cases
in
the
following
section.
lements.
Since
N
(mod
we
obtain
N
0
(mod
3).
By
lemma
he
problem
be
solvable
in
polynomial
time.
We
can
check
whether
an
additional
Theorem
4.
If
N
2
(mod
3).
F
Theorem
4.
If
N
2
(mod
3).
F
(N
)
can
be
partitioned
into
oks
like
a
classic
PARTITION
problem.
PARTITION
problem
is
NPhard
by
reduction
from
SUBSETTheorem
4.
If
2
(mod
3).
F
(N
)
can
be
partitioned
into
two
multisets
of
f
(a
+
3k),
0
{f
(a
+
1
+
3k),
0
}
Theorem
4.
If
N
2
(mod
3).
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
ba2
heorem
4.
If
N
2
(mod
3).
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
Proof.
Suppose
(N
)
=
F
(N
)
f
(1).
Note
that
F
(N
)
contains
N
1
elements.
Sin
ements.
Since
N
2
(mod
3),
we
obtain
N
0
(mod
3).
lemma
(mod
3).
By
lemma
3,
F
can
be
partitioned
into
sum,
which
implies
is
odd.
Therefore,
there
is
no
way
to
partition
(N
).
haveN
0
(mod
3).
By
lemma
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum.
Therefore,
the
,
we
obtain
.
By
lemma
3,
can
be
parti
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
imp
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
implies
our
theorem.
VERTEXCOVER.
VERTEXCOVER.
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
implies
our
theorem.
bWe
2provide
fore,
solving
this
problem
is sum,
reduced
to2two
checking
whether
N
13the
(mod
3).
We
can
solve
this
in
O(1).
bthe
we
obtain
N
2
0 provide
(mod
3).
Byas
lemma
Therefore,
this
problem
is
checking
whether
N
(mod
We
can solv
A
and
BF
have
the
same
for
every
0we
kdened
can
be
partitioned
into
two
multisets
sum
3,
(N
)We
can
be
partitioned
into
multisets
ofsum.
equal
sum,
which
implies
our
theorem.
will
more
examples
of
special
cases
in1 the
following
section.
Therefore,
solving
this
problem
is
reduced
to
checking
whether
N3).of
1 equal
(mod
3).o
3 into
ned
in
awill
very
special
way,
in
that
F
is
using
the
will
more
examples
of
special
cases
in
following
section.
We
will
more
examples
of
special
cases
the
following
section.
WAN
3nd
have
N
2abe
Since
N,3k),
20asolving
(mod
3),
obtain
Nreduced
2inchecking
0to
(mod
3).
By
lemma
multisets
of
equal
sum,
which
implies
our
theorem.
F=
(N
) for
can
partitioned
two
multisets
equal
bsense
2(mod
bcan
abe
N
2
}.
B
=
{f
(a
+
+
kaof}.
nto
two
multisets
of
equal
sum.
refore,
large
value
oftwo
N
it
isis
unlikely
toof
be
able
to
an
algorithm
that
nds
AF
and
B
in
anmultisets
B
{f
(a
+
2elements.
+
3k),
0provide
k2F
solving
into
Therefore,
this
problem
is
reduced
to
whether
1
(mod
3).
We
can
solve
this
haveN
1
0
3).
By
lemma
3,
F
(N
)
partitioned
two
of
equ
tioned
into
multisets
equal
sum,
which
implies
our
theorem.
multisets
of
equal
sum,
which
implies
our
theorem.
sum
of
all
elements
in
(N
)
even.
However,
the
sum
of
all
elements
in
F
(N
)
=
(N
)
+
f
(1),
which
is
odd
bspecial
a kf
2 3to
Atheorem.
=examples
{f
(arecurrence
+We
0
cases
}following
{f
(a
+
1and
3k),
0 are
kB.
Since
}section.
rovide
more
of
in provide
the
section.
plies
will
provide
more
examples
of
special
cases
innow
the
following
Proof.
Assign
fF(mod
(1)
to
AF
and
to
We
will
more
examples
of
special
cases
in
the
following
section.
Proof.
Assign
fG(V,
(1)
to
A
and
f=
(2)
to
Since
fwhether
(1)
=
fof
(2),
inspect
the
formula
more
closely.
Proof.
Assign
f0(1)
to3k),
A
and
(2)
B.
Since
fspecial
(1)
=
f+
(2),
we
now
trying
to
partition
(N
)We
=
F(N
(N)solve
)f(2)
Proof.
Assign
fproblem
(1)
to
A
fwe
(2)
to
fF
(1)
f1INDEPENDENTSET
(2),
we
are
trying
to
oof.
Assign
(1)
to
A
and
fsolving
(2)
to
B.
Since
f3(a
(1)
=
fcases
(2),
are
trying
to
partition
F
(N
).the
=now
ned
into
two
ofTherefore,
equal
sum,
which
implies
our
theorem.
solving
this
isway,
reduced
to
checking
whether
N
1B.
3).
We
can
solv
F
(NHowever,
)our
can
befmultisets
partitioned
into
two
multisets
ofof
equal
sum.
}.
fould
(a
+
2
+
3k),
Therefore,
solving
this
problem
is
reduced
to
checking
N
p
Therefore,
solving
this
problem
is
reduced
to
checking
whether
N
(mod
3).
can
solve
thi
Lemma
2.
Lemma
2.
If
S
V
If
is
S
a
VERTEXCOVER
V
is
a
VERTEXCOVER
of
graph
of
G(V,
graph
E),
then
E),
V
then
S
is
V
an
S
is
an
INDEPENDENTSE
the
Therefore,
solving
this
problem
is
to
checking
whether
N
1
(mod
3).
We
can
3
3
reduced
this
ay.
sequence
is
dened
in
a
very
in
the
sense
that
dened
using
this
Theorem
3.
If
N
1
(mod
3),
F
(N
)
cannot
be
Therefore,
solving
this
problem
is
reduced
to
checking
whether
N
1
(mod
3).
We
can
solve
this
in
O(1).
f
(a
+
3k)
+
f
+
1
+
3k)
=
f
(a
+
2
+
3k)
We
will
provide
more
examples
special
in
the
following
section.
Therefore,
this
problem
is
reduced
to
checking
whether
sum
of
all
elements
in
F
(N
)
is
even.
However,
the
sum
of
all
elements
in
F
(N
)
=
F
(N
because
F
(N
)
is
even
while
f
(1)
is
odd.
Therefore,
there
is
no
way
to
partition
F
(N
).
(mod
Fof
3
educed
to
checking
whether
N
1
3).
We
can
solve
this
in
O(1).
f
(1)
f
(2).
F
(N
)
will
have
N
2
e
2)
to
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
partition
F
(N
)
=
(N
)
4
Some
example
special
cases
),
we
are
now
trying
to
partition
F
(N
)
=
F
(N
)
ba2
f
(1)
f
(2).
F
(N
)
will
have
2
elements.
Since
N
2
(m
foned
(1)
f
(2).
F
(N
)
will
have
N
2
elements.
Since
N
2
(mod
3),
we
obtain
N
0
(mod
3).
By
lemma
ba2
f
(1)
f
(2).
(N
)
will
have
N
2
elements.
Since
N
(mod
3),
we
obtain
N
2
1)
f
(2).
F
(N
)
will
have
N
2
elements.
Since
N
2
(mod
3),
we
obtain
N
0
(mod
3).
By
lemma
educed
to
checking
whether
N
1
(mod
3).
We
can
solve
this
in
O(1).
B
will
have
the
same
sum,
as
for
every
0
We
will
more
examples
ofin
special
cases
insection.
the
following
section.
the
same
sum,
as
for
every
0provide
kcan
We
will
provide
more
examples
of
special
cases
in the
following
section.
We
provide
more
examples
of
special
cases
in the
the
following
section.
graph
G(V,
graph
E)
G(V,
E)
We
will
provide
examples
of
special
cases
in
following
section.
inspect
recurrence.
Therefore,
we0more
should
the
recurrence
formula
more
closely.
with
length
multiples
of
three
be
into
two
multisets
sF
1
(mod
3).
We
can
solve
this
in
O(1).
3
We
can
solve
this
in
.
We
will
provide
more
examples
of
special
cases
the
following
3partitioned
odd.
because
F
(N
)
is
even
while
f
(1)
is
Therefore,
there
is
no
way
to
partition
F
(N
).
4
Some
example
of
specia
4
Some
example
of
special
cases
4
Some
example
of
special
cases
}.
B
=
{f
(a
+
2
+
3k),
problem
is
reduced
to
checking
whether
N
1
(mod
3).
We
can
solve
this
in
O(1).
)ial
B.)3),
Since
fpartitioned
(1)
=
(2),
we
are
now
trying
to
partition
Fwhich
(N
)Proof.
=
Fpartitioned
(N
)our
of
ial
cases
in
the
following
3,theorem.
Finto
)two
be(N
partitioned
into
two
2FTheorem
elements.
Since
2section.
(mod
3),(N
we
obtain
N
23,sum,
sum,
(mod
3).
By
lemma
(mod
wethe
obtain
N
03,ba2
(mod
3).
lemma
F0 (N
)into
be
equal
sum,
w
3,
(N
)can
can
be
partitioned
into
two
of
equal
implies
F
)(N
can
be
partitioned
into
two
multisets
equal
sum,
which
our
theore
Suppose
F(N
(N
)can
=multisets
F
) implies
of
f (1).
Note
tha
3can
ame
sum,
as
for
every
0f
k
Fto
(N
be
into
two
multisets
of
equal
which
implies
our
theorem.
cases
in
following
4.
If
NN
2section.
(mod
3).
Fmultisets
)By
be
two
multisets
of
equal
sum.
3 common
We
will
provide
more
examples
ofpartitioned
special
cases
in
the
following
section.
4
Some
example
of
special
cases
4theorem.
Some
example
of
special
cases
4three
Some
example
of
special
We
will
look
atfwhich
some
examples
of=
special
cases
that
may
occur
inistwo
competitive
programming
p
mples
ofimplies
special
cases
in
the
following
section.
Irvin
GUNAWAN
case
,onathan
2 elements.
Since
N
2proof
(mod
3),
we
obtain
N
0
(mod
3).
By
lemma
Any
consecutive
subsequence
of
F
with
length
multiples
of
can
be
partitioned
into
multisets
3k)
+
f
(a
+
1
+
3k)
f
(a
+
2
+
3k)
two
multisets
offour
equal
sum,
implies
our
Proof.
Proof.
The
proof
is
actually
is
similar
actually
to
similar
the
previous
to
the
lemma.
previous
Let
lemma.
us
assume
Let
us
that
assume
V
S
that
not
V
a
S
INDEPENDENTSET
is
not
a
INDEPEND
(a
+The
3k)
+
(a
+
1
+
3k)
=
f
(a
2
+
3k)
which
theorem.
haveN
partitioned
1special
occur
0occur
(mod
3).
By
lemma
3,of
Fequal
(Noccur
) sum
can
Theorem
4.
2checking
(mod
3).
F (Ncases
)common
can
be
into
two
multisets
4Ifk NWe
Some
example
of
cases
ba2
will
look
at
some
examples
of
special
cases
that
may
We
will
look
at
some
common
examples
of
special
that
may
in
competitive
programming
p
We
will
look
at
some
common
examples
of
special
cases
that
may
in
competitive
programming
p
Therefore,
solving
this
problem
is
Therefore,
solving
this
problem
is
reduced
to
checking
whet
Therefore,
solving
this
problem
is
reduced
to
whether
N
1
(mod
3).
We
can
solve
this
in
O(1).
will
have
the
same
sum,
as
for
every
0
Therefore,
solving
this
problem
is
reduced
to
checking
whether
N
1
(mod
3).
W
this
problem
is
reduced
toV
checking
14
(mod
3). We
can
this
inB.
solve
3
flength
(asolving
+there
3k)
+are
fto
(a
+of
1vertices
+
3k)
=
(a
24
+BS
3k)
two
multisets
of
equal
sum,
which
implies
our
theorem.
Assign
f (1)
A
and
ftwo
(2)
tofB
B.
Since
fdenote
(1)
= Sfby(2),
we
are
now
trying
to
partition
Feven.
(N
)O(1).
=
Fspeci
)
m.
Therefore,
Therefore,
there
two
are
A,
vertices
+
A,
and
V whether
there
and
is
an
there
edge
connecting
anSome
edge
connecting
Ain
and
B.A
Since
and
A,
B
Since
(N
VA,
BS
Some
example
of
special
cases
example
of
4
Some
example
of
special
cases
f Therefore,
FProof.
with
multiples
three,
which
we
will
FinN
=
sum
ofis
all
elements
F
(N
)competitive
is
However,
4ofWe
Some
example
of
special
cases
ook
at
some
common
examples
special
cases
that
may
occur
competitive
programming
problems.
will
look
atN
some
common
examples
ofprovide
special
cases
that
may
occur
in
will
look
at
some
common
examples
of
special
cases
that
may
occur
in programm
competit
We
will
provide
more
examples
ofparti
speth
m
is
reduced
to(mod
checking
whether
1cases
(mod
3).
We
can
solve
this
in3),
O(1).
me
example
of
special
cases
hether
N
1
3).
We
can
solve
this
in
O(1).
We
will
more
examples
of
special
cases
in
the
following
We
will
provide
more
examples
of
special
cases
in
the
following
section.
We
We
will
provide
more
examples
of
special
cases
in
the
following
section.
e
will
provide
more
examples
of
special
in
the
following
section.
Proof.
Assign
f
(1)
to
A
and
f
(2)
to
B.
Since
f
(1)
=
f
(2),
we
are
now
trying
to
f
(1)
f
(2).
F
(N
)
will
have
N
2
elements.
Since
N
2
(mod
we
obtain
N
0
(mod
3).
By
lemma
me
cases
wecases
have
A,
we
BSome
have
/of
S.
A,
B
/+some
S.
and
As
A
and
connected
byof
an
edge,
by+Planar
an
we
edge,
note
that
weF
note
S occur
is
that
aS VERTEXCOVER.
iswhile
not fa(1)
VERTEXCOVER.
ispa
4.1
graphs
aial
< example
b.
We
can
partition
Fspecial
into
We
will
look
common
special
cases
that
may
in
competitive
programming
because
(N
)will
isnot
even
odd. This
Therefo
Irvin
GUNAWAN
Example
ofB
Special
Cases
fAs
(aatA
3k)
+
fare
(a
+ length
1Bexamples
+are
3k)connected
=
fcan
(a
+solve
2of
3k)
khan
any
consecutive
subsequence
of
Fsome
with
multiples
three,
we
denote
bycompetitive
F =isthat
mNAWAN
is4
reduced
to4.
checking
whether
N
1 F(mod
3).
We
this
inwhich
O(1).
Some
example
of
special
cases
special
in
the
following
section.
ng
section.
cases
4.1
Planar
graphs
4.1
Planar
graphs
We
will
look
at
common
examples
of
special
cases
that
may
occur
in
programm
4.1
Planar
graphs
We
will
look
at
some
common
examples
of
special
cases
may
occur
We
will
look
at
some
common
examples
of
special
cases
that
may
occur
in
competitive
programming
We
will
look
at
some
common
examples
of
special
cases
that
may
occur
in
competitive
programming
f
(1)
f
(2).
(N
)
will
have
N
2
elements.
Since
N
2
(mod
3),
we
obtain
N
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
implies
our
theorem.
contradiction.
contradiction.
Therefore
Therefore
V
S
is
V
an
INDEPENDENTSET.
S
is
an
INDEPENDENTSET.
We
will
look
at
some
common
examples
of
special
cases
that
may
occur
in
competitive
programming
problems.
AN
es
ofaspecial
special
cases
that
maysome
occur
in
competitive
programming
problems.
+
1),
f(a
...f
(b)}
for
a in
< competitive
b.that
We
F ainto
b
2+ 2),
bPlanar
acan
be
2partition
Planar
graph
a (N
graph
drawn
on
at
surface
without
having
twographs
edges
o
special
cases
in
thethat
following
4.1
graphs
4.1
Planar
4.1
Planar
es
of
cases
may
programming
problems.
Theorem
4.
Ifgraphs
N
2which
(mod
3). Fcrossing
(N
) theorem.
caneach
be pa
3,isoccur
Fsection.
) can
be can
partitioned
into
two
multisets
of
equal
sum,
implies
our
r
in
competitive
programming
problems.
}
{f
(a
+
1
+
3k),
0
}
Planar
graph
is
aof
graph
that
can
be
drawn
on
ais can
at
surface
without
havi
4
Som
Planar
graph
is
aaproblem
graph
that
can
be
drawn
on
aaspecial
at
surface
without
having
two
edges
crossing
each
ot
4
Some
example
of
Planar
graph
is
graph
that
can
be
drawn
on
at
surface
without
having
two
edges
crossing
each
ot
4.1
Planar
graphs
4
Some
example
of
special
cases
mmon
examples
of
special
cases
that
may
occur
in
competitive
programming
problems.
4
Some
example
of
special
cases
et
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
if
the
graph
is
planar.
We
will
prov
Therefore,
solving
this
is
reduced
to
checking
whether
N
1
(mod
3).
We
solve
this
in
O(1).
3GUNAWAN
3
4
Some
example
of
cases
Theorem
1.
1.
If
S
V
If
is
S
a
MAXINDEPENDENTSET
V
is
a
MAXINDEPENDENTSET
graph
G(V,
of
graph
E),
G(V,
then
E),
V
then
S
V
a
MINVERTEXCOVER
S
is
a
MINVERTE
rvinTheorem
We will look at someb
common
examples of special
casesPlanar
thatb may
occur
in4.1
competitive
a at
2graph
graphs
acrossing
2at
4.1
graphs
Planar
graphs
4.1
is
aAa
graph
that
can
be
drawn
onamany
agraph
without
having
two
each
Planar
graph
is
that
can
be
on
aProof.
surface
without
having
two
crossing
et
al.
2001).
There
are
many
graph
which
easy
solve
ifprov
thefc
Planar
graph
graph
that
can
be
drawn
on
aproblems
surface
without
having
two
edg
Some
example
cases
et
al.
2001).
There
are
graph
problems
which
are
easy
to
solve
the
graph
planar.
We
will
et
al.
2001).
There
are
problems
which
are
easy
to
solve
the
isisare
planar.
We
will
prov
faphspecial
cases
4.1
Planar
graphs
b
2of
Assign
fifif}(1)
tograph
A other
and
f(West
(2)
toto
B.
Since
=
{f
(a
+more
3k),
0of
kspecial
E).
}surface
is
{fathis
(a
1drawn
+
3k),
0Planar
kat
edges
Therefore,
solving
problem
is
reduced
to
checking
whether
N
1edges
(mod
3).
We
examples.
We
will
provide
examples
of many
special
cases
in +
the
following
section.
of
the
graph
the
G(V,
graph
E).
G(V,
4.1
Planar
graphs
programming
problems.
Planar
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
crossing
each
otm
}.
k
3
3
4.1
Planar
graphs
We
will
look
at
some
common
examp
We
will
look
at
some
common
examples
of
special
cases
that
We
will
look
at
some
common
examples
of
special
cases
that
may
occur
in
competitive
programming
problems.
1).
There
are
many
graph
problems
which
are
easy
to
solve
if
the
graph
is
planar.
We
will
provide
several
et
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
if
the
graph
is
planar.
We
wi
We
will
look
at
some
common
examples
of
special
cases
that
may
occur
in
competitiv
ome
example
of
special
cases
examples.
et
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
ifcrossing
the
graph
ishav
poeo
examples.
e will look
some
common
examples
of
special
cases
that
may
occur
in
competitive
problems.
3 at examples.
fasurface
(1)
surface
fcan
(2).
Fwithout
(N
)programming
will
have
Nsurface
2crossing
elements.
Sin
We
will
provide
more
examples
of
special
cases
in
the
following
section.
Planar
graph
is
a
graph
that
can
be
drawn
on
at
having
two
edges
crossing
Planar
graph
is
a
graph
that
be
drawn
on
a
at
without
Planar
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
each
Planar
graph
is
a
graph
that
can
be
drawn
on
a
at
without
having
two
edges
each
4.1
Planar
graphs
b
2
Planar
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
crossing
each
other
(Wes
etsurface
al.cases
2001).
There
are
many
graph
problems
which
are
easy
toThe
solve
ifthat
the
graph
is planar.
We
will
prov
amples
ofa =
special
that
may
occur
inproblems.
competitive
programming
problems.
mayProof.
occur
in
competitive
programming
only
rawn
on
at
without
having
two
edges
crossing
each
other
(West
examples.
Proof.
We
know
We
that
know
V
that
S
is
V
a
vertex
S
is
a
cover
vertex
by
cover
lemma
by
1.
lemma
The
1.
thing
only
thing
remains
that
for
remains
us
to
for
prove
us
to
is
it
p
examples.
}.
B
{f
(a
+
2
+
3k),
0
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
ba2
awn
on
a
at
surface
without
having
two
each
other
(West
et
al.are
2001).
There
are
many
graph
problems
which
are
easy
to
solve
ifgraph
the graph
is planar.
Weifpro
wi
et al.crossing
2001).
There
are
many
problems
which
easy
to
th
etcrossing
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
theplanar.
graph
planar.
Wesolve
will
pro
et
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
ifif the
isisare
planar.
We
will
4.1.1
Number
of
edges
ving
two
edges
each
other
(West
3edges
ry
0 can
kal.
et
2001).
There
many
graph
problems
which
are
easy
to
solve
ifgraph
the
is
We
will
provide
examples.
mples
of
special
cases
may
occur
competitive
programming
problems.
3 Suppose
hat
be
drawn
on
atothat
at
surface
without
two
edges
crossing
each
other
(West
oblems
which
are
easy
solve
ifSthe
the
graph
isishaving
planar.
We
will
provide
several
V
4
is
VSome
not
inS
minimum
not
minimum
vertex
cover.
vertex
Then,
cover.
there
Then,
isgraph
another
there
is vertex
another
cover
vertex
V
cover
S severa
where
V
minimality.
minimality.
Suppose
example
of
special
cases
4.1.1
Number
of
edges
4.1
Planar
g
4.1.
Planar
Graphs
4.1.1
Number
of
edges
4.1
Planar
graphs
4.1.1
Number
of
edges
4.1
Planar
graphs
blems
which
are
easy
to
solve
if
graph
is
planar.
We
will
provide
several
examples.
examples.
examples.
examples.
4.1
Planar
graphs
he graph
is planar.
We
provide
several
examples.
ba2
will
graph
edges
provide
solving
Therefore,
this
problem
is cases
reduced
to ca
any
graph
are
easy
to
solve
the
is
planar.
We
will
several
InPlanar
simple
general
graph,
the
of
canBy
be
up
order
with
respect
the
4Sedges
Some
example
ofindependent
special
ill
sum,
for
0
kimplies
ifnumber
the
V
<
V
S
which
<as
V
which
S,
implies
which
that
S
3 that
> of
S.
By
>
lemma
S.
2,lemma
S
isto
an
2,a independent
Squadratic
isNumber
an
set.
Therefore,
set.
Therefore,
S to
is not
4.1.1
Number
4.1.1
Number
of
edges
4.1
4.1.1
of
edges
graphs
+ have
f V
(a +
1Sproblems
+same
3k)
=
fS,
(a
+
2graphs
+every
3k)
Planar
graph
iseach
awith
graph
that
can
bein
In
simple
general
graph,
the
number
of
edges
can
be
up
to
a
quadrat
Planar
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
2
In
simple
general
graph,
the
number
of
edges
can
be
up
to
a
quadratic
order
with
respect
to
the
In
simple
general
graph,
the
number
of
edges
can
be
up
to
a
quadratic
order
respect
to
the
Planar
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
crossing
each
other
(West
4.1.1
Number
of
edges
Planar
graph
is
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
We
will
look
at
some
common
examples
of
special
cases
that
may
occur
in
competitive
programming
problems.
We
will
provide
more
examples
of
special
cases
anar
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
crossing
other
(West
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
In
a
planar
graph,
we
may
show
that
Ednn
maximum
independent
independent
set. This set.
is a This
contradiction.
is a contradiction.
Therefore
Therefore
V S is Vthe
minimum
S is the minimum
vertex cover.
vertex cover. wi
4.1 maximum
Planar
graphs
2
2
4.1.1
Number
of
edges
2
4.1.1
Number
of
edges
4.1.1
Number
of
edges
4.1.1
Number
of
edges
general
graph,
the
number
of
edges
can
be
up
to
a
quadratic
order
with
respect
to
the
number
of
In
simple
general
graph,
the
number
of
edges
can
be
up
to
a
quadratic
order
with
respect
to
etis
al.
2001).
There
are
many
graph
pr
be
drawn
on
avertices
at
surface
without
having
two
edges
each
other
(West
Planar
graph
is
aet
graph
that
can
be
drawn
on
a2Therefore,
flat
surface
without
having
two
edges
vertices
(i.e.
O(V
)).
isgraph
not
case
for
planar
graph.
In
aeasy
planar
In
simple
graph,
the
number
of
edges
can
be
up
to
aO(V
quadratic
order
wi
without
having
two
edges
each
other
(West
fV(acrossing
+3graph
3k)
+
fThis
(a
+is
1general
+
3k)
=
fcrossing
(aal.
+
+
3k)
eteasy
2001).
There
are
graph
problems
are
to
(i.e.
O(V
)).
not
the
case
for
planar
In
athe
planar
graph,
we
may
show
that
E
et
2001).
There
are
many
problems
which
are
to
solve
ifgraph.
the
graph
planar.
We
will
provide
several
vertices
(i.e.
O(V
)).
This
issome
not
the
case
for
planar
graph.
Inmany
ais
planar
graph,
we
may
show
that
E
4.1.1
Number
of
edges
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
ifwhich
graph
is plan
We
will
look
at
common
examples
of
special
cases
that
may
occur
in).the
competitive
pr
al.al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
ifThis
the
planar.
We
will
provide
several
holds
for
by
using
the
Eulers
formula.
number
of
edges
is
Naturally,
any
4.1.1
Number
of
edges
simple
general
graph,
the
number
edges
can
be
upthe
tograph.
a quadratic
order
with
respect
to
the
n
2 Number
2planar
2 of
4.1.1
of
edges
i.e.
O(VifFrom
)).which
This
is
not
the
case
for
graph.
In
a
planar
graph,
we
may
show
that
E
3V
6
be
drawn
on
aIn
at
surface
without
having
two
edges
crossing
each
other
(West
crossing
each
other
(West
etal.,
2001).
There
are
many
graph
problems
which
are
easy
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
In
a
planar
graph,
we
may
show
th
examples.
h solve
problems
are
easy
to
solve
if
the
graph
is
planar.
We
will
provide
several
the
From
above
the
theorem,
above
theorem,
we
conclude
we
conclude
that
a
MINVERTEXCOVER
that
a
MINVERTEXCOVER
can
be
easily
can
be
constructed
easily
constructed
if
we
have
if
holds
for
V
3
by
using
the
Eulers
formula.
Therefore,
the
number
of
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
In
a
planar
graph,
we
oamples.
the
graph
is
planar.
We
will
provide
several
examples.
holds
for
V
3
by
using
the
Eulers
formula.
Therefore,
the
number
of
edges
is
O(V
).
Naturally,
any
examples.
holds
for
V
3
by
using
the
Eulers
formula.
Therefore,
the
number
of
edges
is
O(V
).
Naturally,
any
examples.
that
has
O(E)
in
running
time
can
be
changed
into
O(V
).In
shortest
path
in
goaw
In(i.e.
simple
general
graph,
the
number
of up
edges
can
up
to
aofquadratic
order
with
to
2its
In
simple
graph,
the
number
edges
can
be
up
toarespect
ageneral
quadra
In
simple
general
graph,
the
number
ofgeneral
edges
can
be
upbeto
to
aaquadratic
quadratic
order
with
respect
to the
the
In
simple
general
graph,
the
number
of
edges
can
be
up
aComputing
order
with
respect
to
4.1.1
Number
of
edges
4.1
Planar
graphs
In
simple
general
graph,
the
number
of
edges
can
be
to
a
quadratic
order
with
respect
to
the
number
vertices
O(V
)).
This
is
not
the
case
for
planar
graph.
planar
graph,
we
may
show
that
E
4number
Some
exam
to
solve
graph
is
planar.
We
provide
several
examples.
3 by can
using
Eulers
formula.
Therefore,
the
number
ofits
is
O(V
).
Naturally,
any
algorithm
ofproblems
edges
can
bethe
up
toif
afor
quadratic
order
with
respect
tothe
the
number
of
hV
which
are
easy
to
solve
the
graph
is3will
planar.
We
will
provide
several
holds
V
3ifrunning
by
using
the
Eulers
formula.
Therefore,
the
number
of
edges
O(V
Naturall
MAXINDEPENDENTSET.
MAXINDEPENDENTSET.
that
has
O(E)
in
running
be
changed
into
O(V
).
Computin
holds
Vis
by
using
Eulers
formula.
Therefore,
theplanar
is O(
2path
2for
that
has
O(E)
in
time
can
be
changed
into
O(V
).
Computing
shortest
path
in
aedges
gr
2edges
that
has
O(E)
in its
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
inshow
a).general
general
gE
22O(V
of
edges
be
up
to
athe
quadratic
order
with
respect
to
the
number
of
vin
GUNAWAN
BellmanFord
takes
O(V
E)
(Halim
&
Halim
2013),
but
only
takes
O(V
)isgraph.
in
aof
planar
graph
vertices
(i.e.
)).
This
is
not
the
case
for
planar
graph.
In
awe
planar
we
may
t
2
vertices
(i.e.
O(V
)).
This
istime
not
the
case
for
plana
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
Incan
a planar
planar
graph,
we
may
show
that
vertices
(i.e.
O(V
)).
This
not
the
case
for
planar
graph.
In
ait
graph,
we
may
that
4.1
Planar
graphs
atic
order
with
respect
to
the
number
ofinto
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
In
ato
planar
graph,
may
show
that
EIninashow
3V
E
holds
for
V
3algorithm
byup
using
the
Eulers
formula.
Therefore,
the
number
of
edges
isgraph,
O(V
).
Naturally,
any
2
2
thePlanar
number
of
edges
can
be
to
a
quadratic
order
with
respect
the
number
of
O(E)
in
its
running
time
can
be
changed
O(V
).
Computing
shortest
path
in
a
general
graph
using
case
for
planar
graph.
In
a
planar
graph,
we
may
show
that
E
3V
6
graph
is
a
graph
that
can
be
drawn
on
a
at
surface
without
having
two
edges
crossing
each
other
(West
that
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
path
a
gen
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
tp
that
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
graph.
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
graph.
4.1.1
Number
of
4.1.1
Number
of
edges
4.1.1
Number
of
edges
case
for
planar
graph.
In
a
planar
graph,
we
may
show
that
E
3V
6
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
holds
for
V
3using
byusing
thecan
Eulers
formula.
Therefore,
theatnumber
of).Therefore,
edges
is ).
O(V
Naturall
holds
for
V changed
3 Therefore,
by
using
the
Eulers
formula.
the
number
of
holds
for
in
3the
by
the
Eulers
formula.
Therefore,
the
number
of edges
edges
is O(V
O(V
).
Naturally,
an
holds
for
VV
3E
by
using
the
Eulers
formula.
the
number
of
is
Naturally,
any
4.1.1
Number
of
edges
ar graph,
we
may
show
that
graph
3V
6isformula.
holds
for that
Vbeginning
3the
byO(E)
using
Eulers
Therefore,
the
number
of
edges
is
Naturally,
any
algorithm
has
its
running
be
into
O(V
Computing
shortest
path
in
ain).
general
gr
We
will
look
some
common
examples
of
special
2).
2two
2i
4.1.1.
Number
of
Edges
his
is
not
the
case
for
planar
graph.
InHalim
aiswe
planar
graph,
we
may
show
that
Ein
asurface
3V
itO(V
62013),
Planar
atime
graph
that
can
be
drawn
on
athe
at
without
having
edges
cro
Ford
algorithm
takes
O(V
E)
(Halim
&
2013),
but
it
only
takes
O(V
)
planar
graph.
Counting
ormula.
Therefore,
number
of
edges
O(V
).
Naturally,
any
algorithm
et
al.
2001).
There
are
many
graph
problems
which
are
easy
to
solve
if
graph
is
planar.
We
will
provide
several
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
only
takes
O(V
)
a
planar
In
the
In
the
beginning
of
this
section,
of
this
section,
assume
we
we
assume
know
we
that
know
MINVERTEXCOVER
MINVERTEXCOVER
is
a
NPhard
is
a
NPhard
problem.
prob
It
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
but
it
only
takes
O(V
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
4.1.1
Number
of
edges
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
of
edges
ormula.
Therefore,
the
number
ofalgorithm
edges
O(V
).
Naturally,
any
algorithm
planar
Therefore,
ifisrunning
the
problem
requires
usgeneral
to
compute
the
number
ofO(V
connected
components
that
has
O(E)
in
its
time
can
be
changed
into
O(V
).with
Computing
shortest
path
in
ausin
gen
that
has
O(E)
its
running
time
be
changed
into
O(V
).order
that
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
path
inthe
general
that
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
path
in
aabeComputi
general
g
fner
edges
is
O(V
).components
Naturally,
any
In
simple
general
graph,
number
that
has
O(E)
ingraph.
its
running
time
be
changed
into
O(V
).This
Computing
shortest
path
into
a2athe
general
BellmanFord
algorithm
takes
E)
(Halim
&
Halim
2013),
but
itcan
takes
)the
inin
anumber
planar
graph.
In
simple
graph,
the
number
of
edges
can
up
towe
simple
general
graph,
the
number
ofcan
edges
can
be
up
toin
abe
quadratic
order
respect
ofnumb
Ingraph,
simple
general
graph,
the
number
of
edges
can
be
up
to
ato
with
In
simple
general
the
number
of
edges
can
up
to
quadratic
order
respect
simple
general
graph,
the
number
of
edges
can
be
up
to
a).
quadratic
order
with
the
number
of
the
Eulers
Therefore,
the
edges
is
O(V
Naturally,
any
algorithm
et
al.
2001).
are
many
graph
problems
are
easy
towith
ifquadratic
graph
isthe
planar.
of
connected
using
DFS
in
aO(V
general
graph
takes
O(V
+a000,
E),
but
itonly
only
)new
a2components
be
changed
into
O(V
).
Computing
shortest
path
in
arequires
general
graph
using
examples.
the
number
of
connected
components
using
DFS
in
awhich
general
graph
takes
O(V
+
E),
but
itsolutio
only
good
to formula.
know
good
as
to
many
know
NPhard
as
many
problem
NPhard
as
possible.
as
possible.
This
isus
necessary
is
necessary
so
that
if
so
we
that
encounter
ifthe
we
encounter
problem
agraph
new
X,
prob
planar
graph.
Therefore,
if
the
problem
requires
us
to
number
of
connected
components
using
DFS
in
arespect
general
graph
takes
O(V
+
E)ii
4.1.1
Number
of
edges
2solve
planar
graph.
Therefore,
ififThere
the
problem
to
compute
the
number
of
connected
planar
graph.
Therefore,
the
problem
requires
us
to
compute
the
number
of
connected
components
22compute
be
changed
into
O(V
).
Computing
shortest
path
in
a
general
graph
using
2
graph,
even
though
the
constraint
states
that
V
100,
E
100,
000
,
standard
DFS
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
2
2
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
graph
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
graph
2
2&
path
in
awith
general
graph
vertices
(i.e.
)).
This
isgraph.
not
the
mber
of(i.e.
edges
can
be
up
to
aonly
quadratic
order
respect
to
number
of
2the
BellmanFord
algorithm
takes
O(V
E)
(Halim
Halim
but
itto
only
takes
O(V
)and
inaO(V
athus
planar
graph.
Countin
oing
a shortest
quadratic
order
respect
to
the
number
of
the
number
of
connected
components
using
DFS
in
ato
general
graph
takes
O(V
+
E),
it3V
only
takes
vertices
(i.e.
O(V
)).
This
is
not
case
for
planar
IO
2planar
vertices
O(V
)).
This
not
the
case
for
planar
graph.
In
athe
planar
graph,
we
may
show
that
E
3V
6conne
to
number
of
vertices
(i.e.
).
This
is
not
case
for
planar
graph.
In
planar
vertices
(i.e.
O(V
)).
This
is2013),
the
case
for
planar
graph.
In
a100,
planar
graph,
wealso
m
22the
rtices
O(V
)).
This
is
not
the
case
for
graph.
In
a
planar
graph,
we
may
show
that
Ebut
6100,
ning
time
can
be
changed
into
O(V
).using
Computing
shortest
path
in
aof
general
graph
using
examples.
P
aph.
Therefore,
if2013),
the
problem
requires
us
to
compute
the
number
connected
components
in
athe
planar
(Halim
&(i.e.
Halim
but
itisthe
takes
O(V
inwith
planar
graph.
Counting
planar
graph.
Therefore,
the
problem
requires
us
compute
the
number
of
connected
compon
can
use
any
can
of
use
the
any
NPhard
of
problems
NPhard
problems
that
we
know,
we
reduce
know,
itthe
reduce
problem
it
to
X,
problem
and
thus
X,compute
prove
that
prove
X
is
that
also
X
NPhard
is
graph,
even
though
the
constraint
states
that
000,
E
4.1
00
2if
planar
graph.
Therefore,
ifusing
the
problem
requires
us
to
number
of
graph,
even
though
the
constraint
states
that
Vnot
100,
000,
E
100,
000
the
standard
DFS
solution
even
though
the
constraint
states
that
V
100,
000,
E
100,
000
,, V
the
standard
DFS
solution
2 graph,
Halim
&
Halim
2013),
but
it
only
takes
O(V
))Therefore,
in
aathat
planar
graph.
Counting
under
one
second
(in
competitive
programming,
we
assume
that
1number
million
operations
can
be
done
in
the
number
of
connected
components
DFS
in
aedges
general
graph
takes
O(V
+
E),
but
it
only
the
number
of
connected
components
using
DFS
in
a
general
graph
take
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
mber
of
edges
can
be
up
to
a
quadratic
order
with
respect
to
the
number
of
y
takes
O(V
)
in
a
planar
graph.
Counting
holds
for
V
3
by
using
the
Eulers
f
t
the
case
for
planar
graph.
In
a
planar
graph,
we
may
show
that
E
3V
6
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
O(V
)
in
2
In
a
planar
graph,
we
may
show
that
E
3V
6
planar
graph.
Therefore,
if
the
problem
requires
us
to
compute
the
of
connected
components
i
holds
for
V
3
by
using
the
formula.
Therefore,
the
n
2
graph,
we
may
show
that
holds
for
by
using
the
Eulers
holds
for
V
3
by
using
the
Eulers
formula.
the
number
of
is
O(V
).
Naturally,
any
algorithm
2 still
holds
for
V
3though
by
using
the
Eulers
formula.
Therefore,
the
number
of
edges
2 isDFS
olds
for
the
by
using
the
Eulers
formula.
Therefore,
the
of
is programming,
O(V
).
Naturally,
any
algorithm
akes
O(V
E)
& Halim
2013),
but
it+
only
takes
O(V
)number
inthat
awe
planar
graph.
Counting
en though
constraint
states
that
V even
100,
000,
100,
000
,assume
the
standard
DFS
solution
runs
using
DFS
in3(Halim
aunder
general
graph
takes
O(V
E),
but
itEthe
only
takes
O(V
) edges
in
athat
graph,
even
though
the
constraint
states
V
100,
000,
100,
000
, of
the
standard
s
under
one
second
(in
competitive
we
assume
that
1O(V
mill
graph,
constraint
states
V
100,
000,
E
100,
000
,the
the
sta
4.1.1
Number
of
edges
under
one
second
(in
competitive
programming,
that
11E
million
operations
can
be
done
in
one
second
(in
competitive
programming,
we
assume
that
million
can
be
done
in
1V
1 We
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
O(V
)
in
a
(Halim
&
Halim
2013)).
planar
graph.
Therefore,
if
the
problem
requires
us
to
compute
the
number
connected
compon
We
say
that
problem
say
that
X
problem
is
reducible
X
is
to
reducible
problem
to
Y
problem
Y
2 operations
planar
graph.
Therefore,
if
the
problem
requires
us
to
compute
num
planar
graph.
Therefore,
if
the
problem
requires
us
to
compute
the
number
of
connected
components
planar
graph.
Therefore,
if
the
problem
requires
us
to
compute
the
number
of
connected
components
Planar
graph
is
a
graph
that
can
be
drawn
on
a
the
case
for
planar
graph.
In
a
planar
graph,
we
may
show
that
E
3V
6
es
O(V
+
E),
but
it
only
takes
O(V
)
in
a
that
has
O(E)
in
its
running
time
can
ers
formula.
Therefore,
the
number
of
edges
is
O(V
).
Naturally,
any
algorithm
planar
ifthat
the
problem
requires
us
to
compute
the
number
of
connected
components
in
a plana
Therefore,
the
number
edges
is
.that
Naturally,
any
algorithm
that
has
Computing
in
its graph
number
of
edges
isTherefore,
O(V
).
Naturally,
any
algorithm
graph,
even
though
the
constraint
states
that
V
100,
000,
E
100,
000
,athe
standard
DFS
solution
has
O(E)
in
its
running
time
can
changed
into
O(V
).d
hat
has
O(E)
inits
its
running
time
can
be
changed
into
O(V
).2013)).
Computing
shortest
path
in
ageneral
general
using
has
O(E)
in its
running
time
can
be
changed
into
O(V
).
shortest
has
O(E)
in
running
can
be
changed
into
O(V
Computing
shortest
path
using
components
using
DFS
in
atime
general
graph
takes
O(V
+
E),
but
takes
O(V
)we
in
eat
second
(in
competitive
programming,
we
assume
that
1).
million
operations
can
be
done
inbe
second
m
requires
usgraph.
to
compute
the
number
of
connected
components
init
aonly
planar
under
one
second
(in
competitive
programming,
we
assume
that
1ain
million
can
bepa
4.1.1
Number
of
(Halim
&
Halim
under
one
second
(in
competitive
programming,
assume
that
1 graph
million
operati
21 operations
(Halim
&
Halim
2013)).
(Halim
&
Halim
2013)).
22 edges
m
requires
us
to
compute
the
number
of
connected
components
in
aV
planar
graph,
even
though
the
constraint
states
that
100,
000,
E
with
100,
,standard
the
standard
DFS
2There
graph,
even
though
the
constraint
states
that
Vthe
100,
000,
E 2013),
100,
graph,
even
though
the
constraint
states
that
100,
000,
E
100,
000
,000
the
standard
DFS
solutio
graph,
even
though
the
constraint
states
that
VV
100,
000,
E
100,
000
,graph
DFS
solutio
2
et
al.
2001).
are
many
graph
problems
which
2
rs
formula.
Therefore,
the
number
of
edges
is
O(V
).
Naturally,
any
algorithm
In
simple
general
graph,
the
number
of
edges
can
be
up
to
a
quadratic
order
respect
to
the
number
of
mber
of
connected
components
in
a
planar
BellmanFord
algorithm
takes
O(V
E)
eellmanFord
can
be
changed
into
O(V
).
Computing
shortest
path
in
a
general
graph
using
running
time
can
be
changed
into
.
Computing
shortest
path
in
a
general
us2
graph,
even
though
the
constraint
states
that
V
100,
000,
E
100,
000
,
the
standard
DFS
solution
still
run
).
Computing
shortest
path
in
a
general
graph
using
under
one
second
(in
competitive
programming,
we
assume
that
1
million
operations
can
be
done
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
b0si
2
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
graph.
Counting
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
takes
O(V
E)
& Halim
2013),
but itcomponents
only
takes O(V
) in a planar graph. Counting )in
ifHalim
the
problem
requires
compute
the
number
ofDFS
connected
in a planar
2013)).
tes
that
V
algorithm
100,
000,
Eus
to
100,
000(Halim
, the
standard
solution
still runs
runs
(Halim
&
Halim
22013)).
(Halim
& competitive
Halim
2013)).
2
2
es
that
V
100,
000,
E
100,
000
,
standard
DFS
solution
still
2
under
one
second
(in
programming,
we
assume
that
1
million
operations
can
be
2
under
one
second
(in
competitive
programming,
we
assume
that
1
mil
under
one
second
(in
competitive
programming,
we
assume
that
1
million
operations
can
be
done
under
one
second
(in
competitive
programming,
we
assume
that
1
million
operations
can
be
done
4.1.2
Maximum
Clique
examples.
In
simple
general
graph,
the
number
of
can
be
upgeneral
tomay
ait of
quadratic
order
with
can
changed
into
O(V
).
Computing
shortest
path
agraph.
general
graph
using
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
In
aedges
planar
graph,
we
show
that
E
)in
3V
res
6gdibi
000
,(Halim
the
standard
DFS
solution
runs
the
connected
components
E)
&connected
Halim
2013),
itstill
only
takes
O(V
in
aincomponents
planar
graph.
Counting
under
second
competitive
programming,
we
assume
that
1O(V
million
operations
can
be
done
1in
2
but
itbe
only
takes
O(V
)(in
in
abut
graph.
(Halim
&
Halim
2013)).
the
number
connected
components
using
DFS
in
general
he
number
of
connected
components
using
DFS
ageneral
general
graph
takes
O(V
E),
but
only
takes
O(V
aE),
the
number
ofCounting
connected
using
DFS
inproblem
anumber
graph
takes
O(V
+
eonstraint
number
ofone
components
using
DFS
inin
a4.1.2
graph
takes
++
E),
but
itMaximum
only
takes
O(V
)ain
asecon
states
that
V
100,
000,
E
100,
000
,)planar
the
standard
DFS
solution
still
runs
gramming,
we
assume
that
1planar
million
operations
can
be
done
in
1of
second
4.1.2
Clique
probl
Maximum
Clique
problem
4.1.2
Maximum
Clique
problem
2
2
gramming,
we
assume
that
1
million
operations
can
be
done
in
1
second
(Halim
&
Halim
2013)).
(Halim
&
2013)).
(Halim
&
2013)).
(Halim
&
Halim
2013)).
vertices
(i.e.
O(V
)).
isifplanar
not
the
case
forofplanar
In
planar
graph,
we
may s
E)
(Halim
&&
Halim
2013),
but
it
takes
O(V
) to
in
aHalim
graph.
Counting
holds
for
VO(V
incan
3+
by
using
the
Eulers
formula.
Therefore,
the
number
edges
is O(V
). aNaturally,
any
algorithm
llion
operations
be
in
1only
second
planar
graph.
Therefore,
the
problem
ents
using
DFS
aMaximum
general
graph
takes
O(V
+
E),
but
it
only
takes
O(V
) of
in
aset
(Halim
Halim
2013)).
graph
takes
E),
but
itproblem
only
takes
) us
inThis
aoperations
planar
graph.
Therefore,
if graph.
the
problem
us
to
compute
planar
graph.
Therefore,
ifHalim
the
problem
requires
compute
the
number
connected
components
planar
planar
graph.
Therefore,
the
problem
requires
us
to
compute
the
number
of
connect
anar
graph.
Therefore,
ifdone
the
requires
us
to
compute
the
number
of
connected
components
inin
aifasuch
planar
mpetitive
programming,
we
assume
that
1O(V
million
can
be
done
in
1
second
The
Clique
problem
requires
us
to
nd
the
maximum
of
vertices
inrequires
a graph,
that
ev
4.1.2
Maximum
Clique
problem
4.1.2
Maximum
Clique
problem
4.1.2
Maximum
Clique
problem
2
2
holds
for
V
3
by
using
the
Eulers
formula.
Therefore,
the
number
of
edges
is
O(V
).sta
N
4.1.1
nts
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
O(V
in
a
that
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
path
in
a
general
graph
using
graph,
even
though
the
constraint
oblem
requires
us
to
compute
the
number
of
connected
components
in
a
planar
2)
The
Maximum
Clique
problem
requires
us
to
nd
the
maximum
set
of
ve
te
the
number
of
connected
components
in
a
planar
graph,
even
though
the
constraint
states
that
V
100,
000,
E
The
Maximum
Clique
problem
requires
us
to
nd
the
maximum
set
of
vertices
in
a
graph,
such
that
eve
graph,
even
though
the
constraint
states
that
V
100,
000,
E
100,
000
,
the
standard
DFS
solution
still
runs
The
Maximum
Clique
problem
requires
us
to
nd
the
maximum
set
of
vertices
in
a
graph,
such
that
ev
4.1.2
Maximum
Clique
problem
graph,
even
though
the
constraint
states
that
V
100,
000,
E
100,
000
,
the
stand
aph, even though
the in
constraint
thatconnected
V 100,by
000,
100,
, the standard
DFS
solution
still runs cliqu
vertices
the set isstates
directly
an E
edge.
By 000
reduction
from vertex
cover,
the maximum
2
2
2
4.1.2
Maximum
Clique
problem
4.1.2
Maximum
Clique
prob
4.1.2
Maximum
Clique
problem
4.1.2
Maximum
Clique
problem
that
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
path
in
Clique
problem
requires
us
to
nd
maximum
set
of
vertices
inproblem
aconnected
graph,
such
that
every
of
oblem
requires
us
to
compute
the
number
of
connected
components
in
astill
planar
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)can
abe
planar
graph.
Counting
The
Maximum
Clique
problem
requires
us
to
nd
the
maximum
set
of
vertices
in
acompetitive
such
th
under
one
second
(in
pro
tmum
that
V
100,
E
100,
000the
,connected
the
standard
DFS
solution
runs
vertices
incompetitive
the
is
directly
by
an
edge.
By
reduction
from
The
Maximum
Clique
problem
requires
us
to
nd
the
maximum
set
of
vertices
incliqu
ave
Estates
100,
000
,
the
standard
DFS
solution
still
runs
under
one
second
(in
competitive
programming,
assume
tg
vertices
in
the
set
is
directly
connected
by
an
edge.
reduction
from
vertex
cover,
the
maximum
under
one
second
(in
competitive
programming,
we
assume
that
1In
million
operations
done
in
1we
second
vertices
in000,
the
set
is
directly
by
an
edge.
By
reduction
from
vertex
cover,
the
maximum
cliqu
4.1.2
Maximum
Clique
under
one
second
(in
programming,
we
assume
that
1pair
million
operation
nder
second
(in
competitive
programming,
we
assume
that
1By
million
operations
can
be
done
in
1graph,
second
on
general
graph
is
NPhard.
However,
it
isset
easy
to
solve
this
problem
inin
planar
graph.
Consider
th
simple
general
graph,
the
number
of
edges
ca
.1.2 one
Maximum
Clique
problem
The
Maximum
Clique
problem
requires
uscan
to
nd
the
maximum
set
of+vertices
in
aonly
graph,
such
that
eve
2
2
Maximum
Clique
problem
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
ne.1.2
the
set
is
directly
connected
by
an
edge.
By
reduction
from
vertex
cover,
the
maximum
clique
problem
states
that
V
100,
000,
E
100,
000
,
the
standard
DFS
solution
still
runs
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
E),
but
it
takes
O(V
vertices
in
the
set
is
directly
connected
by
an
edge.
By
reduction
from
vertex
cover,
the
maximum
(Halim
&
Halim
2013)).
programming,
we
assume
that
1
million
operations
be
done
in
1
second
on
general
graph
is
NPhard.
However,
it
is
easy
to
solve
this
problem
vertices
the
set
is
directly
connected
by
an
edge.
By
reduction
from
vertex
cover,
that
1
million
operations
can
be
done
in
1
second
(Halim
&
Halim
2013)).
on
general
graph
is
NPhard.
However,
it
is
easy
to
solve
this
problem
in
planar
graph.
Consider
th
blem
on
general
graph
is
NPhard.
However,
it
is
easy
to
solve
this
problem
in
planar
graph.
Consider
th
Halim & Halim 2013)).
is aPlanar
graph graph
that can
drawn
on can
a at
edgesNumber
crossing
each
other
(Westeach other (West
is abegraph
that
besurface
drawn without
on a athaving
surfacetwo
without
having
two
crossing
4.1.1
ofedges
edges
canSuppose
be
partitioned
two
ofedges
equal
sum..
There
many Number
graph
which
easy toProof.
solve
ifare
the
graph
is4.1.1
planar.
We
will
several
Number
ofNote
4.1.1
edges
4.1.1
Number
of
edges
et are
al.
2001).
Thereproblems
areof
many
graphare
problems
which
easy
to
if F
the
graph
isprovide
planar.
We
severa
F solve
(N
)into
=
(N
)multisets
f (1).
thatwill
F provide
(N ) contains
In simple general graph, the number
of
edges
can
be
up
to
a
quadratic
order
with4.1.1
respectN
4.1.1
Number
of
edges
examples.
haveN
number
1 03.(mod
3).
By
lemma
3,
F a(N
) can be
partitioned
int
2order
Iffor
N
1to
(mod
Fto
) graph
cannot
partitioned
int
general
graph,
the
edges
can
be3),
up
quadratic
order
with
res
ber of edges can
be up
toIna simple
quadratic
withisTheorem
respect
theof
number
of
In simple
general
graph,
the
of
can
be
up
agraph.
quadratic
order
with
to show
the
Planar
isbe
arespect
graph
that
can
vertices
(i.e.
O(V
)).number
This
notedges
the to
case
planar
In
a(Nplanar
graph,
we may
sum
of
all
elements
in
F
(N
)
is
even.
However,
the
sum
of
all
eleme
2
simple
general
the
of
edges
can
In
simple
upfor
graph,
order
the
with
number
respect
of edges
to
the
ca
vertices
O(V
)).
This
is not
the be
case
graph.
In2001).
aofplanar
graph,
we
may
the case for In
planar
In
graph,
we
may
show
that
E
3Vtoplanar
ageneral
vertices
(i.e.
O(V
)).
isnumber
not
the
case
for
planar
graph.
In6quadratic
athe
planar
graph,
we
may
show
En
et
There
are
many
gra
holds
foragraph,
V2planar
(i.e.
3This
by
using
the
Eulers
formula.
Therefore,
edges
is O(V
).that
J.I.
94 graph.
Gunawan
Proof.
Suppose
F (N
) =f F
(Nis)number
al.
f (1).
Note
that
F (N
)Natur
cont
4.1.1
Number4.1.1
of
edges
because
F
(N
) is
even
while
(1)
Therefore,
there
isO(V
no
way
2
2odd.
Number
of
edges
vertices
(i.e.
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
In
a
O(V
planar
)).
graph,
This
is
we
not
may
the
show
case
that
for
pla
E
holds
for
V
3
by
using
the
Eulers
formula.
Therefore,
the
number
of
edges
is
).
s formula. Therefore,
the
of in
edges
is O(V formula.
).
Naturally,
any algorithm
holds forthat
V number
3 by
using
the
Eulers
the number
edges is O(V
). Naturally,
examples.
has
O(E)
its running
time
canTherefore,
be
).of
Computing
in any
aN
g
haveN
1 changed
0 (modinto
3). O(V
By lemma
3, F (Nshortest
) can be2path
partitioned
holds
for
VO(E)
3edges
by
using
the
Eulers
Therefore,
holds
the
for
number
3F
by
ofbut
using
edges
the
isbe
O(V
Eulers
).O(V
Naturally,
formula.
any
Ther
has
O(E)
in
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
can In
be
changed
into
).that
Computing
shortest
path
a 4.
general
graph
using
neral
graph,
the
number
of
can
be
up
toTheorem
aformula.
quadratic
order
with
respect
to
the
number
ofto
that
hasO(V
in
its
running
time
can
beinchanged
).V Computing
shortest
path
in a)number
general
gi
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
itcan
only
takes
in of
apath
plan
simple
general
graph,
the
number
of
edges
can
be
up
to
a
quadratic
order
with
the
of
ing
BellmanFord
algorithm
takes
(Halim
and
Halim,
2013),
itrespect
only
takes
If
Ninto
2O(V
(mod
3).
)but
partitioned
into
two
sum
of all
elements
in F 2013),
(N
) is(N
even.
However,
the
sum
2 allgre
2 takes
2
2 6takes
2
that
has
O(E)
in
its
running
time
can
be
changed
into
that
O(V
has
).
O(E)
Computing
in
its
running
shortest
time
path
can
in
a
be
general
changed
BellmanFord
algorithm
O(V
E)
(Halim
&
Halim
2013),
but
it
only
O(V
)
in
a
E)
&
Halim
2013),
but
it
only
)
in
a
planar
graph.
Counting
O(V(Halim
)).
This
is
not
the
case
for
planar
graph.
In
a
planar
graph,
we
may
show
that
E
3V
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
it
only
takes
O(V
)
in
a
planar
graph
the
number
of
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
on
in
a
planar
graph.
Counting
the
number
of
connected
components
using
DFS
in
vertices (i.e. O(V )). This is not the case for planar
graph.
In
planar
graph,
weis may
show
that E 3Vis
6
because
F f(N
) to
isa even
while
f (1)
odd.
Therefore,
no
2f (1) = fthere
A
(2)
toO(V
B.
Since
(2),
we
ar
BellmanFord
algorithm
takes
O(V
E)
(Halim
&edges
Halim
BellmanFord
but
algorithm
only
takes
takes
O(V
O(V
) of
inbut
E)
a planar
(Halim
graph.
&comp
Ha
the
number
of
connected
components
using
DFS
in
general
graph
O(V
E),
but
using
DFS
in
anumber
graph
takes
O(V
+ E),
but
itof
only
takes
)and
inNaturally,
afitaplanar
nts
3 by
using
Eulers
formula.
Therefore,
the
number
is
O(V
).
any
algorithm
of
connected
components
using
DFS
in(1)
a 2013),
general
graph
takes
O(V
+takes
E),
it +
only
takes
takes
,Therefore,
but
itAssign
only
takes
graph.
Therefore,
graph.
Therefore,
ifProof.
the
problem
requires
us
to
compute
the
number
connected
holds
forthe
Vthe
3general
byplanar
using
the
Eulers
formula.
the
number
of
edges
is
).
Naturally,
any
algorithm
simple
general
graph,
the
nu
f (2).
Fshortest
)requires
will
have
N
2EIn
elements.
Nit
only
2 (mod
3O
2bebut
the
number
of
connected
components
using
DFS
in
ato
the
general
number
graph
of
connected
takes
+
E),
using
DFS
takes
in
planar
graph.
Therefore,
ifrequires
the
problem
us
compute
the
number
of
connected
blem
requires
us time
to
compute
the
number
ofthe
components
in
a
) inthat
its
running
can
be
changed
into
O(V
).f (1)
Computing
path
in
ato
general
graph
using
if in
the
problem
requires
toconnected
compute
the
number
components
in
aSince
planar
graph.
Therefore,
ifus
the
problem
us
compute
the
number
of
connected
components
Theorem
4.(N
Ifof
N
2100,
(mod
3).
FO(V
(N
)components
can
partitioned
into
graph,
even
though
constraint
states
that
Vconnected
planar
000,
100,
000
, the
standard
DFS
has O(E)
its
running
time
can
be
changed
into
O(V
).
Computing
shortest
path
in
aplanar
general
graph
using
2
by the
construction
of
the
function.
2
vertices
(i.e.
O(V
)).
This
is
n
2
2
2
3,
F
(N
)
can
be
partitioned
into
two
multisets
of
equal
sum,
which
2 Eof
graph.
Therefore,
the
problem
us
planar
compute
graph.
the
Therefore,
number
if
connected
the
problem
requires
in
graph,
even
though
the
constraint
states
that
Vruns
000,
000
,components
the
standard
graph,
even
though
theif
constraint
that
the
standard
states
thattakes
Vplanar
O(V
100,
000,
E
100,
000
,2013),
the
standard
DFS
algorithm
E)
(Halim
&second
Halim
but
itrequires
only
takes
O(V
)only
in
aEassume
planar
graph.
Counting
graph,
even
though
the
constraint
states
that
Vsolution
to
100,
000,
100,
100,
000
,
the
standard
DFS
solutio
under
one
(in
competitive
programming,
we
that
million
operations
can us
be
BellmanFord
algorithm
takes
O(V
E)
(Halim
&states
Halim
2013),
but
itstill
takes
O(V
) 1,in
a100,
planar
graph.
Counting
by
the
construction
of
the
function.
2to for
Proof.
Assign
fassume
(1)
to
A
and
fmillion
(2)
B.
Since
fby
(1)
=
fdone
(2),
w
holds
V
a3
using
the
Eu
graph,
even
though
the
constraint
states
that
V
100,
graph,
000,
even
E
though
100,
000
the
,
constraint
the
standard
states
DFS
that
solution
V
DFS
solution
still
runs
under
one
second
(in
competitive
programming,
we
assume
that
under
one
second
(in
competitive
programming,
we
assume
that
1
million
operations
ca
we
assume
that
1
million
operations
can
be
done
in
1
second
fprogramming,
connected
components
using
DFS
in
a
general
graph
takes
O(V
+
E),
but
it
only
takes
O(V
)
in
under
one
second
(in
competitive
programming,
we
that
1
operations
can
be
in
Theorem
2.
If
N
is
divisible
by
three,
then
F
(N
)
can
be
partitioned
into
two
multise
(Halim components
& Halim 2013)).
the number of connected
using DFSTherefore,
in a general
graph
takes
O(V +
E),
but it
takes whether
O(V ) inN
a
this
solving
problem
isthat
reduced
toonly
checking
f
(1)
f
(2).
F
(N
)
will
have
N
2
elements.
Since
N
2
(mo
has
O(E)
in
its
running
tim
1million
operations
can
be
done
in
1
second
(Halim
and
Halim
2013)).
under
one
second
(in
competitive
programming,
we
under
assume
one
that
second
1
million
(in
competitive
operations
programming,
can
be
done
in
(Halim
&
Halim
2013)).
Theorem
2. Ifproblem
N&isHalim
divisible
then
F (N
)number
can
be partitioned
into
two
multisets
of
equal sum.in a planarw
Therefore,
if (Halim
the
requires
usthree,
to compute
the
of
connected
components
in
a
planar
planar graph.
Therefore,
if 2013)).
thebyproblem
requires
us
to
compute
the
number
of
connected
components
three, then
We will
more
special
the
sectio
Proof.
N is000,
divisible
Fexamples
(N ) isHalim
a2of
prex
of Fcases
within
length
multiples
of
3,byFprovide
(N
)2can
bestandard
partitioned
into
two
multisets
of following
equal
sum,
wh
BellmanFord
algorithm
takes
O(
(Halim
&states
Halim
2013)).
2013)).
hough
the constraint
that
V If100,
E
000
, the
DFS
solution
still
runs
graph,
even
though
the constraint
states
that
V 100,
100,
000,
E(Halim
100,&000
, the
standard
DFS
solution still runs
4.1.2
Maximum
Clique
problem
Proof. If N is4.1.2.
divisible
bycan
three,
thenProblem
F (N ) into
is a two
prex
of F with
lengthsum..
multiples
of
three. ofByconnected
lemma 3,compo
F (N )
be
partitioned
multisets
of
equal
the
number
Maximum
Clique
cond
(in competitive
weprogramming,
assume that
1wemillion
operations
can problem
be
done
1can
second
4.1.2
Maximum
Clique
problem
4.1.2
Maximum
Clique
problem
4.1.2
Maximum
problem
under
one
secondprogramming,
(in competitive
assume
that
1Clique
million
operations
betodone
in 1 second
Therefore,
solving
this
isinreduced
checking
wheth
can be partitioned
into Maximum
two multisets
of equal
sum..
planar
graph.
Therefore,
ifMaxi
the
p
The
problem
requires
us to
the4maximum
set
of
vertices
in4.1.2
a graph,
such
The Maximum
CliqueClique
problem
requires
usMaximum
to find
thend
maximum
set
of
vertices
in
a graph,
4.1.2
Clique
problem
im 2013)).
Some
example
of
spe
(Halim & Halim 2013)). Theorem 3. If N 1We
(mod
3),
F
(N
)
cannot
be
partitioned
into
two
multisets
of
equs
will
provide
more
examples
of
special
cases
in
the
following
The
Maximum
Clique
problem
requires
us
to
nd
the
maximum
set
of
vertices
in
a
graph,
uires us to ndThe
thesuch
maximum
set
of
vertices
in
a
graph,
such
that
every
pair
of
Maximum
Clique
requires
us
maximum
set an
of edge.
vertices
in
a though
graph,
that
ev
that every
of vertices
in the
settois nd
directly
connected
by
By
reduction
graph,
even
the
vertices
in pair
the problem
set
is directly
connected
bythe
an edge.
By reduction
from
vertex
cover,such
theconstrai
maxim
TheoremThe
3. Maximum
If N 1 vertices
(mod
3),
Fthe
(Nset
) cannot
be
partitioned
into
two
multisets
of equal
sum.
Clique
problem
requires
us
to
nd
the
The
maximum
Maximum
set
of
Clique
vertices
problem
in
a
graph,
requires
such
us
to
that
nd
eve
t
in
is
directly
connected
by
an
edge.
By
reduction
from
vertex
cover,
the
m
cted by an edge.
By
reduction
from
vertex
cover,
the
maximum
clique
problem
from
vertex
cover,
the
maximum
clique
problem
on
general
graph
is
NPhard.
However,
vertices
in
the
set
is
directly
connected
by
an
edge.
By
reduction
from
vertex
cover,
the
maximum
cliqu
under
one
second
(in
competiti
on
general
graph
is
NPhard.
However,
it
is
easy
to
solve
this
problem
in
planar
graph.
Con
examples
special N
cases
may oc
Suppose
FWe
(Nwill
)problem
= look
F (Nat
) some
f (1).common
Note that
F (N )ofcontains
1that
elements.
4.1.2 Proof.
Maximum
Clique
4.1.2
Maximum
Clique
problem
vertices
set
directly
connected
by
an
By
vertices
reduction
in
the
from
set
is
directly
cover,
the
maximum
by
an
edge.
clique
general
graph
NPhard.
However,
isvertices
easy
solve
this
problem
in
graph.
the
edge.
N
it solve
isFinof
easy
to
solve
inthat
planar
graph.
Consider
the
colouring
a1planar
wever,
it is Suppose
easy
this
problem
in
planar
graph.
Consider
the
on to
general
graph
NPhard.
However,
it
is
easy
to
solve
this
problem
inof
planar
graph.
Consider
th
(Halim
& connected
Halim
2013)).
a)this
graph
such
that
two
have
the
same
colour.
Note
that
ifwe
Proof.
(Ncolouring
)on
= haveN
Fisis
(N
f1problem
(1).
Note
F
(N
)adjacent
contains
1to
elements.
Since
N
two
(mod
3),
0is
(mod
3).no
By
lemma
3,it
Fproblem
(N
)
can
be vertex
partitioned
into
multisets
of
4problem
Some
example
of
st
on
general
graph
is
NPhard.
However,
it
is
easy
to
on
solve
general
this
graph
problem
is
NPhard.
in
planar
graph.
However,
Consider
it
is
easy
the
of
colouring
a
graph
such
that
no
two
adjacent
vertices
have
the
same
colour.
Note
tha
graph
such
that
no
two
adjacent
vertices
have
the
same
colour.
Note
that
if
there
is
a
adjacent
vertices
have
the
same
colour.
Note
that
if
there
is
a
clique
of
mtwo
Clique
problem
requires
us
to
nd
the
maximum
set
of
vertices
in
a
graph,
such
that
every
pair
of
of
colouring
a
graph
such
that
no
two
adjacent
vertices
have
the
same
colour.
Note
that
if
there
is
size problem
k insum
a graph,
vertices
insideset
the
must
coloured
with
kevery
colours.
Th
The
Maximum
requires
toofnd
ofclique
vertices
in abegraph,
such
thatTherefore,
pair
of
haveN
1 0 Clique
(mod
3).
By
lemma
3, us
Fset(N
)inthe
can
bemaximum
into
two
multisets
equal
sum.
of
all the
elements
Fthe
(N
)partitioned
is even.
However,
the
sum
ofof
all
elements
in
F
(N
) =the
F
4.1
Planar
graph
ofsize
colouring
aby
graph
such
that
no
two
adjacent
vertices
ofodd.
colouring
have
the
aFsame
graph
colour.
such
that
Note
no
that
two
ifadjacent
there
ve
a
clique
of
size
in
in
graph,
ofWe
the
vertices
the
clique
must
be
coloured
size
kthe
aset
graph,
the
set
of
the
inside
the
clique
with
kproblem
colour
be
be
with
clique
coloured
kset
colours.
Therefore,
the
entire
ertices
setvertices
isinside
directly
connected
an
edge.
By
reduction
from
vertex
cover,
the
maximum
clique
problem
ksetinisamust
graph,
of
the
vertices
inside
the
clique
must
coloured
with
kspecial
Therefore,
will
look
at
some
common
ofcoloured
cases
that
ma
inthe
the
directly
by
edge.
By
reduction
from
vertex
cover,
the
maximum
clique
sum
of all
elements
in
F
(N
)connected
is
even.
However,
the
sum
of
all
elements
inbe
(Nexamples
)must
=
Fis
(N
)way
+colours.
fwith
(1),
which
isFis
odd
because
F
(N
)the
isan
even
while
fvertices
(1)
isinside
Therefore,
there
no
to
partition
(N
colours.
Therefore,
the
entire
graph
requires
at
least
colours.
By
the
four
colour
theaeven
graph,
setto
ofodd.
the itvertices
inside
the
clique
sizeproblem
k
must
intoa partition
be
graph,
coloured
set
with
of kthe
colours.
vertices
Therefore,
inside
the
graph
Planar
graph
is planar
graph
that
can
be drawn
aConsider
at
surface
without
aphbecause
is general
NPhard.
it isthe
easy
solve
this
problem
in
graph.
Consider
the
problem
on
NPhard.
However,
is
easy
to there
solve
in
planar
graph.
the
problem
Fsize
(NkHowever,
) in
is is
while
f (1)
is
Therefore,
isathis
no
way
F (N
).on
Jonathan
Irvin
GUNAWAN
graph
requires
at
least
kmultisets
colours.
Bysolve
therf
The
Maximum
Clique
problem
orem,
any
planar
graph
can
be
coloured
with
at
most
four
colours.
(Gonthier,
2005).
Since
Theorem
4.
If
N
2
(mod
3).
F
(N
)
can
be
partitioned
into
two
of
equal
et
al.
2001).
There
are
many
graph
problems
which
are
easy
to
a graph
such
that
no
two
adjacent
vertices
have
the
same
colour.
Note
that
if
there
is
a
clique
of
of colouring
a graphIrvin
such
that no
twoGUNAWAN
adjacent vertices have the same colour. Note that4.1
if there
is a cliquegr
of
Jonathan
Irvin
Jonathan
GUNAWAN
colours.
the
four
colour
theorem,
any
can be
coloured
with
at most
four
the four By
colour
theorem,
any
planar
graph
can
begraph
with
at most
four
colours.
2005).
Since
at most
vertices
inentire
setPlanar
is directly
con
most
colours
are
required
to
colour
a planar
there
does
not
exist
athe
clique
4.
If vertices
N
2four
(mod
3).
F
(Nplanar
) can
becoloured
partitioned
into
two
multisets
of (Gonthier
equal
sum.
examples.
aph,Theorem
the kset
of
theat
inside
thevertices
clique
must
be
coloured
with
kgraph,
colours.
Therefore,
the
size
in
a
graph,
the
set
of
the
inside
the
clique
must
be
coloured
with
k
colours.
Therefore,
the
entire
Jonathan
Irvin
GUNAWAN
Jonathan
Irvin
GUNAWAN
Proof.
Assign
fcolour
(1)
toawe
Aplanar
and
fgraph,
(2)
tonot
B.
Since
(1)
=
f (2),
wethan
are
now
trying
to pa
orem,
anyatcolours
planar
graph
can be
coloured
with
at
most
four
. Since
most four
colours
are
required
does
exist
most
four
are required
tofour
colour
a to
planar
graph,
there
does
exist
athat
clique
with
more
vertices.
H
on
graph
is NPhard.
with
more
than
vertices.
Hence,
can
solve
the
problem
byfnot
checking
whether
there
Planar
graph
is athere
graph
can
begeneral
drawn
on
a four
at
surface
with
Since f (1) = f (2), we are now trying to partition F (N ) = F (N )
Proof.
Assign
f
(1)
to
A
and
f
(2)
to
B.
f
(1)
f
(2).
F
(N
)
will
have
N
2
elements.
Since
N
2
(mod
3),
we
obtain
N
w2
es.
required
to
colour
a
planar
graph,
there
does
not
exist
four
vertices.
Hence,
wethe
can
solve
by
checking
whether
there
is
a
clique
Hence,
we can
problem
by problem
checking
whether
there
is
a
clique
with
four
vertices.
If
there
is
no
clique
of
colouring
a
graph
such
that
is solve
a clique
with
fourthe
vertices.
If there
is
no
clique
with
four
vertices,
we
check
whether
et al. 2001). There are many graph problems which
are easy
to so
Number
oftheore
edg
f (2).
F
(Nchecking
) vertices,
will
have
N
(mod
3). our
By
lemma
Jonathan
Irvin
GUNAWAN
3,whether
Fwith
(Ncheck
) can
beispartitioned
two multisets
of equal
sum,
which
implies
solve
theclique
problem
by
there
a clique
re
iswith
with
four
we
whether
therewith
isinto
a clique
withisthree
vertices.
ue
four
vertices,
we
whether
there
three
vertices.
Finding
whether
there
is
a the
clique
with
k
there
is
acheck
clique
three
vertices.
Finding
whether
there
a clique
with
vertices
can
size
k2in
a0graph,
set
of
the
examples.
k
kthree
4of edgeswhich
F (N
)whether
can
besolved
partitioned
into
multisets
of equal
sum,
which
our
theorem.
s,a we
check
there
is
a clique
with
clique
with
k vertices
can
be
solved
naively
inInvertices.
O(V
).the
Therefore,
theimplies
whole
solution
th
k 3,vertices
can
be
naively
in two
O(V
).. Therefore,
Therefore,
the
whole
solution
simple
general
graph,
the
number
up to a qua
naively
in
whole
solution
takes
is
takes
O(V
) time, can be
is polynomial.
Therefore,2 solving this2 problem is2 reduced to checking whether N 1 (mod 3). W
k
solved
in
O(V
).improved
Therefore,
the
whole
solution
is polynomial.
The
solution
can solution
betoimproved
to
O(V of).
Instead
of
having
four
nested
polynomial.
The
improved
to
having
four
nested
loopsindependently,
ial.
Thenaively
solution
can
be
O(Vcan
).be
Instead
having
nested
vertices
(i.e.
O(Vfour
)).
Thisloops
isof
not
the
case
forvertices
planar
graph. In of
a pl
to
nd
four
. Instead
4.1.1
Number
Jonathan
Irvin
GUNAWAN
Therefore, solving
this
problem
is reduced
checkingofwhether
N
1in(mod
3). We can
solve
this in O(1).
We
will provide
moretoexamples
special
cases
the following
section.
2
an
be
improved
to
O(V
).
Instead
of
having
four
nested
totwo
find
four
independently,
we
can
two
nested
loops
over
the edges
instead
sntly,
independently,
cannested
havevertices
two nested
loops
overinstead
the
edges
and
test
whether
we can havewe
loops
over
the
edges
and
test
whether
holds
for
V have
3instead
by using
the
Eulers
formula.
Therefore,
number
the
four
vertices
(which
are thethe
endpoint
We will provide more examples of special cases in the following
section.
2 the the
2 takes
wo
nested
over
the
edges
instead
testthat
whether
In
simple
general
graph,
of
can
be up
to a
and
the
four
vertices
(which
are
the
endpoint
twoasnumber
edges)
a clique.
re the
of
thetest
twowhether
edges)
form
aand
clique.
This
solution
),same
which
isO(V
the
oint
of endpoint
the loops
two edges)
form
a clique.
This
solution
takes
O(E
),
which
is of
the
has
O(E)
in
itsO(E
running
time
can
be2form
into
O(V
). Comp
)changed
in edges
planar
graph.
2
2
isvertices
the
same
as
in
planar
graph.
s)graph.
form a clique. This solution takes
takes O(E ),, which
the4
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
BellmanFord
algorithm
takes
O(V
E)
(Halim
&
Halim
2013),
but
itIno
Some example of special cases
holds
for
V
3
by
using
the
Eulers
formula.
Therefore,
the
num
the number of of
connected
components
using DFS in a general graph
t
4 Some example
special
cases
4.1.3.
Problem
Example
that
has examples
O(E)
in its
time that
can
be
changed
into
O(Vthe
). C
We willexample
look at some
common
of ifrunning
special
cases
may
occur
in
competitive
planar
graph.
Therefore,
the problem
requires
us
to compute
n
4.1.3 example
Problem
4.1.3 Problem
We
use
a that
past
programm
Wesome
will common
use a pastexamples
competitive
programming
problem
illustrate
the
importance
of
the
BellmanFord
algorithm
takes
O(V
E)
(Halim
& 100,
Halim
2013),
will look at
of special
cases
that
may
occur
in will
competitive
programming
problems.
lemWe
example
graph,
even though
theto
constraint
states
Vcompetitive
000,
E but
10
etitive programming
illustrate
theThe
importance
of
the
properties
in
a
planar
ramming
problemproperties
to problem
illustrate
the
importance
of Traffic
the
properties
in
a
planar
in ato
planar
graph.
problem
from
Central
European
Olympiad
in
graph.
The
Trac
problem
from
Centra
the
number
of
connected
components
using
DFS
in
a
general
gra
under one second (in competitive
programming,
we assume that 1
4.1 this
Planar
graphs
ontral
illustrate
the importance
of
the properties
in a2011
planar
lem
from
Central
EuropeaninOlympiad
in (CEOI)
Informatics
(CEOI)
2011this
illustrates
concept
European
Olympiad
Informatics
illustrates
concept
Informatics
(CEOI)
2011
illustrates
this
concept
well.
In thiswell.
problem,
there
isrequires
a directed
In problem
this
problem,
there
directed t
planar
graph.
Therefore,
if the
us is
toacompute
(Halim
& Halim
2013)).
4.1
Planar
graphs
mpiad
Informatics
2011
this
concept
ere
isgraph
aindirected
graph
up
to000
Villustrates
=
300,is000
vertices
given
a
2D
plane.
There
are
graph
with
up
to
vertices
in
a
2D
plane.
There
are
two
vertical
lines
cted
with up
to(CEOI)
Vwith
= 300,
vertices
given
ingraph,
athat
2D
plane.
There
are
two
vertical
lines
denoted
as
left
and
rig
Planar
graph
a graph
can
be
drawn
on
a
at
surface
without
having
two
edges
even though the constraint states that V 100, 000,
E
Vleft
= 300,
000
vertices
given
a contained
2D
plane.
There
are
denoted
as that
left
and
right.
All
are
contained
within
the
left
and
right
lines,
as
andgraph
right.
Allgraph
vertices
are
within
the
left
and
right
lines,
with
some
dto
right.
All
vertices
contained
within
theThere
left
and
right
lines,
with
some
vertices
possibly
lying
on
these
two
lines.
Planar
is aare
can
be
drawn
onvertices
a under
at
surface
without
having
two
edges
crossing
each
other
(West
etin
al.
2001).
are
many
graph
problems
which
are
easy
to
solve
if
the
graph
is
plan
one second (in competitive
programming,
we
assume
tha
4.1.2
Clique pr
2 the Maximum
2of visitable
with
some
vertices
possibly
lying
onsome
these
two
lines.
The ifproblem
requires
contestant
are
contained
within
the
left
and
right
lines,
with
these
two2001).
lines.
The
problem
requires
the
contestant
to
print
the
number
ines.
The
problem
requires
the
contestant
to
print
the
number
of solve
visitable
vertices
lying
on the
line from
eve
et
al.
There
are
many
graph
problems
which
are
easy
to
the
graph
is planar.
Weright
will provide
severa
examples.
(Halim
&
Halim
2013)).
2
2 lying on the right line from every vertex lying
to vertex
print
number
of(which
visitable
vertices
the contestant
tothe
print
the
number
htevery
line
from
every
lying
on
the
left of
line
(which
we
shall
call problem
left
vertices
andus for
mrequires
vertex
lying
on the
left
line
wevisitable
shall
call
left
vertices
and
The
Maximum
Clique
requires
to nd
the maximum
set o
right
vertices
simplicity).
An instanc
examples.
on
the
left
(which
we
shall
call
left
and
rightconnected
vertices forbysimplicity).
An reduction from
on the
(which
we
shall
call
left
vertices
and
ity).
An
instance
for
this
problem
can
be
seen
gure
tance
forleft
this line
problem
can
beline
seen
on gure
5. on
vertices
in5.vertices
the set is
directly
an
edge.
By
4.1.1 Number of edges
Maximum Clique
for this problem can beon
seen on Fig.
5. is NPhard. However, 4.1.2
em can be seen oninstance
gure 5.
graph
it is easy to solve this prob
4.1.1general
Number
of edges
simple
general
graph,
number
of
edges
upadjacent
to
a to
quadratic
withsa
The bruteInforce
solution
for of
this
problem
is
runClique
DFS
from
every
left
vertex
which
Thethe
Maximum
problem
requires
us
nd the order
maximum
colouring
a to
graph
such
thatcan
no be
two
vertices
have
the
2 . Itcan
In simple general
the number
edges
be
up
to
a
quadratic
order
with
respect
to
the
number
of
givesgraph,
us a running
time
ofof
is
very
difficult
to
find
a
solution
(if
any)
faster
than
vertices
(i.e.
O(V
)).
This
is
not
the
case
for
planar
graph.
In
a
planar
graph,
we
vertices
in
the
set
is
directly
connected
by
an
edge.
By
reduction
size k in a graph, the set of the vertices inside the clique must be m
co
forThis
this
However,
there
is
an
important
constraint
on
the
problem.
The
vertices (i.e. O(V 2 )).
isproblem.
not
case
planar
graph.
In
a
planar
graph,
we
may
show
that
E
3V
holds
for the
V
3 byforusing
the
Eulers
formula.
Therefore,
the
number
of
edges
is
O(V
on general graph is NPhard. However, it is easy to solve this6)
given the
in
this
problem
is
planar
graph.
Wechanged
first
relabel
the
right
vertices
holds for V graph
3 by using
Eulers
formula.
the
of edges
isno
O(V
).).adjacent
Naturally,
any
algorithm
that
has
O(E)
inalways
its Therefore,
running
time
can
be
into
O(V
Computing
shortest
of acolouring
anumber
graph
such
that
two
vertices
havepat
th
Jonathan
Irvin
GUNAWAN
2
in
ascending
order
according
to
the
ycoordinate.
The
planar
properties
ensures
that
for
that has O(E) in its running
time can be
changed
into
O(V
). Computing
pathbut
in
a general
graph
using
BellmanFord
algorithm
takes
E)
(Halim
& Halim
it
only
O(V
) in
size
k inO(V
a graph,
the set
ofshortest
the 2013),
vertices
inside
thetakes
clique
must
b
2
BellmanFord algorithm takes
E) (Halim
& Halim
2013), butusing
it only
takes
) in graph
a planar
graph.
the O(V
number
of connected
components
DFS
in aO(V
general
takes
O(V Counting
+ E), b
the number of connected
components
DFS in ifa the
general
graph
takes O(V
E), but the
it only
takesofO(V
) in a
planar graph.using
Therefore,
problem
requires
us to+compute
number
connect
2
vertex v is visitable from vertex u if thereJonathan
is a path from
u to vGUNAWAN
Irvin
2 in a planar
planar graph. Therefore, ifgraph,
the problem
requires
us
to
compute
the
number
of
connected
components
even though the constraint states that V 100, 000, E 100, 000 , the stand
graph, even though the constraint
that(inV competitive
100, 000, programming,
E 100, 0002 ,we
theassume
standard
DFS
solutionoperations
still runs
under onestates
second
that
1 million
under one second (in competitive
(Halim &programming,
Halim 2013)).we assume that 1 million operations can be done in 1 second
(Halim & Halim 2013)).
95
Fig. 5. An instance of problem Traffic. In this example, the expected output is {4, 4, 0, 2},
since the top left vertex can visit 4 right vertices, the second top left vertex can2 visit 4
of O(V ). It is very dicult to nd a
right vertices, the third top left vertex cannot visit any right vertex, and the bottom left
important constraint on the problem.
vertex can visit 2 right vertices.
4.2
4.2 Graph
Bipartite Graph
Bipartite
that
graph
problems
NPhard
forthe
general
graph
but
inmatching
polynomial
if the included
graph is in
bipartite.
hat are
NPhard
graph
but time
solvable
in graph
polynomial
timesolvable
if Since
the graph
is bipartite.
Since
polynomial
time
iffor
thegeneral
graph
is are
bipartite.
Since
neral
graph
but solvable
inthat
polynomial
if
is bipartite.
bipartite
graph
and
bipartite
wastime
recently
IOI 20
4.2.1
Vertex
Cover
and
Independent
Set
(and
maximum
matching)
bipartite
graph
and
bipartite
matching
was
recently
included
in IOI
weIOI.
can W
and
bipartite
matching
recently
included
in
IOI
2015
syllabus
(Forisek
2015),
wesyllabus
can expect
I 2015
syllabus
(Forisek
2015),
wesyllabus
can
expect
was
recently
included
inwas
IOI
2015
(Forisek
2015),
we
expect
that
this
type
of can
problem
may
be2015
conceived
in (Forisek
the near 2015),
future of
that
this
typeof
ofIOI.
problem
may
be aconceived
in the
near
future
ofatIOI.
We examples.
will take a look at several examp
problem
may
be
conceived
in
the
near
future
of
IOI.
We
will
take
a
look
several
OI.
We
will
take
a
look
at
several
examples.
ived
in
the
near
future
We
will
take
look
at
several
examples.
e discussed in an earlier section, both of the MINVERTEXCOVER and MAXINDEPENDENTSET problems
4.2.1 Vertex
Independent
NPhard. However,
both of these problems are solvableJ.I.inGunawan
polynomial
time onCover
bipartiteand
graph.
By Konigs Set (a
96matching)
4.2.1
Vertex
Cover
and
Independent
Set
(and
maximum
matching)
Vertex
Cover
and
Independent
Set
(and
maximum
matching)
tr.2.1
(and
maximum
and
Independent
Set
(and
maximum
matching)
em, the size of the minimum vertex cover in As
bipartite
graph in
is equal
to the
size of
theofmaximum
bipartite
we discussed
an earlier
section,
both
the MINVERTEXCOVER
hing
(Bondy
&
Murty
1976),
and
the
size
of
the
maximum
independent
set
in
bipartite
graph
is
equal
to thein polyno
bipartite
graph
is equal
to theare
number
of MINVERTEXCOVER
the
vertices
minusofthe
size
of
the maximum
in
Assection,
we discussed
in
an earlier
section,
both
of the
andproblems
MAXINDEPENDENTSET
pro
nh an
earlier
both of
the
MINVERTEXCOVER
and
MAXINDEPENDENTSET
problems
VER
and
MAXINDEPENDENTSET
problems
of the
MINVERTEXCOVER
and
MAXINDEPENDENTSET
problems
NPhard.
However,
both
these
are solvable
ber
of theboth
vertices
minus
the
size are
ofboth
the
maximum
bipartite
Therefore,
problems
are
equivalent
bipartite
matching.
Therefore,
both
problems
are
equivalent
toboth
finding
the
size
of
the graph.
are solvable
NPhard.
However,
ofon
these
problems
are
solvable
in polynomial
time
on
bipartite
owever,
of
problems
solvable
in
polynomial
time
bipartite
graph.
By
Konigs
lynomial
time
onthese
bipartite
graph.
By
Konigs
problems
are
in
polynomial
time
bipartite
graph.
By
Konigs
theorem,
thematching.
size
ofon
the
minimum
vertex
cover
in
bipartite
graphBy
is eK
3 time. Finding the size
maximum
bipartite
which
can
bebe
solved
in
nding
the minimum
size
of size
the
maximum
bipartite
matching,
which
caninto
solved
in
)equal
time.
Finding
ofmaximum
the indepe
eisofequal
the
vertex
cover
in bipartite
graph
is cover
equal
the
size
of O(V
the ismaximum
bipartite
theorem,
the
size
the
minimum
vertex
bipartite
graph
to
the
ofsize
the
bi
to
the
of
the
maximum
bipartite
ex
cover
in
bipartite
graph
isof
equal
tomatching,
the
size
of
the
maximum
matching
(Bondy
&bipartite
Murty
1976),
and the
size size
ofthe
the
maximum
of
the
maximum
matching
in
bipartite
graph
using
HopcroftKarp
algorithm
or
Maximum
matching
in
bipartite
graph
using
HopcroftKarp
algorithm
or
MaximumFlow
algorithm
is
much
simpler
(Bondy
& Murty
1976),
and
the graph
size
of isthe
maximum
setmaximum
in bipartite
graph ismatchin
equal
yhe&size
Murty
1976),
and
theindependent
size
ofisthe
maximum
independent
set
in bipartite
graph
to
the bipartite
dependent
set
in
bipartite
graph
equal
of matching
the
maximum
setto
in the
bipartite
equal
tominus
the independent
number
of the
vertices
the
sizeisofequal
the
mumFlow
algorithm
is much
simpler
toTherefore,
solve,
asgraph.
compared
using
Edmonds
Bloslve,
asminus
compared
to
Edmonds
Blossom
algorithm
on
general
This to
is bipartite
actually
the
solution
of the
ertices
number
of using
the
vertices
minus
the
size
of
the
maximum
bipartite
matching.
Therefore,
both
problems
rtices
the
size
of problems
the
maximum
bipartite
both
problems
are
equivalent
ching.
Therefore,
both
are
equivalent
the maximum
bipartite
matching.
Therefore,
both
problems
are
tomatching.
nding
the
sizeequivalent
of
the
maximum
matching,
which
canare
beequ
sol
so
algorithm
on
general
graph.
This
is
actually
of
IOI
3the solution of the 5th subtask
3
3 som
3the
ubtask
IOI
2014
Friend.
toO(V
nding
the
size
of
the
maximum
bipartite
matching,
which
can
be
solved
in
O(V
)
time.
Finding
the
size
e solved
of matching,
theofin
maximum
bipartite
matching,
which
can
be
solved
in
O(V
)
time.
Finding
the
size
of
the
ertite
)
time.
Finding
the
size
of
which can be solved in O(V ) time.
Finding
the sizeinofbipartite
the
maximum
matching
graph using HopcroftKarp algorithm or
2014
Friend.
ingorin
bipartite
graph
using
HopcroftKarp
algorithm
orHopcroftKarp
MaximumFlow
algorithm
much
simpleralgorithm
maximum
matching
bipartite
graph
algorithm
or isMaximumFlow
algorithmonis general
much s
m
MaximumFlow
algorithm
much simpler
sing
HopcroftKarp
algorithm
orinisMaximumFlow
algorithm
is much simpler
to using
solve,
as
compared
to
using
Edmonds
Blossom
th
th
to
solve,
toalgorithm
usingThis
Edmonds
Blossom
algorithm
on general
is actually the solution
pared
to using
Edmonds
Blossom
on
general
graph.
This
is
thegraph.
solutionThis
of the
graph.
This
is as
actually
the graph.
solution
of
the
seral
Blossom
algorithm
oncompared
general
is 5actually
theofsolution
of actually
the
subtask
IOI
2014
Friend.
5th subtask
IOI 2014
Friend.
OI 2014 Friend.
4.3
Directed
Acyclic Graph
4.3. of
Directed
Acyclic
Graph
ected acyclic graph is a directed graph that does not contain any cycle. Similar to planar and bipartite graphs,
4.3acyclic
Directed Acyclic
are several graphAproblems
that aregraph
muchiseasier
to solve
if the
is a contain
directed
directed acyclic
a directed
graph
thatgraph
does not
any cycle.graph.
Similar to
4.3 Directed
Acyclic Graph
4.3 Directed
Graph
c Graph
Directed Acyclic
Graph Acyclic
hhe
G
(Vout
,all
E this
),
where
Voutifis=
= VA
and
E
=
{(u,
v)
Vout
Vthe
:ifvertices.
(u,
v)isonly
NPhard.
E}.
Then
it can
beone path
in
in
toincover
of
the
inVin
aonly
graph.
By
ahas
simple
reduction
from
Hamiltonian
this
problem
is NP
vertices
a VPath,
graph.
a vertices
simple
reduction
from
Hamiltonian
Path,
problem
m
Hamiltonian
problem
NPhard.
By
a=simple
reduction
from
Hamiltonian
Path,
this
problem
is
NPhard.
graph
a to
Hamiltonian
Path
and
ifPath,
we
only
need
Path
ifBy
and
only
we
need
one
path
cover
allthis
of
However,
this
n
bytoKonigs
Theorem
that
G
has
a
matching
of
size
m
if
and
only
if
there
exist
V

m
vertexdisjoint
graph
has
avertices.
Hamiltonian
Path
if
and
only
if
we
only
need
one
path
to
cover
all
of
the
vertices.
Howeve
amiltonian
Path
ifproblem
and
only
if
we
only
need
one
path
to
cover
all
of
the
vertices.
However,
this
ath
all
of
the
However,
this
only
if cover
weAonly
need
one
path
to
cover
all
of
the
vertices.
However,
this
problem
can
be
solved
in
polynomial
time
for
a
directed
acyclic
graph.
can be solved in polynomial time for a directed acyclic graph. For a graph
For
ssolved
that
cover
all ofacyclic
vertices
indirected
G.
for, awe
graph.
aout
graph
=
E), we
create
ainnew
problem
can
begraph.
solved
in
polynomial
time
for
a we
directed
For
a=graph
(V,
create
aph.
apolynomial
graph
Gthe
=time
(V,
E),
we
create
anew
new
me
forFor
aindirected
For
a graph
Ggraph
=
(V,G
E),
create
aG,new
graph
=
(V
Vacyclic
E (V,
),,graph.
where
Vout
Vin
=GV=and
E =we{(u,
v)
create
aacyclic
where
andE),
in
out
in
out
graph G = (V
inV=
E and
),it
V{(u,
V
=Then
Vand
E
=be
{(u,
v)by
Konigs
Vhas
V
(u, v)
E}.mThen
it
V
EV
),
V=
=
Vv)
v)
VitTheorem
: (u,
v)
E}.
Then
itmatching
can
V,out
where
V
v){(u,
E}.
Then
can
be
.out
can
be
shown
Theorem
that
=
Vin
=
and
V,Vout
where
VEin =
: (u,
v)=
by
E}.
Then
it
can
shown
Konigs
that
G
ofsize
if and
out
in
out
inV
out a
in :be
out
in
in :E(u,
ttv)
in
Konigs
by
Theorem
that
athat
of of
size
V  m vertexd
has
matching
size
has
and
only
there
exist
vertexdisjoint
vertexdisjoint
s
that
G
has
matching
of
sizeGexist
m
ifif and
only
ifif there
exist
Vif and
monly
and
only ifshown
there
exist
monly
vertexdisjoint
4.4
Miscellaneous
s aTheorem
matching
of size
mVifa and
ifof
there
V
 matching
m
vertexdisjoint
paths
cover
all
themvertices
in
G.if there existpaths
that
cover all
all of
of the
the vertices in
that
in G..
vertices
in cover
G.
.all of the paths
4.4.1 Special case of CNFSAT problem
4.4
Miscellaneous
will
use Google
Code Jam 4.4
2008 Round
1A Milkshake
for this example. This problem requires the
Miscellaneous
4.4problem
Miscellaneous
ous
4.4
Miscellaneous
4.4. Miscellaneous
4.4.1
Special
case with
of CNFSAT
estant to nd a solution with the minimum number of true variables that satisfy
a CNFSAT
problem
up
4.4.1
Special
case
of
CNFSAT
problem
4.4.1
Special
case
of
CNFSAT
problem
SAT
problem
Special
case of CNFSAT problem
We will
use Google Code Jam 2008 Round 1A Milkshake problem fo
4.4.1. Special Case of CNFSAT
Problem
gle
Code
Jam
2008
Round
1A
Milkshake
problem
for
example.
Thiswith
problem
requires
We
will
use
Google
Code
Jam
2008
Round
1Athis
problem
for
example.
This of
problem
requir
m
for1A
this
example.
requires
und
Milkshake
problem
this
example.
This
requires
the
contestant
toMilkshake
nd
aMilkshake
solution
thethis
minimum
number
true variable
than
Irvin
GUNAWAN
WeThis
will problem
use for
Google
Code the
Jam
2008problem
Round
1A
problem
for
this the
example.
contestant
to
nd
a problem
solution
with
the
minimum
number
of atrue
variables
that satisfy
a CNFSAT
problem w
dinimum
a solution
withofThis
the
minimum
number
ofthetrue
variables
satisfy
CNFSAT
withnumber
up
ables
that
satisfy
a true
CNFSAT
up
number
variables
that satisfy
a CNFSAT
problem
with
upwith
problem
requires
contestant
tothat
find
a solution
theproblem
minimum
of
In Google Code Jam, contestants are given 8 minutes to produce the output upon downloading the input.
97
5. Conclusion
In conclusion, we can use a wellknown reduction technique to prove that a problem that
we are currently attempting to solve is impossible (or at least it is very hard such that no
people has been able to solve it for more than 40 years). In competitive programming
(including IOI), understanding this technique is essential so that we will not be stuck at
trying to solve an impossible problem, thus prompting us to find another way to solve
the problem. To prove that a problem is NPhard, it is good to know as many NPhard
problems as possible, so that we can reduce from any one of the problems that we know
to the new problem. Some of the classic NPhard problems include 3SAT, Vertex Cover,
Independent Set, and Subset Sum. After realizing that the problem is NPhard, we must
be able to find the special case that makes the problem solvable. We must be able to find
a special property that breaks the reduction proof. Having a lot of practice on these kind
of problems will help us to familiarize with the possibilities of a special case. Some of
the common special cases include planar, bipartite, and directed acyclic graph.
References
ACM ICPC World Finals 2010 Problem Statement (n.d.). Available via internet:
http://icpc.baylor.edu/download/worldfinals/problems/2010WorldFinalProblemSet.pdf
ACM ICPC World Finals 2010 Solutions (n.d.). Available via internet:
http://www.csc.kth.se/~austrin/icpc/finals2010solutions.pdf
Bondy, J.A., Murty, U. S. R. (1976). Graph Theory with Applications, Vol. 290, London: Macmillan.
CEOI 2011 Solutions (n.d.). Available via internet:
http://ceoi.inf.elte.hu/probarch/11/ceoi2011booklet.pdf
CEOI 2011. Traffic Problem (n.d.), available via internet:
http://ceoi.inf.elte.hu/probarch/11/trazad.pdf
Cook, S.A. (1971). The complexity of theoremproving procedures. In: Proceedings of the Third Annual ACM
Symposium on Theory of Computing. ACM, 151158.
Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C. (2009). Introduction to Algorithms (3rd ed.). MIT Press.
Foriek, M. (2015). International olympiad in informatics 2015 syllabus. Available via internet:
https://people.ksp.sk/~misof/ioisyllabus/ioisyllabus.pdf
Gonthier, G. (2005). A computerchecked proof of the four colour theorem. Available via internet:
http://research.microsoft.com/enus/people/gonthier/4colproof.pdf
Google Code Jam 2008 Round 1A, Milkshake Problem (n.d.). Available via internet:
https://code.google.com/codejam/contest/32016/dashboard#s=p1
Google Code Jam 2008 Round 1A, Milkshake solution (n.d.). Available via internet:
https://code.google.com/codejam/contest/32016/dashboard#s=a&a=1
Halim, S., Halim, F. (2013). Competitve Programming 3. lulu.com
IOI 2008, Island Problem (n.d.). Available via internet:
http://www.ioinformatics.org/locations/ioi08/contest/day1/islands.pdf
IOI 2014, Friend Problem (n.d.). Available via internet:
http://www.ioinformatics.org/locations/ioi14/contest/day2/friend/friend.pdf
West, D. B. etal. (2001). Introduction to Graph Theory, Vol. 2. Prentice hall Upper Saddle River.
98
J.I. Gunawan
99
Homo Informaticus
Why Computer Science Fundamentals are
an Unavoidable Part of Human Culture
and How to Teach Them
Juraj HROMKOVI
Department of Computer Science, ETH Zrich
email: juraj.hromkovic@inf.ethz.ch
Abstract. The goal of this article is on one hand to introduce informatics as a scientific discipline
in the general context of science and to outline its relationships especially to mathematics and engineering, and on the other hand to propose a way how to integrate computer science into school
education.
Keywords: teaching, computer science, mathematics.
1. Introduction
The development of human society is mainly determined by the ability to derive knowledge and to find efficient ways of applying it. Let us explain this claim more carefully.
Human beings sample experiences by observations and experiments and use them to
generate knowledge by combining their experience with logical thinking. The derived
knowledge is used to develop procedures in order to reach concrete goals. A crucial point
in our considerations is that to use such procedures one usually does not need to fully
understand the knowledge used to obtain such procedures. To an even higher extent, one
does not need to understand the way in which this knowledge was derived and verified.
Let us illustrate this on a simple example.
The famous theorem of Pythagoras claims c2 = a2 + b2 in any right triangle, where
c is the length of the longest side (hypotenuse). This theorem was used to fix the right
angles when building houses and temples in the classical antiquity. The workers only
needed to build a triangle of sizes 5 units, 4 units, and 3 units in order to get a right
angle, and for sure they did not need to understand how the theorem of Pythago
100
J. Hromkovi
ras was discovered and how it was proven. Hence, to successfully apply the derived
knowledge, one did not need to master the high qualification of an investigator. In this
way, scientists changed and still change society and became a crucial factor in human
development.
Computer science was created as a natural step forward in the above described development, when the following two conditions were satisfied:
1. Using the exact language of mathematics, one was able to discover and describe
procedures in such a way that no intellect was needed to apply them. Executing
them step by step, everything was unambiguous, and no educated or trained person was needed to find the right interpretation of the particular instructions of the
procedure executed.
2. The technology enabling to execute the discovered procedures by machines was
developed, and languages providing the opportunity to explain universal machines what they have to do were designed.
In this context, we speak about automation. We let the machine execute not only
physical work, but also such human work considered as intellectual work in the past.
This is the reason why computer science is a mixture of mathematics and engineering.
On the one hand, one uses the concepts, methods, and the language of mathematics in order to understand the considered entities and their relations so exactly that
algorithms as unambiguously interpretable procedures can be developed in order to
solve a variety of problems everywhere in science, technology, and everyday life. Here,
mathematics is the instrument that has to be mastered together with the specific area in
which one tries to solve problems.
On the other hand, developing and improving the enabling technology is mostly
engineering. This is not only about hardware, but especially about software enabling
us to conveniently communicate with computers in highlevel programming languages.
We see that computer science is a part of the natural development of science, and
it became a discipline that is crucial for the performance of the human society. This
contextual view is important when thinking about what computer science actual is, and
how to teach computer science in schools. We are asked not to teach specific isolated
facts, methods, and other final products of scientific work, but the way how they were
discovered, i. e., the paths from the motivation coming from the general context of science to the final products of the research work and engineering. As in its fundamentals
computer science is very strongly related to mathematics as its basic research instrument, we start with the question What is mathematics and how to teach it? in the
next section, and use the derived point of view in the final section to propose the way
of teaching computer science in schools. Before the final section, however, we discuss
engineering as a missing subject in schools in Section 3. Again, we use this discussion
in order to show in the final section how teaching computer science can contribute to
understanding some basic concepts of engineering and how it integrates them in the
school curriculum.
101
102
J. Hromkovi
103
the education in mathematics for everybody. Based on this, we recommend to adopt the
following concepts:
1. Focus more on the genesis of the fundamental notions (concepts) of mathematics.
To define them took centuries, to prove most of the theorems took a few years.
Each new concept enabled to investigate so many things that no single discovery
can compete with introducing a fundamental concept. The strengthening of mathematics as a research instrument is the main job of mathematics, and deriving
new concepts (not necessarily on the axiomatic level) in mathematics provides
the best, true picture of its nature. Without this, nobody can really understand its
role and usefulness. And only if one understands the genesis of mathematics as
the development of a language of science and as a research instrument, one can be
able to apply it regularly to all areas of our life. Teaching mathematics this way
can completely change the behaviour of the members of our society. Instead of
memorizing and sampling facts provided, one would start to verify the degree of
trustability of claims sold as knowledge and to understand to which extent and
under which conditions one is allowed to take them seriously.
2. Concrete examples first, abstraction as a final discovery. One first has to touch
concrete problem instances and objects in order to get some intuition about their
properties. Then, one can formalize her or his intuition into a formal concept.
One has to follow the natural way of discovering that usually goes from concrete
to abstract. To sell methods and theorems as final products is as poor as teaching
manuals for washing machines or Microsoft office instead of teaching discoveries of physics, mechanics, and computer science that enabled to develop these
products.
3. Teach algorithmics instead of training calculation methods. Pupils learn in schools
to multiply arbitrarily large integers in decimal representations, to solve quadratic
equations and systems of linear equations, or to analyze functions, etc. In all cases, most pupils learn to apply given methods, but most of them do not understand
why they work. It is more of a challenging memorizing than a deep understanding
of the nature of the algorithms used. One has to start to introduce problems instead
of presenting methods solving them, and ask the pupils and students to solve concrete problem instances first and finally to discover an algorithm as a robust procedure that is able to solve any of the infinitely many concrete problem instances
of the given problem. Discovering algorithms as wellfunctioning calculation procedures offers another quality of education in mathematics than executing a given
calculation method, which any pocket calculator can do faster and more reliable.
Teach programming as the art of exactly describing the methods discovered in an
unambiguously interpretable way in the language of the machines, and strengthen
the ability of exact communication this way.
4. Teach the principles of correct argumentation. Teach the notions of implication
and quantifiers, and train direct and indirect proofs. Do not believe that the pupils
in high schools cannot learn to verify and to derive simple proofs. They did not
manage this in the past, because there was no effort made to teach proving claims,
or most effort in this direction was done in a wrong way.
104
J. Hromkovi
5. Guarantee the opportunity to the pupils to deal with the subjects as many time as
needed at an individual speed. Mathematics is one of the sciences that needs a
large number of iterative touchings of particular topics until one is allowed to say
Eureka, and gets a reasonable understanding of what it is about. The trouble is
that no teacher can assure this by herself or himself for everybody in the class.
Another problem is that most textbooks of mathematics are good collections of
exercises, but explanations are written more for teachers than for pupils. One way
out is to change the style of the textbooks. The textbooks should be written in
such a way that pupils and students would be able to learn from them by their own
with a minimal support from outside. Partitioning the discoveries into a number
of small, natural steps written in the language mastered by the pupils at the corresponding age, and regularly giving the opportunity to verify whether one understands the topic up to now properly are some of the basic principles used to create
good textbooks for mathematics.
Finally, one can ask how to reach the new teaching style for mathematics described
above. For sure, one cannot ask the highschool teachers to make this change without
showing them how to do this in detail. One also cannot ask educationalists, who do not
have a sufficiently deep contextual knowledge of mathematics to master these changes.
The movement has to start at the universities, where the teaching style has to change
first. In order to speed up this process in Switzerland, in our department at ETH Zrich
we develop new textbooks for teaching different topics of mathematics and computer
science for all school levels. Our experiments prove that mathematics can become one
of the most favorite subjects of pupils and students if taught in the way described
above. Students can successfully master topics that were considered to be too hard for
them before, and the marks in mathematics can be significantly higher than the average
marks over all topics.
For me, it is not a question of whether the proposed evolution of the education in
mathematics will come. It is only the question of the time at which particular countries
will need to adopt it. Since this is a service for the future generation, the earlier the
better.
105
In todays schools, we find almost nothing about the concept of iterative specifying,
testing, modifying, and improving the product of our work, let alone about fundamental
constructive ways of creating original products. But this is fundamental to human activities since the beginning of time. The current school systems ignore this fact to a high
extent and are more about teaching to memorize than teaching to work in a creative
way. One can explain this educational misconception by the fact that, in contrast to
basic scientific models of reality, the engineering work is heavily dependent on experience that is often hard to formalize and thus to teach. The creative work of engineers
as human experts cannot be described by an algorithm (a method). However, this must
not be a reason to remove engineering from education, because students also have to
learn to build their own experience over a longer period of time in order to become an
expert for a special area.
The crucial fact we want to point out is that computer science mastered to formalize
several basic concepts of engineering and made them available to our schools as a result.
Teaching computer science is a chance to introduce engineering as a highly creative,
constructive activity to our educational system.
Let us consider some concrete illustrations. Probably the most fundamental concept of technical sciences is modularity. One builds some simple units with clear and
well verifiable functionalities and calls them modules. Then one uses these modules
as fundamental building blocks to construct more complex systems that are again
considered basic modules for constructing even more complex systems. There is no
upper bound on the growth of the complexity of systems built in such a way. Unbelievably many human activities can be described by this modular concept. This
includes learning. Ones learns some simple facts and methods and their applications
in a restricted framework. After that, one masters them perfectly in such a way that
one can use them as elementary operations in attacking more complex tasks. All spiral
curricula run in a welldesigned modular way. Thinking in a modular way when trying to reach given goals is the most fundamental instrument of creative human work.
And it does not matter whether you apply it topdown or bottomup. If one applies a
topdown approach, then everything is clear and one designs only a transparent and
wellverifiable plan for constructive work. More typical is the bottomup approach
where one builds more and more complex modules without knowing what the final
product will be about.
Programming is an excellent instrument to teach modularity. Writing programs to
automate solving different tasks provides modules for attacking much more complex
tasks. Children of age between 10 and 12 are able to put five loops into each other without being disturbed by or even observing the complexity of their final product due to
modularity. One simple program containing a loop gets a name and so becomes a new
instruction. This instruction is used in the body of another loop that also becomes a new
instruction used in another loop, etc. Here, one can train both, the topdown approach as
well as bottomup approaches devoted to openend tasks. To practice the ability to bring
a clear structure into complex processes is at least as important as any of the fundamental concepts of sciences or humanities contained in the school curricula.
106
J. Hromkovi
Another important concept is teaching to test or verify products of our work. Typically, children verify their own products by asking teachers or adults to tell them whether
their work resulted in what they were asked to reach. But this way, they cannot sufficiently build their selfconfidence because they need a strong dependency on their supervisor. They have to learn to trust their solutions by being taught to verify the products of
their work by themselves. Programming is again a wonderful instrument for this purpose
using the platform or editor that fits the educational requirements. One can learn to test
the functionality of programs by running them on several data sets as well as by the verification approach based on a transparent structuring of the program into small modules
whose correct behavior can by easily verified.
In general, constructive engineering work within the educational system changes the
behavior of young people in an essential way. They move from the role of customers
searching for products with some desired property to the role of creative inventors for
designing and developing products with new, original functionalities. The neverending
story of improving any human products with no limits on what can be approached in the
future would be the most important, great consequence of embedding the creative way
of thinking of engineers into school systems.
107
8. To try to sell computer science as a joy much easier than mathematics and physics
by avoiding any depth and thus a spiral curriculum, and instead presenting one
simple application after the other.
9. Going too much into technical details about concrete programming languages,
software systems, or hardware.
While 1, 2, and 4 have been the main reasons for destroying the image of computer
science in the society in the past, currently the points 7 and 8 are the major danger for
establishing computer science as a school subject.
After listing what we are not allowed to do, it is now time to switch to positive
recommendations and conceptual work. We do not want to make a proposal for the
content of a computer science curriculum, because our goal is not to go too much into
detail, and because, for sure, there are various possibilities for good implementations of
the computer science subject in schools. What we try here is to recommend a strategy
and principles that are useful for designing a computer science curriculum that can be
accepted as a fundamental part of education in its generality for everybody, and that essentially contributes to:
1. The understanding of our world (in this case with the focus on the artificial world
created by humans).
2. Developing our way of thinking in a dimension that cannot be compensated by
teaching other school subjects.
3. Providing knowledge that is useful and sometimes even expected as prior knowledge for the study of a variety of specialized scientific disciplines later (university
studies, etc.).
As a byproduct, we have to aim to improve teaching overall, especially by strengthening the subjects mathematics and natural sciences. We already presented the basic
strategy how to design a computer science curriculum in Section 2 about mathematics.
We have to follow the genesis of computer science and think about motivations and
fundamental concepts introduced and discovered by computer scientists from the point
of view of science as a whole. For sure, we have to think about or even discover which
concepts are available to which extent in which age, and to follow all the ideas for creating good teaching materials as presented in Section 2. Let us be more concrete and
present a few examples.
One can decide to introduce programming at the age between 8 and 14. The first
step is to deal with abstractions that enable us to unambiguously describe the problem
instances. Then we teach to sample experience by trying to find solutions to concrete,
special problem instances, whose size and complexity may grow with growing experience. After some time, one can develop a strategy that works successfully for a small
collection of problem instances that we subsequently call a problem. Having a solution
strategy, one has to learn to communicate it, i. e., to unambiguously describe it for anybody else. After that, we are allowed to start teaching proper programming by describing
our strategy as a program in a suitable programming language. We are not allowed to
teach the list of all instructions (fundamental words) of a programming language. We
have to start with very few (10 to 15) fundamental instructions, and use modularity to
108
J. Hromkovi
create new words (instructions) in order to make our communication with the computer
more convenient. After writing programs, we let them run in order to verify their correct functionality and learn to correct, improve, and modify our programs in order to get
a final product with which we are satisfied. Let us list some of the added values when
teaching the introduction to programming in the way described above:
1. Training and strengthening the abstraction in representing real situations by drawing graphs, writing lists or tables with different kinds of elements.
2. Contributing to teaching mathematics by searching for a solving strategy, instead
of simply learning a method as a given product of the work of others.
3. Strengthening the ability to express matters and procedures in an exact way, and
so to improve the way used to communicate.
4. Recognizing that a language is not a given final product of human work, but that
any language is continuously developed, and that in case of a programming language one can develop the language on her or his own with respect to her or his
personal demand.
5. Defining new instructions by describing the meaning of the new words by subprograms, one learns the principle of a modular design that is common and fundamental in engineering.
6. Introducing the concepts of testing, verifying, modifying, and improving is the
first contact with the creative, constructive work of engineers.
A really good teaching sequence for introductory programming can be created if one
focuses on the above listed added values and not on technical details of programming
languages and other software used or on a specific class of tasks.
Another nice example is teaching cryptography. Cryptography can be viewed as
the history of developing the notion secure cryptosystem. One can start with the
historical examples in order to introduce the basic terms decryption, encryption, key,
and cryptosystem with a lot of creative work by designing and breaking new, own
cryptosystems. After defining the concept of security by Kerckhoff, one can build
the bridge to probability theory. The concept of probability was used to design new
cryptosystems and later to break them. One can wonderfully understand the importance and the usefulness of the concept of probability studying the history of secret
communication in this way. Then one can introduce the formal mathematical definition of absolutely secure cryptosystems with respect to the concept of probability, and
recognize that such system cannot be built for practical purposes. Finally, the concept
of computational complexity offering publickey cryptosystems is the way out, leading
to the recent ecommerce.
What we try to repeatedly present as the key strategy is to follow the history of the
discoveries of particular concepts, methods, and ideas, and not to try to sell finalized
products of science. The creative work is the most (and may be even the only really)
exciting part of the study. Let us teach creativity by repeatedly discovering things that
were already discovered, up to the point where one is able to discover something completely new. Forget about teaching facts, teach how to verify the trustability of claims
made by others. We are lucky, because we are allowed to create a curriculum for a
109
completely new subject. We can implement principles, which the other subjects still
did not recognize, and so contribute to the evolution of the system of education. For
those who would like to see detailed implementations of the design principles presented
above, we recommend to following textbooks from our production (Bckenhauer and
Hromkovi, 2013; Freiermuth et al., 2014; Hromkovi, 2011; Hromkovi, 2014) or
the book Algorithmic Adventures from Knowledge to Magic (Hromkovi, 2008;
Hromkovi, 2009).
References
Bckenhauer, H.J., Hromkovi, J. (2013). Formale Sprachen. Springer Vieweg.
Freiermuth, K., Hromkovi, J., Keller, L., Steffen, B. (2014). Einfhrung in die Kryptologie. 2nd Edition.
Springer Vieweg.
Hromkovi, J. (2011). Berechenbarkeit. Vieweg+Teubner.
Hromkovi, J. (2008). Sieben Wunder der Informatik Eine Reise an die Grenze des Machbaren.
Vieweg+Teubner.
Hromkovi, J. (2009). Algorithmic Adventures From Knowledge to Magic. Springer.
Hromkovi, J. (2014). Einfhrung in die Programmierung mit LOGO. 3rd Edition. Springer Vieweg.
J. Hromkovi is professor of informatics with a special added focus on computer science education at ETH Zurich. He is author of
about 15 books published in 6 languages (English, German, Russian,
Spanish, Japanese, and Slovak) and about 200 research articles. He is
member of Academia Europaea and the Slovak Academic Society.
111
1. Introduction
Algorithmic thinking constitutes one of the core concepts of computer science. It has
proven a versatile and indispensable tool for problem solving and found applications far
beyond science. Hence, sustainable computer science education should be built upon
algorithmic thinking as its primary objective, thus unfolding benefits for a broad and
general education. However, how do we bring algorithmic thinking to computer science
education? In this paper, we identify a number of principles that we want to deliver to
students at different levels. As the main contribution, we describe concrete examples of
how to teach these paradigms, which have been proven successful in the past.
Our work is part of ubiquitous efforts towards establishing sustainable computer science
in K12 education. Particularly noteworthy and inspiring are CS unplugged approaches
as proposed by Bell etal. or Gallenbacher, which do completely away with computers
and solely focus on the underlying algorithmic principles (Bell et al., 2012; Gallenbacher,
2008). By incorporating such ideas into programming education, we effectively combine
the strengths of the two approaches, resulting in a truly sustainable education.
112
J. Hromkovi et al.
1.2. Objectives
Computer science is a vast field with algorithmic thinking at its core. Our curricula
hence focus on the study of algorithms and its various aspects. Our approach comprises
three major aspects of algorithmic thinking, as described in the following paragraphs:
the notion of the programming language as a formal language to express algorithms, abstraction and automation as central problem solving strategies, and the limits of practical
computability as a motivation for improving existing algorithms. More on the authors
goals, motivation, and approaches can be found in a complementing paper (Hromkovi
etal., 2016).
Concept of a Formal Language. Students are introduced to programming as a means to
convey instructions to a machine in our case the turtle. The initial set of instructions is
strongly limited and restricted to basic movements such as moving forward and turning.
Each instruction has a clearly defined syntax and semantics, avoiding any ambiguity.
At first, then, programming is the activity of writing sequences of such instructions, encoding graphical shapes. From our perspective, this is to say that students use a formal
language to combine words to sentences. Even though each valid sentence conveys the
information of a graphical shape, not every sentence makes sense in the context of the
interpretation of the resulting shape.
The initial vocabulary given to the students is not adequate to encode more complex
shapes in a humanaccessible form. Students are early required to extend the vocabulary
by defining new words, i. e., by defining subroutines. In the context of the turtle, this can
113
Fig. 1. By parametrizing programs, we gradually gain more versatile algorithms and procedures. Drawing a square of fixed size is the first step towards drawing arbitrary polygons of
various sizes (above). Likewise, loops allow us to build ever more complex and larger programs out of simple and small parts (below).
be beautifully explained as teaching the turtle new words (Papert, 1993). The semantics of the new words is expressed algorithmically as a sentence over an already existing
vocabulary. Think, for instance, of a house consisting of a triangle and a square. Both
the triangle and the square themselves might be expressed as sequences of forward and
turninginstructions.
Hence, our objective is to provide students with a simple yet expandable base of
instructions, the means to combine these instructions to sentences, and to define new
words with associated unambiguous semantics. This way, the students are exposed to
the concepts of modularization, formal languages, and expressing semantics in algorithmic form.
Abstraction and Automation. Programming is, of course, much more than combining
instructions to form programs. Some of the most essential key concepts are abstraction
and automation. Modularization, for instance, only unfolds its full potential in combination with parameters. Having a dedicated instruction to draw a square, say, helps to
clarify the intent of a program. Allowing that very same instruction to draw squares of
various sizes makes it versatile and open to applications beyond its initial conception.
Further abstraction could even introduce a second parameter to pertain to the number
of vertices to draw, resulting in one instruction capable of drawing all regular polygons
(see Fig. 1).
Abstraction itself also requires the concept of automation. Even drawing a regular
polygon with a given number of vertices is a tedious task without the notion of a loop.
For the step to an abstract instruction encompassing all polygons, the loop becomes a necessity. Once this level of automation is mastered, students are introduced to loops with
variations, allowing for figures such as spirals where even the parameter automatically
varies (see Fig. 1).
Automation and abstraction are not just core concepts of programming but of computer science and algorithmic thinking in a much wider sense. Expressed in the context
of problem solving, abstraction corresponds to the question Can we adapt an already
known or universally available strategy to solve the problem at hand? Once we know
how to solve a single instance, we then employ the concept of automation to apply our
solution to a large set of instances.
114
J. Hromkovi et al.
115
instructions for a predefined number of times. More precisely, the current vocabulary of
the turtle comprises the following instructions as well as their abbreviations: forward
(fd), back (bk), left (lt), right (rt), clearscreen (cs), penup (pu), pendown
(pd), and repeat. Furthermore, the students are already used to giving their programs
names and to reusing available programs as subprograms within main programs in an
elementary way. In subsequent activities, they learn how to develop a table that consists
of rows of identical squares in a proper modular way.
To reinforce the concept of modular development, the students are now challenged
to write a program for drawing a small town, which consists of streets with identical
houses. While the program for drawing a house is already available in the booklet, the
students are expected to consequently apply the approach they intensively practiced.
They are therefore expected to:
Identify the next shape or pattern they can systematically reuse.
Write a sequence of instructions for drawing it.
Give this subprogram a name.
Test and iteratively improve the code until the solution meets the assignment.
Afterwards, the students should reflect on how to adjust the position of the turtle in
order to draw the pattern by simply reusing the program they developed above, to test
and to iteratively improve their approach, and to finally integrate the two modules of
their solution. In a following step, this new main program can be reused as a subprogram in other main programs of increased complexity. More specifically, the students are
given the program shown in Listing 1.1 accompanied by the following exercise, which
asks them to study the effects of each command in detail.
Exercise. Where does the turtle start drawing the house? Think about the path the
turtle follows when drawing the house using the program HOUSE. Where is the
turtle located at the end of the execution? Draw the image and describe the effect
of each command.
Next, they are told how to design a program HOUSEROW (Listing 1.2) that uses HOUSE
as a subprogram. Here, the most difficult task is to position the turtle in such a way that,
after each iteration, the new house is drawn at the correct coordinates.
Listing 1.1: Drawing a house using a simple repeatloop.
to HOUSE
rt 90
repeat 4 [fd 50 rt 90]
lt 60 fd 50 rt 120 fd 50 lt 150
end
Listing 1.2: Drawing a row of houses.
to HOUSEROW
repeat 5 [HOUSE rt 90 pu fd 50 lt 90 pd]
end
116
J. Hromkovi et al.
A small
townthat
that consists
of 15
Fig. 2:Fig.
A 2.small
town
consists
ofhouses.
15 houses.
At this
theare
students
already
how approach
to move the
turtletoforward
and
Finally,
the point,
students
asked to
use theknow
modular
in order
draw the
town
a straight
line,This
howway,
to rotate
it as well
howtoto
iterate
a
thatbackward
consists ofon
multiple
streets.
the students
learnashow
extend
theover
language
sequence
of instructions
a predened
number
of times.
precisely,
the is
of the
computer
step by stepfor
with
more complex
programs.
TheMore
crucial
observation
vocabulary
of the
turtle comprises
the subprograms.
following instructions as well as
thatcurrent
the overall
complexity
is hidden
in the smaller
their abbreviation: forward (fd), back (bk), left (lt), right (rt), clearscreen
(cs),
penup (pu),
pendown
(pd),would
and repeat.
Furthermore,
the students
are by
Exercise.
At this
point, we
like to extend
the complex
of buildings
already
used
to
giving
their
programs
names
and
to
reusing
available
programs
additional streets. Use the program HOUSEROW as a building block to draw the
as subprograms within main programs in an elementary way. In subsequent
image shown in Fig. 2.
activities, they learn how to develop a table that consists of rows of identical
Hint:inAfter
the completion
of a row, the turtle has to be moved to the correct posisquares
a proper
modular way.
To reinforce
thenext
concept
tion
to build the
street.of modular development, the students are now
challenged to write a program for drawing a small town, which consists of streets
Modular
development
offersthe
a didactically
creative
tasks. In
with identical
houses. While
program forappealing
drawing aplatform
house is for
already
available
in the
booklet,exercises,
the students
are expected
tothat
consequently
thesuch
approach
the two
following
the students
observe
even smallapply
changes
as adding
they intensively
are houses
therefore
expected
a window,
a door, orpracticed.
a chimneyThey
to their
may
have a to:
considerable impact on the
overall
outcomethe
of the
streets
townthey
theycan
are systematically
designing.
identify
next
shapeand
or the
pattern
reuse,
BASE. Write two programs to draw the two building blocks. Combine those proAfterwards,
thea new
students
should
reectthat
on how
to aadjust
grams
to form
program
HOUSE1
draws
house.the position of the
turtle in order to draw the pattern by simply reusing the program they developed
above,
to testThe
andhouses
to iteratively
improve
their
andtotobenally
integrate
Exercise.
in Listing
1.1 are
veryapproach,
simple. Try
creative
and come
the up
two
modules
of
their
solution.
In
a
following
step,
this
new
main
with a new design for a house. Use your house to build an entireprogram
complex of
can be reused as a subprogram in other main programs of increased complexity.
buildings.
More specically, the students are given the program shown in Listing 1.1
accompanied
by thethat
following
which is
asks
them to study
the eects
of
The
students learn
modularexercise,
development
a systematic
and efficient
problem
each command in detail.
solving strategy. Moreover, they experience that subsequent changes in a basic module
of a properly developed complex program require no or very limited additional program5
ming effort.
117
left(90 + 5)
repeat 27:
forward(RADIUS * 3.1416 * 2 / 36)
left(10)
left(90  5)
118
J. Hromkovi et al.
repeat 27:
left(5)
forward(RADIUS * 3.1416 * 2 / 36)
left(5)
Listing 1.6: Starting the circumference not at a vertex but at the center of an edge instead.
repeat 27:
forward(RADIUS * 3.15 / 36)
left(10)
forward(RADIUS * 3.15 / 36)
Finally, an alternative solution is to have the radius meet the circumference not at a
vertex but at the center point of an edge. In this case, the radius does meet the circumference perpendicularly. The resulting code, again, has a very symmetrical form (Listing
1.6). Yet the ratio between radius and circumference now differs and requires to change
the used approximation of the value of .
119
to QUAD :WIDTH
repeat 4 [fd :WIDTH rt 90]
end
Listing 1.8: Testing whether a given number is prime.
to PRIME :NUM
ht
make "IT 2
make "ISPRIME 1
while [:IT<:NUM] [
make "RES mod :NUM :IT
if :RES=0 [make "ISPRIME 0] []
make "IT :IT+1
]
of the lecture. After that, an advanced booklet is supplied that is specifically designed for
this class (Bckenhauer etal., 2015a). As part of this booklet, more involved concepts
such as variables, conditional execution, and whileloops are introduced. The students
are then given three projects, which consolidate what they have learned so far by designing small programs to solve specific tasks (Bckenhauer etal., 2015b). The lecture is
accompanied by exercise classes in which the students are asked to present and explain
their solutions to a tutor.
As a first step towards the mathematical analysis of algorithms, we give the students
the following project. The examples are taken from the project booklet (Bckenhauer
etal., 2015b) and the corresponding lecture notes. The goal is to show the students the
idea of how to mathematically analyze how long a program will run depending on the
input size. A typical example that does not need anything beyond high school mathematics is to test whether a given number is prime. Logo is especially suited to visualize the
distribution of (small) prime numbers without much overhead.
The first component is a program called QUAD (Listing 1.7) that draws a square, and
which essentially consists of a simple loop, which the students already know from previous lessons. The size of the square is determined by the value of the parameter :WIDTH.
Next, we can write a program that tests whether a given input is a prime number.
This is done in the most straightforward fashion, i. e., by testing whether there is smaller
number (except 1) that divides it. Depending on the result, either a red or black square is
drawn on the screen using the instruction setpencolor (setpc). Before that, the turtle
is hidden with the instruction hideturtle (ht). The corresponding algorithm PRIME
is shown in Listing 1.8.
The students can easily follow the steps and try out different inputs. As a next step,
we ask them to carefully check corner cases, and give them the following exercise.
120
J. Hromkovi et al.
Exercise. PRIME does not yet work correctly on all inputs as the value of :IT is
initially set to 2. However, we know that 1 is by definition not a prime number.
Thus, PRIME 1 creates an incorrect output. Extend the program such that a black
square is drawn when the input is 1. Moreover, an error message should be output
if 0 or a negative number is given.
Once the students familiarized themselves with the algorithm, we discuss its running
time. It is obvious that the time grows with larger inputs, and this seems to be unavoidable on an intuitive level. Furthermore, it is easy to see that the running time directly
depends on how often the body of the whileloop has been executed. We therefore agree
on counting the number of these executions and neglect how many instructions are executed with each iteration. The above trivial attempt needs roughly 2 iterations for inputs
of length (hence, is the number of bits used to represent the input number). Now we
show how to improve this running time using a little bit of math. The following exercise
is wellsuited to be presented to the students as part of the lecture.
Exercise. We can now make our algorithm PRIME faster (more efficient) by
having it execute the whileloop less often. To this end, we make use of the
following idea.
Suppose the input is not a prime number. Then, by the definition of a prime
number, there is a number , which is neither 1 nor , that divides without
remainder. But from this it also follows that there is a second number , which
is also neither 1 nor , that also divides without any remainder. An important
point is that one of these two numbers is not larger than the square root of.
If, e. g., is larger than , then has to be smaller, since otherwise were
larger than .
We want to use this observation to improve PRIME. Write an algorithm PRIME2
which works exactly as PRIME, but in which the whileloop is modified such that
the variable :IT does not take the values of all numbers smaller than :NUM, but
only those that are smaller than or equal to :NUM .
The students are asked to verify the speedup by trying different inputs. Good candidate inputs to observe the increase in speed of course depend on the computer used.
Moreover, the students can try to make a simple running time analysis of PRIME2 themselves, which leads to the result that the loop is now executed at most (roughly) 1.41
times for inputs of length .
The above considerations give rise to another question, namely in which kind of analysis we are interested. To this end, the algorithm is modified such that the whileloop
is left as soon as a divisor of the input is found. The resulting algorithm obviously still
works correctly, but is it faster? Indeed, if the input is, say, an even number, the running
time of the new algorithm is a lot better. However, if the input is prime, both algorithms
take the same time. This is exactly the difference between a best case and a worst case
analysis of the algorithms running time.
Now we can follow the modular building of algorithms (see Section 2) and use PRIME2 as a building block to visualize the distribution of small prime numbers. More
precisely, the algorithm PRIMES shown in Listing 1.9 uses PRIME2 as a subprogram to
121
Fig. 5. The distribution of prime numbers between 1 and 26. Instead of red and black
Fig. 2: The
distribution ofsquares,
primewenumbers
between 1 and 26. Instead of red and
use filled and unfilled ones.
black squares, we use lled and unlled ones.
However,
if the input
to PRIMES
:MAX is prime, both algorithms take the same time. This is exactly
the dierence
a best
case
pu lt between
90 fd 300
rt 90
pdand a worst case analysis of the algorithms
runningmake
time."TEST 1
Nowrepeat
we can :MAX
follow[the modular building of algorithms (see Section 2) and use
pu
rt
90 fd 10 lt 90 pd
PRIME2 as a building
block to visualize the distribution of small prime numbers.
PRIME2 :TEST
More precisely,
the
algorithm
make "TEST :TEST+1 PRIMES shown in Listing 1.9 uses PRIME2 as a
subprogram
to visualize the appearances of prime numbers among the rst :MAX
]
endnumbers.
natural
Listing 1.10: Visualizing primes more nicely.
PRIME2
:TEST
pu
rt 90
fd 10 lt 90 pd
make "REST
mod :TEST :ROW
PRIME2
: TEST
if :REST
= 0 :[TEST +1
make
" TEST
pu lt 90 fd :ROW*10 lt 90 fd 10 rt 180 pd
]
] [ ]
end
make "TEST :TEST+1
]
end
The result of executing PRIMES 26 is shown in Figure 5. Next, we can improve
the
appearance
by having
the squares
multiple
rows
(Listing
1.10). To
visualize
the appearances
of prime
numbersdrawn
amonginthe
first :MAX
natural
numbers.
this
end,
we
write
a
new
algorithm
PRIMES2
with
an
additional
parameter
:ROW.
The result of executing PRIMES 26 is shown in Fig. 5. Next, we can improve
the
The
turtle
moves
to
the
next
row
whenever
it
drew
a
number
of
squares
that
is
appearance by having the squares drawn in multiple rows (Listing 1.10). To this end, we
divisible by the value of :ROW. With PRIMES2 104 26 we obtain an output as
write a new algorithm PRIMES2 with an additional parameter :ROW. The turtle moves to
shown in Figure 6.
the next row whenever it drew a number of squares that is divisible by the value of :ROW.
An advanced exercise then deals with prime powers. The students should
With PRIMES2 104 26 we obtain an output as shown in Fig. 6.
solve this task at home, either alone or in small groups. The diculty of this
An advanced exercise then deals with prime powers. The students should solve this
exercise is due to the usage of a return statement, which is implemented by the
task
at home,
either alone
or in small groups. The difficulty of this exercise is due to the
output
instruction
in Logo.
usage of a return statement, which is implemented by the output instruction in Logo.
11
122
J. Hromkovi et al.
Exercise. A prime power is a natural number that has exactly one prime factor. For
instance, 27 is a prime power since it has the prime factorization
27 = 3 3 3 = 33.
Clearly, every prime number is thus also a prime power.
In this project, you design a program PRIMEPOW, which checks whether a given
number is a prime power. To this end, do the following steps:
1. Rewrite the program PRIME to obtain a program PRIMEOUT that uses the command output instead of drawing squares. If the value of :NUM is prime, the
value 1 should be returned, otherwise 0.
2. PRIMEPOW has one parameter :TEST. We want to check whether the value assigned to :TEST is a prime power (possibly with the exponent being 1).
3. First, the program checks using PRIMEOUT whether :TEST is a prime number. If so, Prime. is printed on the screen and the execution is ended using
stopall.
make "ISPRIME PRIMEOUT :TEST
if :ISPRIME=1 [pr [Prime.] stopall] []
4. Otherwise, all numbers smaller than the value of :TEST are iterated, and again
using PRIMEOUT it is checked whether the current number is a prime. If so, it is
checked whether it divides the value of :TEST without remainder.
5. If such a prime number is found, PRIMEPOW takes note of this by setting the
value of a variable :FOUND to 1. :FOUND is initialized with 0. If a second such
prime number is found, this will be noted since the value of :FOUND is already
1. In this case, More than one divisor. is printed on the screen and the execution is again ended with stopall.
6. Finally, if :FOUND is still 1 after all numbers were tested, Prime Power. Base:
and the prime number that divides the value of :TEST without remainder are
printed on the screen.
7. Check PRIMEPOW using small input values.
This introduction using Logo proved to be very valuable for the students in the succeeding lessons, where we implement more complex projects using Python. More precisely, they were able to learn important paradigms without having to worry too much
about syntactical details.
5. Conclusion
Programming education is a great opportunity to teach important core concepts of computer science on various levels and to establish algorithmic thinking as part of a broad
and general education. A necessary prerequisite is, of course, that we find ways to go
beyond teaching the specifics of a programming language and rather put emphasis on
those aspects of programming that lead to a deeper understanding of computer science.
123
In this article, we have provided three examples of how programming education can
incorporate more general principles of algorithmic thinking. All three examples have
been taken from our welltested teaching materials for primary school, high school, and
university level, respectively. Further details about our curricula are given in the complementing paper (Hromkovi etal., 2016).
References
Bell, T., Rosamond, F., Casey, N. (2012). Computer science unplugged and related projects in math and computer
science popularization. The Multivariate Algorithmic Revolution and Beyond, SpringerVerlag, 398456.
Bckenhauer, H.J., Hromkovi, J., Komm, D. (2015). Programmieren mit LOGO Projekte.
http://abz.inf.ethz.ch/wpcontent/uploads/unterrichtsmaterialien/primarschulen/
logo_projekte.pdf
Bckenhauer, H.J., Hromkovi, J., Komm, D. (2015). Programmieren mit LOGO fr Fortgeschrittene.
http://abz.inf.ethz.ch/wpcontent/uploads/unterrichtsmaterialien/primarschulen/
logo_heft_2_de.pdf
Freiermuth, K., Hromkovi, J., Keller, L., Steffen, B. (2010). Einfhrung in die Kryptologie. Springer.
Gallenbacher, J. (2008). Abenteuer Informatik. IT zum Anfassen von Routenplaner bis OnlineBanking.
Springer, 2 edition.
Gebauer, H., Hromkovi, J., Keller, L., Kosrov, I., Serafini, G., Steffen, B. (2016). Programmieren mit
LOGO.
http://abz.inf.ethz.ch/wpcontent/uploads/unterrichtsmaterialien/primarschulen/
logo_heft_de.pdf
Hromkovi, J. (2014). Einfhrung in die Programmierung mit LOGO Lehrbuch fr Unterricht und Selbststudium. Springer, 3 edition.
Hromkovi, J., Kohn, T., Komm, D., Serafini, G. (2016). Combining the Power of Python with the Simplicity of
Logo for a Sustainable Computer Science Education. Unpublished Manuscript.
Kohn, T. (2016). Python. Eine Einfhrung in die ComputerProgrammierung.
http://jython.tobiaskohn.ch/PythonScript.pdf
Papert, S. (1993). Mindstorms. Basic Books, 2 edition.
Turing, A. M. (1936). On computable numbers, with an application to the Entscheidungsproblem. Proceedings
of the London Mathematical Society, 42(2), 230265.
124
J. Hromkovi et al.
J. Hromkovi is professor of informatics with a special added focus on computer science education at ETH Zurich. He is author of
about 15 books published in 6 languages (English, German, Russian,
Spanish, Japanese, and Slovak) and about 200 research articles. He
is member of Academia Europaea and the Slovak Academic Society.
T. Kohn is writing his PhD thesis in computer science at ETH Zurich.
The focus of his research is programming education, particularly in
high schools. He holds an MSc in mathematics from ETH and has been
teaching mathematics and computer science for 10 years.
D. Komm is lecturer at ETH Zurich and an external lecturer at University of Zurich. He studied computer science at RWTH Aachen
University and Queensland University of Technology. He received
his PhD from ETH Zurich in 2012. His research interests focus on
algorithmics and advice complexity.
G. Serafini is lecturer in the Computer Science Teaching Diploma
Program at ETH Zurich. He holds a MSc in computer science and
a teaching diploma in computer science from ETH Zurich. His research interests focus on the contribution of computational thinking to school education. He is a member of the board of the Swiss
Computer Science Teacher Association and a member of the Swiss
Olympiad in Informatics.
125
Abstract. In our paper, we want to present the conception of elementary programming in primary
Informatics education in Slovakia and the process of its integration into ordinary classrooms.
First, we will familiarize the reader with the tradition of so called Informatics education in
Slovakia and with the various stages of the process of its integration. We will formulate the learning objectives of the elementary informatics as a school subject in Slovakia (referring to Blaho
and Salanci, 2011) and give reasons why we believe that it offers an important opportunity for
developing informatics knowledge, computational thinking and problem solving skills. We will
primarily focus on the presentation of our arguments why we consider programming (in the form
rigorously respecting the age of the primary pupils) to be appropriate and productive constituent
of learning already for this age group. Several recent research findings, presented by Ackermann
(2012) and others support our position here. In the next chapter, we will present in detail the
conception of elementary programming and how it is implemented in the continuing professional
development (CPD) of primary teachers in Slovakia. We will examine which programming environments are being used, what kind of pedagogies and which specific learning objectives our
teachers apply. We will list programming concepts and identify corresponding cognitive operations, which we find appropriate for primary pupils. Then we will present and analyse the CPD of
our inservice teachers (and the position of programming in this process) which we have recently
implemented in Slovakia. Another important element of our CPD strategy is the wellknown
Bebras contest (in Slovakia it is called iBobor or Informatics Beaver). In the next chapter of
our paper, we will apply qualitative educational inquiry methods to examine how our conception of elementary programming has really penetrated into primary classes in Slovakia. We are
also interested in how it is being received by the teachers and pupils. Through interviews with
the teachers we will identify different aspects of the whole process and main risk factors, which
may complicate or hinder the implementation. In the final chapter, we will study the tendency
to develop informatics and programming at the primary level in the context of various research
projects presented in the academic research literature. We will compare various key findings of
other research projects with our own experience.
Keywords: educational programming, primary education, computing, computational thinking.
126
1.Introduction
In recent years many educators, education policy makers and scientists call for integration of what they call computational thinking into primary education of all pupils. In influential documents like (The Royal Society, 2012) a need to distinguish computational
thinking (or computer science, informatics or computing education) from the ICT education is declared. However, reasons for such reflections differ computer scientists and
industry leaders feel that not enough young people (and only very few women) choose to
pursue a career in computer science and they believe that if pupils become familiar with
some informatics concepts (within their primary education already) they will favour it
later in their lives and careers. Others believe that computational thinking is equally
important and key skill as literacy and mathematical thinking and they call for a redefinition of literacy and for integrating digital literacy development into primary education
for the sake of educating a fully developed citizens to live in the digital world.
While ICT oriented education is included in most national curricula, many countries
do not pay any special attention to including other (and in our opinion more interesting
and more important) informatics concepts. However, we can observe important new step
in the UK by establishing computing as a compulsory subject in every school year since
September 2014.
The situation in Slovakia is different from most of the countries. Informatics as a
separate mandatory subject was established many years ago and for many years we have
been systematically preparing teachers for teaching it. The authors of our national curriculum took a great care to include topics from core informatics along with learning of
basic ICT skills.
Since Comenius University plays a key role in building National Informatics Curriculum (2011, 2015) we have a lot of experience with integrating educational informatics both into schools (primary, lower secondary and upper secondary) and into teachers
professional development (PD). Some activities with digital technology were recently
nationwide integrated into early childhood education (or children 3 to 6) as well: see
e.g. (
Viel mehr als nur Dokumente.
Entdecken, was Scribd alles zu bieten hat, inklusive Bücher und Hörbücher von großen Verlagen.
Jederzeit kündbar.