Search:

Type: Posts; User: colerelm

Page 1 of 2 1 2

Search: Search took 0.22 seconds.

  1. Replies
    1
    Views
    136

    Cannot push onto a stack

    For some reason, whenever I try to push my objects onto a stack, I get a null pointer exception. This is what I have:

    private Stack<BSTnode<K>> myStack;

    private void preOrderTrav(BSTnode<K>...
  2. How to convert an array of integer to generic type?

    I have an array,
    private T[] elements;. I would like to do this ideally:



    if(elements[index] == null){
    elements[index] = 0;
    }
    elements[index] = elements[index] + 1;
  3. Replies
    0
    Views
    273

    Working with log math function

    I want to output to calculate the following:

    0 - (3/6)logbase2(3/6) = 1/2

    I have this in my program:

    double ratio = 3/6;
    x = x - (ratio * (logbase2(ratio)));

    which should equal .5 but I...
  4. Replies
    2
    Views
    560

    How to write Entropy class in java?

    I found documentation for a class that has some methods I really find useful located at this website.

    Is the code for these methods publicly accessible through this webpage or should I email the...
  5. Replies
    4
    Views
    389

    Re: Creating an algorithm to do this

    I've asked myself that many times. This is my train of thought:

    "What's the biggest number we have to search for?" --I have a function that will tell me this so I have this part solved.
    "How many...
  6. Replies
    4
    Views
    389

    Creating an algorithm to do this

    I'm struggling to wrap my head around how I could calculate a seemingly simple algorithm and am wondering if anyone can provide some guidance.

    I have a 2D array of type int that stores one digit...
  7. Replies
    1
    Views
    959

    Datatable equivalence in Java 6?

    Does anyone know of any equivalent class in Java that has similar properties of a DataTable from C#?

    Transitioning over to Java from C# and was just curious.


    Thanks
  8. Replies
    4
    Views
    286

    Re: Comparing two objects

    What if I have an equals method in my player class but I want to compare two player objects outside that class? How could I, for example, check to see that an element of an array of type player is...
  9. Replies
    1
    Views
    340

    Serialization of lists

    I have a list which I save by the following:

    public void saveList(ArrayUnsortedList<Wrestler> listOfWrestlersToSave) {
    System.out.println(listOfWrestlersToSave);
    try{...
  10. Replies
    4
    Views
    286

    Comparing two objects

    I have two objects, player1 and player 2. These two objects have properties: String first name,String last name, double weight and int grade. I want to create a method that takes in a player object...
  11. Replies
    2
    Views
    327

    Referring to cases

    If I have a switch-case block like:


    switch(i){

    case1:
    blah1;
    break;

    case2:
  12. Replies
    2
    Views
    397

    Implementing the compareTo method?

    I have an assignment that's asking me to create a method which "Implements the compareTo method provided by the Comparable interface. Allows two objects to be compared based on sortKey(sortKey is...
  13. Replies
    2
    Views
    472

    How to sort alphabetically?

    If I have a list of strings within an array, say:
    [0] = jones
    [1] = apple
    [2] = struggle
    [3] = zebra

    How can I alphabetize them and place them into another array, in correct alphabetical order?
  14. Replies
    1
    Views
    434

    Java UML diagram question

    I have a java program to write and the professor gave us a UML diagram to follow. It all makes sense except for the part where there are dollar signs. What do these dollar signs mean? Here's what it...
  15. Replies
    1
    Views
    445

    Big-O Notation question

    I am working with this bit of code for this question:


    public boolean remove (T element)
    // Removes an element e from this list such that e.equals(element)
    // and returns true; if no such...
  16. Replies
    2
    Views
    326

    Why does this equal that?

    Why is it that this method returns true? I'm supposed to write an equals method that returns true if both rectangles are similar (My assumption of a "similar rectangle" is one which has the same...
  17. Replies
    3
    Views
    324

    Re: How to replace dollar signs with ""?

    I tried that...It still didn't work :\

    The string value doesn't become changed at all
  18. Replies
    3
    Views
    324

    How to replace dollar signs with ""?

    I have a program that prompts the user for an entry and they could potentially enter in a lot of things, but I want to catch the dollar signs and convert them to "" in terms of strings. I've tried...
  19. Re: Checking if number is in between two other numbers?

    lol that's what im trying to figure out....What I've thought of so far was thinking of it as a distance or absolute value....Or maybe even finding the median between both numbers and going from...
  20. Checking if number is in between two other numbers?

    Say I have three numbers A, B and C. How would I check if B lies between A and C without assuming that A < C or A > C?
  21. Replies
    2
    Views
    683

    Memory space required for java 6 queue

    I have a question from my assignment which I don't entirely understand. Can anyone please look at it and see if it's as easy as I thought it was or if I'm wrong, in which case can anyone help? This...
  22. What are the constraints on the argument values?

    public static int puzzle(int base,int limit){
    if(base>limit){
    return -1;
    }
    else
    if(base==limit)
    return 1;
    else
    return base * puzzle(base+1,limit);
    }
  23. Replies
    2
    Views
    408

    What would be the output of this?

    This was a homework assignment given to me and I got the answer (listed later), but I was wondering if anyone could check it over and see if i'm correct:
    a)


    //Assume that you can store and...
  24. Replies
    1
    Views
    334

    copying and comparing stacks

    How would I create a shallow copy of a stack? The interface method which I must implement is:

    MyStackInterface<T> copy();
    // Returns a shallow copy of this stack


    It doesn't make sense to...
  25. Replies
    1
    Views
    290

    Not sure what I'm supposed to do...

    So today I got this programming assignment which is due in a week but I don't even understand what is being asked of me. Since my professor sucks at getting back to me via email, I have come to the...
Results 1 to 25 of 30
Page 1 of 2 1 2