5. Sample Questions
Download
Report
Transcript 5. Sample Questions
CodeVita Season III
(2014 – 2015 Season)
1
CodeVita Questions
Broadly speaking Three types of problems – {Simple,
Medium, Complex}
Questions of season III have following flavours
– String Manipulation
– Formula-based
– Algorithmic (Greedy, Genetic, Dynamic programming)
– Real-life
– Data Structures (Trees, Graphs, Bit Set etc.)
Single-correct answer (most of the times), Verified
Solvability (Space-time constraints)
2
Example of Simple Problem
Bob’s List
Find out students
studying
• Physics and Maths
• Physics or Maths
• Physics but not
Maths
Students
studying
Physics
Students
studying
Maths
3
Example of Simple Problem
Stone Removal
• Ladies First Alice always plays
first
• Each player can
remove only 1, 2
or 3 stones
• Assume optimal
play by both sides
2 2
2,
3 1,
3,
1 2
• For Generic N,
where N is the # of
stones, predict if
Alice can win
Bob has to remove last stone.
Hence Alice wins !!
4
Example of Medium Problem
Break the Friendship
• During exams, friends cheat
• Two rooms are available for the exam
• Given a list of friends
• Create two groups of students such
that no two friends are in the same
group
5
Example of Medium Problem
Online Communities - Connectivity
• People connect with each other in a
social network.
• When two persons belonging to
different communities connect, the
net effect is merger of both
communities which they belonged to
• In a constantly changing social
graph, find out whether two persons
are in a same group or not
6
Example of Complex problem
Isotope
Only When
adjacent
2 atoms
atomsfuse
can be
energy
fusedis released and
a new atom is formed
Codium=56
Codium=56
Programium=61
Programium=61
Programium=61
Developium=2
Developium=2
3416KJ
KJ
Energy = 122
(56 * 2)
61)
(61
Algorium=33
Testium=122
(56 * 2)
61)mod
mod199
199
(61
Total energy produced
3416KJ
KJ++6832
66 KJ
= 122
KJ
3492 KJ
= 6954
Algorium=33
Codium=56
Developium=2
Testium=122
Energy = 66
KJKJ
6832
(33 * 122)
2)
(56
Second solution is better because it maximizes energy produced
7
Example of Complex problem
White To Move
Number of moves possible
for White = 20
18
• Always, White to Move
•Ignore Castling and En
Passant rules of Chess
•Compute number of
possible moves for
white in any arbitrary
board position
8