Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Java 

Circular Linked Lists

This is the code i've come up with to return a String containing the items of all the nodes in the list separated by commas. But this code doesn't work with a linked list that is circular that connects back to the head node.
i really wish i could help you, but unfortunately i don't know much about programming or java in general.

good luck in figuring this out though.

wow.

ok, so what i would do is on the second current!=null check i'd also checck if currentl also doesn't equal head
so like
Code
if(current != null && !current.equals(head))
for the second if(current != null) check

that should do it for you friend.

only wrote out all that code bc i'm guessing your new bc this was relatively simple problem, i'm just very coked out right now so i hope this helps.

cheers.
(Nov 30, 2017 05:56 PM)GoodVibes Wrote:  i really wish i could help you, but unfortunately i don't know much about programming or java in general.

good luck in figuring this out though.

wow.

ok, so what i would do is on the second current!=null check i'd also checck if currentl also doesn't equal head
so like
Code
if(current != null && !current.equals(head))
for the second if(current != null) check

that should do it for you friend.

only wrote out all that code bc i'm guessing your new bc this was relatively simple problem, i'm just very coked out right now so i hope this helps.

cheers.

Thanks for that brother and yeah i'm new
omg I just started learning linked listss in class
mind
blown

I need help on my HW but my professor didn't provide me a main.java even tho it says he did and to use it to write the code soooooooooooooooooooooooooooooo
Its not really a hard concept to understand:
[Image: wmoede.png]

In this picture we have two instances of Node. The class node looks like this:

PHP Code

<?php 
class Node {
 
   Node next;
 
   Node prev;
} 

To construct a list of a single element:
PHP Code

<?php 
Node n 
= new Node();
// forward connections (green)
n.next = n;
// backward connections (red)
n.prev = n; 

Now if we want a list of two elements:
PHP Code

<?php 
Node n1 
= new Node();
Node n2 = new Node();
// forward connections (green)
n1.next = n2;
n2.next = n1;
// backward connections (red)
n1.prev = n2;
n2.prev = n1; 

Obviously you will not want to do this manually so you would have methods for adding to the list (and handling edge cases). But as long as the links follow the pattern in the image above you have yourself a circular linked list.
Check out my latest post in the same subforum I just talked about doubly circular linked lists and you may use it for REFERENCE
If this is for school I do NOT give you permission to use this however you may study it and take concepts from it to create your own material
(Dec 1, 2017 06:26 AM)matt Wrote:  Check out my latest post in the same subforum I just talked about doubly circular linked lists and you may use it for REFERENCE
If this is for school I do NOT give you permission to use this however you may study it and take concepts from it to create your own material

hi,you can call me young turbo
no one cares if u give permission or not if u put it on the internet and he wants to steal it he will lol

god blessings,
xoxo

young turbo
(Dec 1, 2017 06:26 AM)matt Wrote:  Check out my latest post in the same subforum I just talked about doubly circular linked lists and you may use it for REFERENCE
If this is for school I do NOT give you permission to use this however you may study it and take concepts from it to create your own material

Thanks brother I’ll have a look later.
(Dec 1, 2017 01:08 PM)GoodVibes Wrote:  hi,you can call me young turbo
no one cares if u give permission or not if u put it on the internet and he wants to steal it he will lol

god blessings,
xoxo

young turbo

His fault if he gets caught cheating, lots of algorithms now a days that check for plagiarized work.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by Juice.Mar 10, 2020 07:02 PM 0 136 Mar 10, 2020 07:02 PM
Last Post: Juice.
[C] by g4143Dec 28, 2019 09:24 AM 1 350 Dec 28, 2019 09:24 AM
Last Post: an balker
[C] by 0xDEAD10CCMar 14, 2019 10:04 AM 23 1,316 Mar 14, 2019 10:04 AM
Last Post: maryous