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#
  4. N-Grandparent-Parent-Child Algorithm

N-Grandparent-Parent-Child Algorithm

Scheduled Pinned Locked Moved C#
questioncsharpc++javaperl
7 Posts 5 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.
  • V Offline
    V Offline
    VarChar255
    wrote on last edited by
    #1

    Greetings, I will try to describe this problem in as much details as I can. Task: Create N HTML page withing a folder-structure based on N grandparent-parent-child relationships. Data structure: TopicID - int ParentTopicID int TopicName - nvarchar(4000) Sample data TopicID ParentTopicID TopicName 0 0 Computers 1 1 Programming 2 1 C# 3 1 C++ 4 1 Java 5 1 Perl 6 0 Operating systems 7 6 Windows 2000 8 6 Windows XP 9 6 Unix Output which to achieve: Folder: Computer File: Computers.html Contents: Programming Operating Systems Folder: Computer/Programming File: Programming.html Contents: C# C++ Java Perl and so forth.... The question is, what is the best algorithm to use to achive the above results? Thank you very much in advanced!

    Arsen

    P L P 3 Replies Last reply
    0
    • V VarChar255

      Greetings, I will try to describe this problem in as much details as I can. Task: Create N HTML page withing a folder-structure based on N grandparent-parent-child relationships. Data structure: TopicID - int ParentTopicID int TopicName - nvarchar(4000) Sample data TopicID ParentTopicID TopicName 0 0 Computers 1 1 Programming 2 1 C# 3 1 C++ 4 1 Java 5 1 Perl 6 0 Operating systems 7 6 Windows 2000 8 6 Windows XP 9 6 Unix Output which to achieve: Folder: Computer File: Computers.html Contents: Programming Operating Systems Folder: Computer/Programming File: Programming.html Contents: C# C++ Java Perl and so forth.... The question is, what is the best algorithm to use to achive the above results? Thank you very much in advanced!

      Arsen

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      VarChar255 wrote:

      The question is, what is the best algorithm to use to achive the above results?

      I suggest the critical thinking algorithm. Good luck on your assignment, it's an interesting one.

      V 1 Reply Last reply
      0
      • V VarChar255

        Greetings, I will try to describe this problem in as much details as I can. Task: Create N HTML page withing a folder-structure based on N grandparent-parent-child relationships. Data structure: TopicID - int ParentTopicID int TopicName - nvarchar(4000) Sample data TopicID ParentTopicID TopicName 0 0 Computers 1 1 Programming 2 1 C# 3 1 C++ 4 1 Java 5 1 Perl 6 0 Operating systems 7 6 Windows 2000 8 6 Windows XP 9 6 Unix Output which to achieve: Folder: Computer File: Computers.html Contents: Programming Operating Systems Folder: Computer/Programming File: Programming.html Contents: C# C++ Java Perl and so forth.... The question is, what is the best algorithm to use to achive the above results? Thank you very much in advanced!

        Arsen

        P Offline
        P Offline
        Paddy Boyd
        wrote on last edited by
        #3

        Smells a bit like homework...

        1 Reply Last reply
        0
        • L led mike

          VarChar255 wrote:

          The question is, what is the best algorithm to use to achive the above results?

          I suggest the critical thinking algorithm. Good luck on your assignment, it's an interesting one.

          V Offline
          V Offline
          VarChar255
          wrote on last edited by
          #4

          No not homework at all... actually one of my developers is having trouble with this, he wrote the code but i'd like to get some opinions from others on what patterns they use.

          Arsen

          J 1 Reply Last reply
          0
          • V VarChar255

            No not homework at all... actually one of my developers is having trouble with this, he wrote the code but i'd like to get some opinions from others on what patterns they use.

            Arsen

            J Offline
            J Offline
            J4amieC
            wrote on last edited by
            #5

            VarChar255 wrote:

            No not homework at all... actually one of my developers is having trouble with this, he wrote the code but i'd like to get some opinions from others on what patterns they use.

            OK, lets flip this around then. What patterns would you use and we'll tell you whether we agree and which of your options sounds like the best way to us! If you're telling the truth, and this really isn't homework, then you'll be willing and able to provide some responses. More likely we will see no response from you whatsoever.

            V 1 Reply Last reply
            0
            • J J4amieC

              VarChar255 wrote:

              No not homework at all... actually one of my developers is having trouble with this, he wrote the code but i'd like to get some opinions from others on what patterns they use.

              OK, lets flip this around then. What patterns would you use and we'll tell you whether we agree and which of your options sounds like the best way to us! If you're telling the truth, and this really isn't homework, then you'll be willing and able to provide some responses. More likely we will see no response from you whatsoever.

              V Offline
              V Offline
              VarChar255
              wrote on last edited by
              #6

              Here is what my developer has implemented (excerpts) void ProcesstopicChildren(DataTable dttopic) { similar while loop, but calling processtopic within whileloop. } main() { DataTable dtChildtopic; DataTable dtParenttopic; ItopicManager topicManager; // this is the SQL connector to call the SQL. int ParenttopicID; ParenttopicID = 8; // Just as a test dtParenttopic = topicManager.GettopicView(ParenttopicID); while(dttopic.Rows.Count > 0) { ParenttopicID = int.Parse(dtParenttopic.Rows[ParenttopicCount]["ParenttopicID"].ToString()); dttopic = topicManager.GettopicView(ParenttopicID); ParenttopicCount++; } }

              1 Reply Last reply
              0
              • V VarChar255

                Greetings, I will try to describe this problem in as much details as I can. Task: Create N HTML page withing a folder-structure based on N grandparent-parent-child relationships. Data structure: TopicID - int ParentTopicID int TopicName - nvarchar(4000) Sample data TopicID ParentTopicID TopicName 0 0 Computers 1 1 Programming 2 1 C# 3 1 C++ 4 1 Java 5 1 Perl 6 0 Operating systems 7 6 Windows 2000 8 6 Windows XP 9 6 Unix Output which to achieve: Folder: Computer File: Computers.html Contents: Programming Operating Systems Folder: Computer/Programming File: Programming.html Contents: C# C++ Java Perl and so forth.... The question is, what is the best algorithm to use to achive the above results? Thank you very much in advanced!

                Arsen

                P Offline
                P Offline
                Pete OHanlon
                wrote on last edited by
                #7

                If the datasource for this is SQL Server 2005, then take a look at using Common Table Expressions (CTE). They will sort this out for you no problem.

                Deja View - the feeling that you've seen this post before.

                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