Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 25 of 25

Thread: Singly-Linked list structure

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy Singly-Linked list structure

    Hi All
    I am beginner in Java and this is my first post.
    Please could you help me with this .
    I need to implement a basic singly-linked list structure as a class. also it should allow
    addition and deletion of single element in the linked list at a specified position i. we can assume each element is represented using the int primitive data type.
    I would be very great full if you point me some sample programs like i described


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,618
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Singly-Linked list structure

    Do you have any code that you are having problems with?
    If so, post the code and ask questions about your problems.

  3. #3
    Junior Member
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Singly-Linked list structure

    How can I get a link list to print out in an array? Any ideas?

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,618
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Singly-Linked list structure

    Can you explain what you are trying to do?
    "print out in an array" makes no sense to me.
    Do you want to extract nodes from a linked list and store them in an array?

  5. #5
    Junior Member
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Singly-Linked list structure

    Sorry to be a pain,
    yeap, extract nodes from a linked list and store them in an array

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,618
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Singly-Linked list structure

    Use the linked list class's methods to get the nodes one by one and assign them to an array slot as you get them.

  7. #7
    Junior Member
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Singly-Linked list structure

    is that ok if PM you my code?

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,618
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Singly-Linked list structure

    I don't do any work out of the public. If you want help you'll have to post code here with your questions.
    If you can isolate a particular problem to a small program that will help.

  9. #9
    Junior Member
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Singly-Linked list structure

    no thats fine, just didn't wanted to make a mess ))

    public void insert(int x){

    if(start==null){
    start=new Node(x,start);
    }
    if(start!=null){
    Node temp=start;
    while(temp.next!=null){
    temp=temp.next;
    }

    temp.next=new Node(x);
    This is what I'm using to insert a node,
    But how do I insert a strand

  10. #10
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,618
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Singly-Linked list structure

    But how do I insert a strand
    By strand do you mean another linked list?
    Change the links to point to the front of the new list and change the end of the new list to be back into the original list.
    Draw it on a piece of paper if you need to see what I'm talking about.

  11. #11
    Junior Member
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Singly-Linked list structure

    no, that is a string,

  12. #12
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,618
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Singly-Linked list structure

    Please explain you question. I don't understand what you are asking.

  13. #13
    Junior Member
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Singly-Linked list structure

    I need to implement, crossover phenomenon. given 2 dan strands and an index i, d strands should cross-over so that d 1st i nucleotides of the 1st strand r unchanged, but d remainder is replaced with d nucleotides from d position i+1 go d 2nd strand. equally, d first i nucleotides of d 2nd strand should be unchanged, but d remainder of the 2nd strand. for ex, if d initial strands r:

    (on the picture)


    IMG_0873.JPG

    thank you very much and I do apologise for my unclear questions
    Last edited by blaster; March 11th, 2012 at 02:01 PM.

  14. #14
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,618
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Singly-Linked list structure

    What is a String?

  15. #15
    Junior Member
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Singly-Linked list structure

    thats my full question, is that make sense

  16. #16
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,618
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Singly-Linked list structure

    You'll have to translate from the jargon you used in post#13 to something related to java programming.

  17. #17
    Junior Member
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Singly-Linked list structure

    Quote Originally Posted by Norm View Post
    You'll have to translate from the jargon you used in post#13 to something related to java programming.
    what u mean jargon

  18. #18
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    660
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Singly-Linked list structure

    jar·gon (järgn)
    1. Nonsensical, incoherent, or meaningless talk.
    2. A hybrid language or dialect; a pidgin.
    3. The specialized or technical language of a trade, profession, or similar group. See Synonyms at dialect.
    4. Speech or writing having unusual or pretentious vocabulary, convoluted phrasing, and vague meaning.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  19. #19
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,618
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Singly-Linked list structure

    cossover phenomenon. given 2 dan strands
    d nucleotides from d position i+1 go d 2nd strand.
    d first i nucleotides of d 2nd strand

    None of that has any meaing for me.

    #3 in post#18

  20. #20
    Junior Member
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Singly-Linked list structure

    i know what does jargon means i asked which words unclear
    Last edited by blaster; March 11th, 2012 at 02:38 PM.

  21. #21
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,618
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Singly-Linked list structure

    please tell me if there is anything wrong with my code
    If you want anyone to test your code, you need to post a complete program that compiles and executes.
    A small program that shows the problem without any other stuff that is not related to the problem.

  22. #22
    Junior Member
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Singly-Linked list structure

    Quote Originally Posted by Norm View Post
    cossover phenomenon. given 2 dan strands
    d nucleotides from d position i+1 go d 2nd strand.
    d first i nucleotides of d 2nd strand

    None of that has any meaing for me.

    #3 in post#18
    given two DNA strands(thread)
    the nucleotides (element) from the position i+1 of the second strand(thread)

  23. #23
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,618
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Singly-Linked list structure

    I'll let you do the translating to programming language from your project's terminology(jargon)
    Do you have a java programming question?

  24. #24
    Junior Member
    Join Date
    Nov 2011
    Posts
    16
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Singly-Linked list structure

    Quote Originally Posted by Norm View Post
    I'll let you do the translating to programming language from your project's terminology(jargon)
    Do you have a java programming question?
    sorry Norm, that is exactly how on paper

  25. #25
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,618
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Singly-Linked list structure

    Now it needs to be translated to programming terms. Computers use bits and bytes.
    Programs work with variables and memory contents.

Similar Threads

  1. Singly Circular Linked List Error
    By clydefrog in forum Collections and Generics
    Replies: 7
    Last Post: March 5th, 2012, 07:17 PM
  2. Linked list Schminked list help with Nodes Please
    By Bially in forum Collections and Generics
    Replies: 1
    Last Post: September 29th, 2011, 03:20 PM
  3. Singly Linked List of Integers, get(int i) function throws Null Pointer Exception
    By felixtum2010 in forum What's Wrong With My Code?
    Replies: 10
    Last Post: June 23rd, 2011, 06:55 PM
  4. [SOLVED] Linked List Help
    By lieles in forum What's Wrong With My Code?
    Replies: 1
    Last Post: February 4th, 2011, 09:32 PM
  5. Help with linked list
    By joecool594 in forum Collections and Generics
    Replies: 3
    Last Post: November 28th, 2010, 11:33 AM