Search:

Type: Posts; User: EDale

Page 1 of 3 1 2 3

Search: Search took 0.08 seconds.

  1. If a method calls a recursive method, does that make the method recursive as well?

    I think the answer is yes, but I'm not 100% sure. For example:



    public E last() {
    return root.getRightMostData();
    }

    public E getRightMostData() {
    if (right == null) return...
  2. Replies
    7
    Views
    1,704

    Re: Remove at index in singly linked list?

    Here is the output now:
    The size of the list is 6 and the list is given below
    [Donald ==> Brett ==> Issac ==> Dana ==> Dillon ==> Jonathan]

    Testing remove(int index)
    ------------------------
    ...
  3. Replies
    7
    Views
    1,704

    Re: Remove at index in singly linked list?

    Okay. Well I really don't have time to start a new project and try and write a smaller and simpler code so that you may see what my problem is here. I don't think I've been exposed to linked lists...
  4. Replies
    7
    Views
    1,704

    Re: Remove at index in singly linked list?

    Here is what I got



    import java.util.Iterator;

    public class SinglyLinkedList<E> {

    private static class Node<E> {
  5. Replies
    7
    Views
    1,704

    Remove at index in singly linked list?

    Okay so I've created a public E remove(int index) method, it works fine at removing. However, when it removes the node at index size-1, and then I try to add nodes at the end of the list afterwards,...
  6. Replies
    13
    Views
    1,594

    Re: Creating methods in a singly linked list?

    Perhaps... depending on how big the deck of cards is. So to write this method I would start off with a loop that compares the data to the argument... and then what?
  7. Replies
    13
    Views
    1,594

    Re: Creating methods in a singly linked list?

    So then if you go through the deck of cards and look at each card one by one, you wouldn't know which is the last one until you go through the whole deck. Would you then have to go through the deck...
  8. Replies
    13
    Views
    1,594

    Re: Creating methods in a singly linked list?

    Great, it worked, thank you.

    Well to find the suit of that last queen... every deck of cards should only have 4 queens, so you just look for the 4th queen and return the suit. So does this mean...
  9. Replies
    13
    Views
    1,594

    Re: Creating methods in a singly linked list?

    Right, it shows the error at the "i" in the line if(this.equals(getNode(i))). I'm trying to compare the argument to the node at index i. Could you show me how I can do this properly to correct the...
  10. Replies
    13
    Views
    1,594

    Re: Creating methods in a singly linked list?

    So for the error, it tells me "i cannot be resolved to a variable."

    Perhaps you didn't understand my question. For the removeLastOccurence method, the program needs to skip over the first and...
  11. Replies
    13
    Views
    1,594

    Re: Creating methods in a singly linked list?

    Okay well I did a little research and I think I've created the first two methods roughly. So lets start with the first two. Here is my code:


    public E remove(int index) {
    Node<E> temp =...
  12. Replies
    13
    Views
    1,594

    Creating methods in a singly linked list?

    I want to create 4 methods for my singly linked list class: public boolean removeFirstOccurence(Object o), public boolean removeLastOccurence(Object o), public int indexOf(Object o), public int...
  13. Remove at index method for singly linked list... what's wrong?

    Hi,

    I'm trying to create a public E remove(int index) method. What am I doing wrong here?



    /** removes the element at the specified position in this list.
    * Shifts any subsequent...
  14. Re: GCD Algorithm... could you help explain what kind of code I need to write?

    Here's what I got!



    public static long gcd ( long a , long b ) {
    if (a < b) return gcd ( b , a ) ;
    // a >= b
    if (b == 0) return a ;
    if (a%2 == 0 && b%2 ==0) {
    return...
  15. Re: GCD Algorithm... could you help explain what kind of code I need to write?

    Thanks so much! I'll post my solution when I figure it out!
  16. GCD Algorithm... could you help explain what kind of code I need to write?

    I have this homework question and I'm not 100% sure what it's asking. Could you break it down for me or write the skeleton code so I can get a better grasp of it?

    Write an alternative gcd...
  17. Re: Big O notation... can you check my answers for each code segment?

    So for #1 if n=10 then the loop executes 5 times. So if it's not O(log n) then it must be O(n) because the number of times it executes is proportional to n? Is that right?

    #3 yes that's what I...
  18. Big O notation... can you check my answers for each code segment?

    int sum = 0;
    for (int i = 0; i < n; i += 2)
    sum++; //I said this is O(log n) because if n=10 then this loop executes half the time. Not sure though. Or is it O(n)?




    int sum = 0;
    for (int i...
  19. Can a method be an abstract method without specifically declaring it is abstract?

    An abstract method is a method that has no body. If a method was declared as public Push push(); within an abstract class would it be abstract because it has no body?
  20. Re: How to call a static method within a static method in the same class?

    Well tune() takes an Instrument as an argument. So I actually should pass an Instrument argument within the parenthesis, right?. Which means I need to change the Instrument.tune() line to...
  21. How to call a static method within a static method in the same class?

    Hi guys,
    I'm trying to call a static method within a static method of the same class, but I can't figure out how. In the tuneAll method below, I'm trying to call tune(Instrument an Instrument). When...
  22. Re: Error message non-static method Person.getFirstName() cannot be referenced from a static context?

    I got it. Thank you so much! This was my last programming assignment of the semester. So glad it's over!
  23. Re: Error message non-static method Person.getFirstName() cannot be referenced from a static context?

    So are you saying I should create a person object within my Person class to be able to call methods from that class?
    Like:


    Person p = new Person("Joe", "Smith", "0394857");


    To call...
  24. Re: Error message non-static method Person.getFirstName() cannot be referenced from a static context?

    I'm talking about changing the getFirstName() method to static not the toString() method. I cant call the toString() because I can't even compile the student class.
  25. Error message non-static method Person.getFirstName() cannot be referenced from a static context?

    Hi, I have a super class Person and its sub class Student. Student has a toString method that prints out the details of the Student object including the first name. But I keep getting the error...
Results 1 to 25 of 58
Page 1 of 3 1 2 3