visit trees

C

carmelo

imagine to have a k-ary tree, each node is a room and each edge is a
corridor; each room has a value assigned, you must place cameras in
rooms but if a room has an adiacent room with the camera you can't
place the camera inside...you must place the cameras to have the max
value possibile.. how to choose the rooms?
 
L

Lew Pitcher

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

imagine to have a k-ary tree, each node is a room and each edge is a
corridor; each room has a value assigned, you must place cameras in
rooms but if a room has an adiacent room with the camera you can't
place the camera inside...you must place the cameras to have the max
value possibile.. how to choose the rooms?

Speaking of rooms, you got the wrong one. Sorry.

What you want is comp.programming, up two floors, on the left side
across from the elevators. They can help you with your algorithm and
theory problems.

Here , we are mechanics working in the C language. If you had a problem
with some specific C code (standards conformant, if you please. We
don't like homebrew or propriatary extensions) we could help you.

Sorry

- --
Lew Pitcher



-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (MingW32) - WinPT 0.11.12

iD8DBQFFCsYvagVFX4UWr64RAkRHAKDV9SC0Gq5vzilctmqthzN6JzaUHgCg9Wmb
S3p8+K+45ljDzMekGkIdL3k=
=VORC
-----END PGP SIGNATURE-----
 
F

Fred Kleinschmidt

carmelo said:
imagine to have a k-ary tree, each node is a room and each edge is a
corridor; each room has a value assigned, you must place cameras in
rooms but if a room has an adiacent room with the camera you can't
place the camera inside...you must place the cameras to have the max
value possibile.. how to choose the rooms?
Start with room 42. It's bigger. And decide whether you want to use Canon
ELF's or Kodaks. Or for max value, use a Hasselblad.
 
G

gpnair78

carmelo said:
imagine to have a k-ary tree, each node is a room and each edge is a
corridor; each room has a value assigned, you must place cameras in
rooms but if a room has an adiacent room with the camera you can't
place the camera inside...you must place the cameras to have the max
value possibile.. how to choose the rooms?

A level order traversal of the k-ary tree starting from the root
(i.e.depth 0) and chosing all the nodes from even numbered depths. So
in this case, sum of all the nodes in depth 0, 2, 4 ..., call it x.

Another level-order traversal of the k-ary tree starting from depth 1
and chosing all the nodes from odd numbered depths. So in this case,
sum of all the nodes in depth 1, 3, 5 ..., call it y.

The larger of the 2 values x,y will be your max and it's corresponding
nodes will give you the rooms with cameras in them.

Gokul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,127
Latest member
CyberDefense
Top