Search:

Type: Posts; User: Norm

Search: Search took 0.14 seconds.

  1. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    TIme for some debugging. Try debugging your code by adding println() statements to show execution progress and how variable values are changing. For example:
    Add a: System.out.println("var=" +...
  2. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Please copy the full text of the error message and paste it here.
  3. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Did you compile and test it to see if it works?
    Call it with several different values.
  4. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Use a loop like in the size() method to find the Node at the requested location in the list.
  5. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Node get(int) returns the Node at the location passed as arg. You were looking for get(0)
  6. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    The linked list needs a couple of methods:
    size() returns the # of nodes in the list
    Node get(int) returns the node at int
  7. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    What happens when you compile and execute the code?
  8. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    How will that work? It sounds like what an iterator does.

    You have got a lot more details of the new method now, but there still are some missing points.
    What happens when the end of a list is...
  9. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    You need to work on the steps of the logic before trying to write code.
    What values do the references to the Node objects have that are useful to the program?
    Are the lists that are passed to the...
  10. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Now you want to forget about the merge() method and work on another project?

    You want to work with a method that will take two lists as input, sort each list and then merge the two lists and...
  11. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    So the copy() method would be in the linked list class and having nothing to do with the class???
    It seems like it should be part of the Node class since it is working with Node data.
  12. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    What would the copy() method do?
  13. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Where is a copy made of the contents of the node?
    The post code copies a reference to the one node to the other list. So of like this:
    String aStr = "asdde";
    String bStr = aStr;
    bStr and aStr...
  14. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    That doesn't show that a copy of the node is made. It looks like the original node is moved to List3.
  15. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Do you have the steps for making a copy of a node?
  16. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    I thought that it was returned by merge(). merge() creates it, fills it and returns it.


    The more details covered in the design, the fewer problems when writing the code.
  17. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    The "create a copy" step is missing.

    Why is List3 created outside of the merge() method?
  18. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    That design seems a bit awkward. I'd have the method do the merge in one step.

    Step 2 needs some expansion to list the steps required. The way it's worded, it sounds like a clone() method that...
  19. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Some class defines the methods of the linked list and holds the pointers to the nodes in the list.
    What is the name of that class? Is it HW3_Vinson?

    I'm still not sure what the merge method does...
  20. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Sorry, that was poorly worded. What is the name of the linked list class the code will be using?
    You will need that to define a method that takes list objects as arguments.
  21. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Ok, start with that: the method takes two lists as input and returns a new list. What class defines the list?
    Then what does the method do?
  22. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Ok. Make a list of the steps the merge code needs to do. It needs to include what args it will get when it is called and what it will return.

    It sounds like the merge is just a connecting...
  23. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Are the lists sorted? Does their order matter when the lists are merged?

    Will the old lists be lost when the new list is created or will the nodes in the new list be copied from the old lists?

    ...
  24. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    The node at the end of the first list would be connected to the first node of the second list.
    Take a piece of paper and draw some nodes for two lists. Connect the nodes in each list with a line...
  25. Replies
    49
    Views
    6,130

    Re: Sort and Merge Two Linked List

    Set the next pointer at the end of one linked list to the first node in the other linked list.



    That will be easy. There are none in java.


    The posted code has compiler errors. Do you get...
Results 1 to 25 of 25