Search:

Type: Posts; User: Loraeron

Search: Search took 0.08 seconds.

  1. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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...
  2. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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.*;...
  3. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    What do you think of this:



    public Node get(int x)
    {
    int searchLoc = x;
    Node ref = firstElement;
    int counter = 0;
  4. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    I'm still at a bit of a loss as to what would be inside the:



    public Node get(int x)
    {
    int searchLoc = x;
  5. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    So.....:



    public int size()
    {
    int count = 0;
    Node ref = firstElement;
    while(ref != null)
    {
  6. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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...
  7. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked 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)
    {
    ...
  8. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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...
  9. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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 =...
  10. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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.
  11. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    It would perform a deep or shallow copy on the node passed and return it. Like when copying an object.
  12. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    So would you have to use something like

    Node L3 = new Node();
    L3.copy(L1.next);
  13. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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.
  14. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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...
  15. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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...
  16. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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...
  17. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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...
  18. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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...
  19. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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...
  20. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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...
  21. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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.
  22. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two 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...
  23. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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...
  24. Replies
    49
    Views
    6,138

    Re: Sort and Merge Two Linked List

    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...
  25. Replies
    49
    Views
    6,138

    Sort and Merge Two Linked List

    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...
Results 1 to 25 of 25