A problem with a graph

This is a discussion on A problem with a graph within the C++ Programming forums, part of the General Programming Boards category; Hello to everybody, I'm preparing for a competition in Informatics and I had difficulty with the following task: You should ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    1

    A problem with a graph

    Hello to everybody,
    I'm preparing for a competition in Informatics and I had difficulty with the following task:

    You should find a path with the greatest number of points(vertices) in a graph.
    /The graph has no cycles in it - it's a tree./

    Can you write down the code or explain to me how to do it?
    Thank you in advance!

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,531
    Draw a few simple trees on paper.
    Draw on them what the longest path would be, say using a highlighter.
    Think about the process you go through to work that out, then think about how you might code it.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  2. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  3. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  4. Help w/ graph as adjacency matrix
    By ac251404 in forum C++ Programming
    Replies: 4
    Last Post: 05-09-2006, 10:25 PM
  5. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21