Michael Grünau

Ranch Hand
+ Follow
since Oct 30, 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 Michael Grünau

So the complete task for the Method was to find the Object in my tree, track the path and build the name via the tracked path.

Below is my complete approach:

1 month ago
That is correct.

My Helper-Method looks like this atm.

Should I implement a List<Node> as an argument inside the helper-Method?
1 month ago
Hello Friends, its me again....back with another problem.

I am trying to write a method which goes through my tree, finds the element given to the function and gives back the path (nodes) I traversed while I was searching for that element/ object.

My Idea was to work with a few helper-methods to solve the problem.

1. Write a method to check if there is a path from each child of my current node.(There is always only one child-node option that works at each level)

2. If there is a path I want to save the node and check the same thing for the child. I don't care about the nodes that don't have a path.

My questions now:

- Is there a smooth way to store the my paths? Thought about an ArrayList where I add the [i] that leads to the correct path.
- Does my pathExist function work? To be honest I am not even sure if i get the correct result that I want...

Hope this is not to vague and someone can maybe give me a Tip or send me a link to check a concept?
I only find Binary-Tree solutions.

Thank you very much in advance.
1 month ago
Thank you very much for the help!

I actually saw that it was redundant and changed my code accordingly just a Minute ago.
1 month ago
@Carey Brown: That might be true, but I am unfortunately just the poor student working on the tasks, restricted by the cruelty of our education system spending 10 hours on a Saturday to implement three methods.

So I came up with the following approach for my size() Method:

To be honest, I don't really think it is working because the count variable should reset every time when I call the method.
I have no idea how I can include the variable and keep it in the recursion and the loop without using another method.
1 month ago
Exactly, and if it is a penguin we want to add +1 to the count and if not just check if the children are a penguin.
1 month ago
It is possible that every node is a Penguin.

So it is basically just node count method based on a specific parameter.

1 month ago
And sorry.

Children is an array of Nodes with the length 26 - where children[0| stands for A, children[1| stand for B etc.
1 month ago
So the task is about concating chars to a String.

There are random names and each node beginning with an empty "" stands for a Character in the Alphabet.
So we basically have the option of 26 leaves per node to create names.

If we reach a node which builds a name together with its prior Chars we register the penguin(name) at this node. Otherwise we leave the nodes "empty".

For example:

Name: Allan

First Node: ""

Second Node: A

Third Node: AL


End: ALLAN - Register Penguin Allan
1 month ago
Thank you very much for the reply!
Correct, I want to pass the count back up the chain.

My problem is, that I saw a solution like your multiple times when I search the web but I don't want to count every node.
I only want to count the node if there is a penguin inside so: penguin != null .

How do I add my case to the count += child.size() ?
1 month ago
Sorry, my bad.
I just think it is always better to provide some code to questions so people can see how I tried to deal with the problem.

Thank you very much for the quick reply btw.

My problem is, that I understand how you can use recursion for Binary-Trees when you basically just have a right-left option.
In my case there is the probability of 26 nodes afterwards each representing a character in the alphabet (children = array with a length of 26).

I don't find a nice way to iterate through all these options and check if there is an object stored in them and check the next options again...hope this makes somehow sense.
So I can store the variable in a parameter call but aren't there ways where I can do it without it?
1 month ago
Hello Friends,

hope everyone is doing great.

I am working on a task for my University Project and I am super stuck a this point.
The task contains a tree in which we need to build a string with char concatenation.

My problem is that we need to write a method which counts the names we have build in this tree via recursive method calls.
What I don't understand is how I can save my count or add-up to this count during my recursive calls, I don't want to store the count in a parameter which gets called by a method.

Hope this is somewhat clear...

My approach using a Support-Method:

Thank you very much for the help!
1 month ago
Well let me explain the task to you.

It is about implementing an Iterator which returns digit sequences as a String.
We need to implement an Instanz of Iterator which goes through all the possible digit sequences of the given password length with the following conditions.

1. Digit Sequence of same number 0000
2. Digit Sequence rising 1234
3. Digit Sequence falling 4321
4. All the rest

We don't have a list where we can iterate over...
1 year ago
The Main Part of the Task is about working with Iterators so this should be implemented in a next() method.

Of course are there better options to check for the password but for this one the main point is that the next() call iterates over the values as described before.
1 year ago
Appreciate the help!!
Your code above is basically a neat way to create the increasing rows, correct?

For the moment I will try to come up with a solution by myself and maybe get back if I am stuck!
Thanks again!
1 year ago