Aidan Johansson

Ranch Hand
+ Follow
since Apr 18, 2017
Cows and Likes
Cows
Total received
1
In last 30 days
0
Total given
0
Likes
Total received
2
Received in last 30 days
0
Total given
1
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Aidan Johansson

Yeah. You know what, I may not write the correct add() method as well.
5 years ago
Anagram trees. Because of the K and R algorithm, summaries are totally ordered, so we can use them as keys in a binary search tree. We will call it an anagram tree. The anagram tree’s keys are summaries, and its values are linear singly linked lists of strings, in which each string represents a word. The anagram tree is the basis for our efficient anagram finding program.
Here is my idea. We start with an empty anagram tree. Then we read words as strings from a text file. Every time we read a word, we construct its summary. Then we search for a node in the tree that has the summary as its key, using the "K-and-R" algorithm to control the search. If we find the node, then we add the word to the node’s list (if it’s not already there). If we do not find the node, then we add a new node to the list. The new node’s key is the summary, and its value is a list that contains the word.
5 years ago
Hello everyone,
I am trying to read in a text from a file and then using an algorithm to find the anagrams by using the concept of summaries. Suppose that a word is a string of one or more lower case Roman letters a through z, without accents, blanks, or punctuation marks. Also suppose that the letter a corresponds to 0, that b corresponds to 1, etc., up to z that corresponds to 25. (These are not the A SCII or Unicode codes for those letters!) For each word, we make an array of 26 integers, called a summary of that word. In the summary, the element at index k tells how many times the letter corresponding to k appears in the word. For example, if we have the word present, then its summary looks like this, where the large numbers are array elements, and the small numbe

After we have read all the words, there will be many nodes in the anagram tree, each with a list of one or more words. The words in each list are anagrams of each other, because they all have the same summary. We then traverse the tree, visiting each node. If we find a node whose list has only one word, then we ignore it, because that word is an anagram of only itself. However, if we find a node whose list has two or more words, then we print those words, because they are anagrams of each other.

I have error messages:

I need help. Thank you.
5 years ago
It is my honor. Thank you for doing that.
5 years ago
I think what you have said helps me a lot. Even though I may not fully understand what you are saying, I will keep in mind for future practice.
Thank you.
5 years ago
I am sorry I have been working all day. I just saw the comments. Is everything alright? Are we cool?
Thanks for helping out me.
5 years ago
I think it is confusing when I made a class called stack but it is implemented as a singly linked list.
I attached a drawing.
5 years ago

Stephan van Hulst wrote:Hugh, don't use names like Base for generic type parameters. Use single capital letters, such as T.



Thank you kindly.
5 years ago
Hello,
I am supposed to compare the top two elements without changing the nature of the stack, i.e I am not supposed to use peek(), pop(), or push() as the way we implement those methods in class will change the date structures. We can define stack differently and it all depends on how we use it, so the method of implementation is different. This is what I think. Thank you for sharing your thoughts.
5 years ago
I apologize. I forgot to inform you that I made a class call Stack but it actually works as a node. I define a node to have two slots: the first one is object and the next slots points to the next node. This class Stack implements a stack using a singly linked list. So I guess for my second comparison, I have to use:

Then:

Am I still right? Thanks.
5 years ago
Hello,
I would to write a method that accepts no arguments. This method has the following content:
1. If the top two elements on the stack are equal, then return true.
2. If the stack is null or has one element, return false.
3. Otherwise, if the top two elements are not equal, return false. Assume no element is null.

Here is my code.

Is this true?
Thank you.
5 years ago
That was all I could think of.
5 years ago
Step 1: To half into two lists: left and right and add the nodes to the front of these lists.
5 years ago
It works now. Thanks everyone.
5 years ago