Nevermind, managed to clear the error, code will compile and run, but gets stuck in an endless loop when it enters the TraverseMerge() method and i'm not sure why:
package hw3_vinson;
import...
Type: Posts; User: Loraeron
Nevermind, managed to clear the error, code will compile and run, but gets stuck in an endless loop when it enters the TraverseMerge() method and i'm not sure why:
package hw3_vinson;
import...
Here is the full code, the only error i'm getting is trying to use .next during my traverseMerge() method at the bottome
package hw3_vinson;
import java.util.LinkedList;
import javax.xml.*;...
What do you think of this:
public Node get(int x)
{
int searchLoc = x;
Node ref = firstElement;
int counter = 0;
I'm still at a bit of a loss as to what would be inside the:
public Node get(int x)
{
int searchLoc = x;
So.....:
public int size()
{
int count = 0;
Node ref = firstElement;
while(ref != null)
{
Well right now an error, because where i declare temp1 and temp2 right under LinkedList LL03 i don't assign anything because i'm stuck there. I need a way to retrieve the starting node of each list...
i meant it to be the built in .next not a method i create shouldn't have placed the ().
When the end of one of the list is found it will jump to another if that says
if (LL01 == null)
{
...
I understand I was just throwing out a quit bit i thought about haha.
The list that are passed will be sorted, the traverseList method will perform another sort while merging them. I will have a...
No haha same project, different approach and it seems like this route would work better. Steps for this method:
TraverseList(List LL1, List LL2)
{
Node temp1 = LL1.next();
Node temp2 =...
Ok a new approach, i think we are adding to much to this method. I want to traverse List1 and List2 and compare them and sort at the same time by using simple comparison.
It would perform a deep or shallow copy on the node passed and return it. Like when copying an object.
So would you have to use something like
Node L3 = new Node();
L3.copy(L1.next);
Question though, wouldn't it still be left in List1 and List2? Therefore it is basically making a copy. It is storing the data of the node in temp then applying it to List3.
I only have what i have written above which is:
Node temp = List1.next(); OR Node temp = List2.next();
then storing them into the new List3:
List3.add(temp);
I think that is what you...
Ok so if i return a LinkedList, List3, i will be able to access it like you would during a return of other methods?
By theoretically i meant it is copying, just not using a copy method instead I...
Would I not need to initialize List3 outside of the method to be able to access it later? I then would use the merge to add to List3.
Also I assumed the two while loops where theoretically...
Haha ok, well I would set up a merge method that accepts two linked list arguments. Note List3 would be initialized in the main loop to null before calling the merge(List1, List2)
Step 1: Take...
The HW3_Vinson has a constructor for initial set up, then I have a Node class that is used to create pointers.
Yes the merge method will copy the two list and create a third, all the while leaving...
Still a bit unsure of what you mean, but i think you are asking what do i use to create my linked list and that would be HW3_Vinson. I have a constructor that initializes the list and then i'm...
I assume by "What class defines the list?" you are asking what in my code is defining/creating the list. They are being made using the private class Node then in the main method by using the add...
Merge code would need to accept two linked list arguments and return a linked list. If that can't be done i guess it will accept a Node and utilize the .next method built into java for linked list.
The initial list will not be sorted. Once the merged list is created then it will be sorted. The old list will still be available, I want to be able to show the two original list along with the...
Ideally I would want my merge method to be a standalone not inside one of the already existing lists. I would want it to take in two List arguments and return a list, but I just don't see how it is...
I did know there was a compile error, it was on my mergeList method I was tampering with. I have edited the above code and commented it out, should compile now. I was using NetBeans IDE, so you may...
I am looking for help with a homework assignment that requires us to merge two linked list (integer type) and create a third list that is sorted without destroying the original list. I have created...