Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Constructing a tree

Constructing a tree

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmshelpquestionc++data-structures
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    llp00na
    wrote on last edited by
    #1

    Dear everyone; I have got a pure C++/ algorithmic question that i would appreciate your input towards. I have a number of files (lets say 100 files) of similar input formats. To reduce the complexity of the problem I will give you a simplied example: File 1: File 2: File 3: A A B B E A C D D D D F E F E I want to write a program which produces a tree from the files, in which the first node is the node from the first line (from above) with the highest number of occurences ('A' in this case). Consequently File 3 will be ignored. The resulting tree will be something like A (100%) B (50%) E (50%) C (50%) D (50%) D (100%) E (50%) E (50%) SO basically the program should go through the files and construct a tree with a % value of each node. every time branching occurs the % will be divided depending on the number of children. My question is, is there any specific algorithm / similar algorithms which i can use to overcome this problem ? and What's the best way to visualise the tree? Your help is very much appreciated Best Regards

    llp00na

    D 1 Reply Last reply
    0
    • L llp00na

      Dear everyone; I have got a pure C++/ algorithmic question that i would appreciate your input towards. I have a number of files (lets say 100 files) of similar input formats. To reduce the complexity of the problem I will give you a simplied example: File 1: File 2: File 3: A A B B E A C D D D D F E F E I want to write a program which produces a tree from the files, in which the first node is the node from the first line (from above) with the highest number of occurences ('A' in this case). Consequently File 3 will be ignored. The resulting tree will be something like A (100%) B (50%) E (50%) C (50%) D (50%) D (100%) E (50%) E (50%) SO basically the program should go through the files and construct a tree with a % value of each node. every time branching occurs the % will be divided depending on the number of children. My question is, is there any specific algorithm / similar algorithms which i can use to overcome this problem ? and What's the best way to visualise the tree? Your help is very much appreciated Best Regards

      llp00na

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      llp00na wrote:

      File 1: File 2: File 3: A A B B E A C D D D D F E F E

      You've not used alignment correctly (use the <pre> tags) so I'm unclear as to what the three files look like.

      llp00na wrote:

      Consequently File 3 will be ignored.

      Why?

      llp00na wrote:

      The resulting tree will be something like A (100%) B (50%) E (50%) C (50%) D (50%) D (100%) E (50%) E (50%)

      Does this tree branch to the right, or does it branch downward? Again, alignment would make the difference here.

      llp00na wrote:

      SO basically the program should go through the files and construct a tree with a % value of each node. every time branching occurs the % will be divided depending on the number of children.

      What exactly does this mean? Use percentages other than 100 and 50 so that we can see how the files relate to the nodes.


      "Approved Workmen Are Not Ashamed" - 2 Timothy 2:15

      "Judge not by the eye but by the heart." - Native American Proverb

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups