linklist

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • senthil

    #1

    linklist

    1) Is there a way, to delete say "n"th node in a link list without
    actually traversing?

    2) Is there a way to find out the number of nodes in the list without
    traversing?

  • dandelion

    #2
    Re: linklist [OT]


    "senthil" <senthilnathan. periasami@wipro .com> wrote in message
    news:1104235585 .432584.318750@ z14g2000cwz.goo glegroups.com..

    Assuming we're talking of a 'standard' linked list.
    [color=blue]
    > 1) Is there a way, to delete say "n"th node in a link list without
    > actually traversing?[/color]

    No.
    [color=blue]
    > 2) Is there a way to find out the number of nodes in the list without
    > traversing?[/color]

    No.

    Unless you have trouble with an implementation in C, and it's a 'C' issue
    (instead of some library or the OS) this is off topic.


    Comment

    • infobahn

      #3
      Re: linklist

      senthil wrote:[color=blue]
      > 1) Is there a way, to delete say "n"th node in a link list without
      > actually traversing?[/color]

      No, unless you happen to know it's the first, or perhaps last, item
      in the list. Ask your programming tutor for details.

      [color=blue]
      > 2) Is there a way to find out the number of nodes in the list without
      > traversing?[/color]

      Yes. Again, ask your programming tutor for details.

      Comment

      • osmium

        #4
        Re: linklist

        "senthil" writes:
        [color=blue]
        > 2) Is there a way to find out the number of nodes in the list without
        > traversing?[/color]

        I'm sure you realize that you could tally items as you add and remove items
        from the list?


        Comment

        • senthil

          #5
          Re: linklist


          infobahn wrote:[color=blue]
          > senthil wrote:[color=green]
          > > 1) Is there a way, to delete say "n"th node in a link list without
          > > actually traversing?[/color]
          >
          > No, unless you happen to know it's the first, or perhaps last, item
          > in the list. Ask your programming tutor for details.
          >
          >[color=green]
          > > 2) Is there a way to find out the number of nodes in the list[/color][/color]
          without[color=blue][color=green]
          > > traversing?[/color]
          >
          > Yes. Again, ask your programming tutor for details.[/color]

          If my programming tutor knows it, i would not have asked for it in
          this newsgroup, wasting u people's precious time.
          Please let me know "How to find out the number of nodes in the list
          without traversing ?", I ask again, because you said,"Yes."

          Comment

          • Richard Bos

            #6
            Re: linklist

            "senthil" <senthilnathan. periasami@wipro .com> wrote:
            [color=blue]
            > infobahn wrote:[color=green]
            > > senthil wrote:[color=darkred]
            > > > 2) Is there a way to find out the number of nodes in the list
            > > > without traversing?[/color]
            > >
            > > Yes. Again, ask your programming tutor for details.[/color]
            >
            > If my programming tutor knows it, i would not have asked for it in
            > this newsgroup, wasting u people's precious time.
            > Please let me know "How to find out the number of nodes in the list
            > without traversing ?", I ask again, because you said,"Yes."[/color]

            You do not get infobahn's point, I'm afraid. Let me state it more
            clearly, then: Do Your Own Damn Homework.

            Richard

            Comment

            • Mike Wahler

              #7
              Re: linklist


              "senthil" <senthilnathan. periasami@wipro .com> wrote in message
              news:1104292704 .583637.15090@f 14g2000cwb.goog legroups.com...[color=blue]
              >
              > infobahn wrote:[color=green]
              > > senthil wrote:[color=darkred]
              > > > 1) Is there a way, to delete say "n"th node in a link list without
              > > > actually traversing?[/color]
              > >
              > > No, unless you happen to know it's the first, or perhaps last, item
              > > in the list. Ask your programming tutor for details.
              > >
              > >[color=darkred]
              > > > 2) Is there a way to find out the number of nodes in the list[/color][/color]
              > without[color=green][color=darkred]
              > > > traversing?[/color]
              > >
              > > Yes. Again, ask your programming tutor for details.[/color]
              >
              > If my programming tutor knows it, i would not have asked for it in
              > this newsgroup, wasting u people's precious time.
              > Please let me know "How to find out the number of nodes in the list
              > without traversing ?", I ask again, because you said,"Yes."[/color]

              If you just take a moment to put yourself in the computer's
              shoes, the answer should become obvious.

              -Mike


              Comment

              • gooch

                #8
                Re: linklist

                If my programming tutor knows it, i would not have asked for it in
                this newsgroup, wasting u people's precious time.
                Please let me know "How to find out the number of nodes in the list
                without traversing ?", I ask again, because you said,"Yes."
                The question was already answered. Take the time to read the responses.

                Comment

                • The Dragon

                  #9
                  Re: linklist

                  On 2005-01-03, gooch <gooch001@comca st.net> wrote:[color=blue]
                  > If my programming tutor knows it, i would not have asked for it in
                  > this newsgroup, wasting u people's precious time.
                  > Please let me know "How to find out the number of nodes in the list
                  > without traversing ?", I ask again, because you said,"Yes."
                  > The question was already answered. Take the time to read the responses.
                  >[/color]

                  I don't know of any way to do it without traversing the list, however, you
                  could actually keep count of inserted and deleted nodes. The count would
                  get out of whack if you have a bad algorithm for insertion, or deletion, and
                  end up with orphan nodes, but this would certainly suffice, infact, its
                  quite possible to keep a count in the head of the list and leave that
                  variable unused in the rest of the nodes, although thats wasteful
                  (sizeof(int) * # nodes - sizeof(int) wasteful to be exact.)

                  -- The Dragon
                  MHM 7x9, Hits you harder than a 2x4.

                  Comment

                  Working...