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...
Type: Posts; User: EDale
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...
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)
------------------------
...
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...
Here is what I got
import java.util.Iterator;
public class SinglyLinkedList<E> {
private static class Node<E> {
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,...
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?
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...
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...
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...
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...
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 =...
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...
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...
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...
Thanks so much! I'll post my solution when I figure it out!
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...
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...
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...
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?
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...
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...
I got it. Thank you so much! This was my last programming assignment of the semester. So glad it's over!
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...
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.
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...