Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!

tyler ruterbusch

+ Follow
since Mar 01, 2019
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by tyler ruterbusch

Updated. Although the HM.append(bucket); is probably wrong.
I am just trying to take the pseudo logic in my head and turn it into code  
2 weeks ago

Junilu Lacar wrote:
I don't know why you need N at all. You already initialize the bucket array to that length in the constructor so you can always use bucket.length where you're using N now.

Anyway, new StringBuilder(N) doesn't work the way you seem to think it works. myHashMap.length() will still be 0 so your for-loop won't even execute, not even once.

You chose a very poor name in myHashMap. First of all, that's a StringBuilder, not a HashMap. It's like declaring this:

What exactly do you want to iterate over anyway with that loop? Isn't it the bucket array?

Appreciate the tip. I want it to print it in the format above
each line being 0 - w/e and the (ascii value, word) next to the appropriate.

the length being based off the N of course.

2 weeks ago

Junilu Lacar wrote:My bad. I thought you were using a java.util.LinkedList, which also has an addLast() method but takes only one parameter.

ahaha nah. we have to be super peculiar about things. We can't use built-in libraries. So we have to build things from scratch.
This is why the toString method is causing me some grief
2 weeks ago

Junilu Lacar wrote:Does line 83 even compile?

As far as I can tell, addLast() only takes one argument:

Your code attempts to pass in two arguments.

It does compile. I mean there are no errors. Also, my add last method does have two arguments? The key and word.
2 weeks ago
This is my test class

2 weeks ago
I am having trouble formatting this properly. So we are using Superhero names, so what I am about to show is an example of how it's supposed to be
The toString method needs to print it out like this

0 (280,Cat)
8 (498, Apple) -> (298, Boy)
its assumed that the last number of their ascii values is where they are placed and boy and apple will be replaced with superhero names

2 weeks ago
Thanks for the help, but i got a whole new issue now ): aha

Campbell Ritchie wrote:Welcome to the Ranch

Thank you for using the code tags, but you didn't quite get them right (see this link): don't worry, I can correct that for you since you are new.

Remember the structure of a linked list.

Current node ≡ nextNode.prev


nextNode ≡ Current

So we assume you already have the appropriate place marked by having a ”live” reference to the current node. What you need to do is add a new node such that:-

  • Current ≡ newNode
  • ≡ (old)nextNode
  • newNode.prev ≡ Current node
  • (old)nextNode.prev ≡ newNode
  • Don't try methods out in a large class. Create a small class that has the requisite features and try it out in that first. You can do that with two old nodes and one new node to insert between them. Once you have done that, you can copy the technique into your larger class.
    I don't think what you are doing is going to work. Find the place to insert a new value before you create the new node. The new node should point to its two neighbouring nodes, not the end nodes. Then you can make the neighbouring modes point to the new node. Remember that if you get to the end node, its next field will point to null, so you cannot find a prev field to point to the new node.
    I think maybe you should make the node class private.

    All the above applies to an addBefore method, except that you look for end nodes the other way and prev might point to null.

    1 month ago
    I've tried giving it a break statement

    if(trailer ==

    1 month ago
    SO i changed up a few things. Now my reverseList is busted. I am having a hard time tracking it in my head so I know what to set to what. That is the hardest thing about linkedlists to me as a new java programmer.. .next can refer to like 5 positions
    1 month ago
    I've been trying to work on this method for about 4 days.  everything in my code is fine but the addAfter method.. I am super stumped on it, even when i draw it out.

    1 month ago