Using Java implement the following data structures and associated algorithms. Implement and automatically run the required test cases. Make sure your submission compiles and runs on AFS.
Tries
A Trie is a type of Tree that can be used to efficiently represent a set of strings. Tries can also be used to implement Dictionaries where the keys are strings. The edges in a Trie represent characters. The sequence of edges on a path from the root to another node represents the characters, in order, in a string (if that string was inserted into the Trie). Each node stores pointers to its children and a boolean value indicating if the node terminates a path that represents a string inserted into the Trie. The figure below shows the Trie built from the set of strings on the left. In the figure below the path from the root to “act” follows the edges labeled a-c-t, in the set of strings shown on the left. Note that the strings are not actually stored at the nodes (it’s shown that way for illustrative purpose) but they can be reconstructed from the sequence of edges using a preorder traversal of the Trie.
In this project you will implement a simplified version of a Trie. Specifically:
The Trie must be implemented using a linked node implementation where each node stores (1) an array of pointers (or references, if using Java) to its child nodes and (2) a boolean flag indicating if the node represents the end of a path that represents a string in the Trie.
For simplicity, you can make the following assumptions:
1. All strings will are lower case
2. All strings will consist of ASCII characters
3. All strings will contain alphabetical characters only (a-z)
4. All nodes store a fixed-sized array of pointers to child nodes (specifically, 26, one for each lowercase ASCII character).
Each bucket of the child node pointer array is mapped to a corresponding ASCII character. For example, if you name the node’s child pointer array children then children[0] will represent the edge for the character ‘a.’ If such an edge exists then there will be a pointer to a child node. If no such edge exists then children[0] will store a null pointer. The same is true for the edge
representing the character ‘b’ (stored at children[1]), character ‘c’ (at children[2]), etc. Note that the above figure does not follow this scheme, but the figure below does.
In this project you will implement a Trie data structure and the following algorithms:
InsertString(String str) – Inserts a new String str into the Trie. The Trie is initially empty. Note that, as you insert the characters of str that some of the rquired nodes may already exist. As you are traversing the Trie (according to the characters of str) you may need to add new nodes into the Trie or you may be able to reuse nodes that already exist.
For example, if you insert “and” after you inserted “ant” then nodes and edges for the “a” and “n” already exist and only an edge“d” will need to be inserted as a link to the appropriate child of “n.” Similarly, if you try to insert the word “an” after “ant” and “and” have been inserted then the node terminating the path with the edges “a” and “n” already exists and the only operation required is to switch the node from not representing a word to representing a word.
StringExists(String str) – Returns a boolean value indicating if the String str is stored in the Trie.
PrintStrings(String str) – Prints all of the Strings inserted into the Trie to standard output. This requires a preorder traversal of the tree. The preorder traversal must be implemented using the stack data structure described below.
Stacks
The PrintStrings operation will require a preorder traversal of the Trie. While this procedure could be implemented recursively, it is often implemented iteratively using a Stack. You will implement an array-based stack called ArrayStack to support PrintString’s preorder traversal of the Trie. ArrayStack will consist of the following operations: push(), pop(), top(), and isEmpty(). You cannot assume that the ArrayStack only stores pointers/references to Trie nodes, as you will also need a way to keep track of the current String. One option is to have the stack store entries that consists of a TrieNode and a String storing the characters on the path from the root to the current node. The array-based stack will start at some initial minimum size and grow/shrink as elements are pushed or popped. This should be done in an efficient way (i.e., don’t create a new array that is one size larger than the previous array when a new element is pushed onto the stack).
Test Cases
These must be run automatically by your program. Your program will take no user input.
Insert the following Strings into the Trie, in the following order: ant, cat, zoo, zone, bat, band, bean, fish, fishing, banana, catch, cannot, can, find, fix, any, zone, zoos, zoo
Determine if the following Strings are in the Trie: fin, find, baton, bat, ban, catching, ant, zones, can
Print all of the words stored in the Trie using the PrintStrings operation.
Example Code (in Java, untested, not compiled)
public class Trie {
private TrieNode root = null;
public Trie() {
}
public void insertStr(String str) {
}
public boolean strExists(String str) {
}
public void printStrs() {
}
}
public class TrieNode {
private boolean strInTrie = false;
private final TrieNode [] children = new TrieNode[26];
public TrieNode() {
}
}
public class ArrayStack {
private ??? [] arr;
public ArrayStack() {
}
public void push(???) {
}
public TrieNode pop() {
}
public TrieNode top() {
}
public boolean isEmpty() {
}
}
Hello
I am Java and Algorithm expert and interested in this project. I have reviewed the attached file and confident to handle it perfectly.
I have a lot of experience in helping in students with assignments, so I will keep codes well documented and simple.
Please communicate to discuss further.
Regards
Anshu
Hello
My name is Ahmed, i'm a top rated freelancer.
i worked over 250 projects and over 600 hours doing java projects.
plus i passed freelancer java exam with top 15%
plus i got 2 java certificate 1Z0-803 and 1Z0-804 with 3+ years experience.
small overview of feedback on my profile
"you want to get your projects completed with quality? Hire Ahmed. Highly recommended."
"Thoroughly satisfied with Ahmed, and would recommend him for anyone looking for an excellent java developer!"
"Highly recommended. Very smart and well experience"
looking forward to work with you
Regards
Hi there,
I'm a senior software developer who have over 300 completed projects with 100% positive reviews and my account also is qualified by this site as a Preferred-freelancer. My portfolio: https://www.freelancer.com/u/DucNA.html
Could you please share me more details? Then I will check and let you know my estimation (time and effort) for this project.
Thanks & best regards,
Duc Nguyen
Hi, I am experienced software developer and I am ready to complete this project. You can find more information about me and my professional experience on the my freelancer profile page. We can discuss all details in the private chat. Please leave me any messages even if I am offline. I am looking to have positive cooperation with you.
Hi , hope you are doing well
i am software engineer with 5 years experience in software development using Java
I can help you to complete this project, also i can provide demo for your requirements
hope to contact me to discuss more about your project
Thanks
I have good knowledge in below mentioned skills by you. I also have some certifications in Java. I can share some of demos with you if you want for better understanding. Currently I'm working on a banking project in an IT company using Java, jsp/jsf, hibernate, spring, software architecture and database programming. And most importantly, you will get your project done before the deadline.
Hi,
I am a software developer with 9+ years of experience in Java/J2EE and I have been writing algorithms for long.
I believe I can write the program and deliver it to you with test cases as well in given time and budget. Please revert back if you like my proposal.
Thanks
Hi,
Can you share more details about your project?
I have done similar project and understood the project outline. Please give me a chance. A trial will convince you. Looking forward to work with you.
Hello. I've wrote your Java assignment. It's pretty easy for me and I can do it for you tomorrow, because now I haven't time. If this interested you, please, contact me.
Best Regards
Giorgi.
I have very good experience in java.
I've implemented many algorithms in java and worked in trees too.
I've read your requirements and I can do that , I can implement tries as mentioned in descriptions
Hi,
Kindly watch my latest review regarding java's project. I have more then 10 years of experienced in java, i did lots of work on Swing,AWT, JDBC, servlet, JSP, Spring
Kindly initiate the discussion
i have two years of experience in java programming. i have done some projects succesifully such as store management systems in java. i use netbeans for my programing. i promise good results once awarded the project
With my background in computer science and multiple projects done during my undergraduation, I am a perfect fit for this job. I had implemented trie in C++ in my under graduation period and have done multiple different projects in JAVA itself. So this is something which I will be able to deliver you in 1 day.
In case you are interested, ping me and I will start working
6 years of programming,having programmed extensively in C++C#,MT4,Java, C,VB, AI,ASP
Excel programming etc and many more languages.
Ability to consult and Program to clients need and ensuring deadline (Single clients/Industry).