Implement a hash table and binary search tree

Assignment Help Data Structure & Algorithms
Reference no: EM133553526

Data Structures

Assignment - To measure the student's ability to implement and/or use complex data structures (e.g., hash tables and binary search trees) to solve an underlying
problem in C++.

Overview
This assignment will test your ability to implement a hash table and binary search tree, then use their functionality to implement a basic spell-checking program. The program will use a hash table with binary search tree chaining as a dictionary, which will be populated with a list of ≈3000 words (see here for the basis of the word list: Oxford 3000). Your spell-checker will then have basic functionality to determine if a word is spelled correctly (i.e., if it exists in the hash table) and suggest potential corrections if spelled incorrectly. For the purposes of this assignment, the potential corrections will be limited to single-character substitutions and swapping of adjacent characters.

The Tasks

The first task is to implement templated BTNode, BinarySearchTree, and HashTable classes. For each class, you are provided with the header file and must adhere to its definitions. These headers will be substantially similar to those discussed in class and in lab but differ in a few minor ways. In particular, the binary search tree has been modified to work with keys rather than data objects, much the same as the hash table. Furthermore, the hash table uses a binary search tree in each cell for collision avoidance.

Next, you will implement the SpellChecker class. As mentioned previously, your spell- checker will have only basic functionality to determine if a word is spelled correctly (i.e., if it exists in the hash table), suggest potential corrections if spelled incorrectly, and to insert and remove words.

Firstly, you will use a hash table of Word objects to represent a dictionary of words. A word can be assumed to be spelled correctly if it exists in the dictionary (i.e., hash table). Conversely, a word that does not exist in the dictionary can be assumed to be spelled incorrectly.

If a word is spelled incorrectly (i.e., it is not in the hash table), the program will present the user with some suggested corrections. In particular, it will present correctly spelled words that are either single-character substitutions (e.g., "analyze" should result in the suggestion of "analyse" by swapping "z" for "s") or can be formed by swapping of adjacent characters (e.g., "tets" should result in the suggestion of "test" by swapping "ts" for "st"). Notably, both suggestions can produce multiple words and all words from both sets of suggestions should be presented to the user. For example, "etst" should suggest both "test" (using adjacent swap) and "east" (using single substitution).

Furthermore, the user can manually insert words to the dictionary, as well as remove words.

BTNode

The BTNode class is a templated version of a node in a binary tree and should be implemented as discussed in lecture. For a full list of methods required and some important details, you should examine the bt_node.h file and its associated documentation.

BSTree

The BSTree class is a templated version of a binary search tree and should be implemented recursively as discussed in lecture. Do note, the signatures of some methods have been modified slightly, particularly to use keys rather than data objects. For a full list of methods required and some important details, you should examine the bs_tree.h file and its associated documentation.

By default, your binary search tree should print an inorder traversal, but should provide functionality to print according to the three traversals discussed in lecture (preorder, postorder, and inorder).

HashTable

The HashTable class is a templated version of a hash table that uses a binary search tree for chaining and should be implemented as discussed in lecture. For a full list of methods required and some important details, you should examine the hash_table.h file and its associated documentation.

You are to use the built-in std::hash<std::string> as the hash function and should simply copy the hash function definition from Figure 1 to your HashTable class.

SpellChecker

The SpellChecker class contains the main logic of the spell-checking process and uses your HashTable class to support the dictionary functionality. That is, this class must use the public interface provided by your HashTable class to support its operations, as further detailed in the header file. Your hash table should be initialised with 101 cells, as is the default size in the header file, but should work for any provided capacity. For a full list of methods required and some important details, you should examine the spell_checker.h file and its associated documentation.

The spell_check method will accept a std::string and determine whether it is spelled correctly. If the word is spelled correctly, a message indicating it is spelled correctly should be displayed to the console: "<word> is spelled correctly.". If the word is not spelled correctly, the user should then be presented with one of two messages. If there are no potential suggestions, the user should be presented with the message "<word> is not spelled correctly. There are no suggestions." Alternatively, if there are potential corrections, the user should be presented with the message: "<word> is not spelled correctly. Here is a list of suggestions: " followed by a list of suggested corrections, one per line. An example of the program execution is shown in Figure 2.

Figure 3 shows a skeleton for the similar_words method, which demonstrates how to perform each of the modifications that are used to generate potential suggestions. However, it does not validate whether the suggestions are valid and does not include any suggestions in the vector. You must complete the implementation to ensure only correct suggestions (i.e., existing words) are added to the vector.

Reference no: EM133553526

Questions Cloud

Make sure to think of ten questions for the interview : Make sure to think of ten questions for the interview. Next, you will create a Word document and write the interview questions and answers.
What medication is used to treat this patient overdose : On physical examination, his Glasgow coma score is 9. What medication is used to treat this patient's overdose?
What year did the mormons practice polygamy : In the late 19th and 20th century, doctors thought that masterbation was harmful. What two devices were created to keep boys from reaching/achieving full
Identify exact flight information : Identify exact flight information e.g., airline's name, flight number, scheduled flight departure time, as well as projected arrival time at destination.
Implement a hash table and binary search tree : Implement a hash table and binary search tree, then use their functionality to implement a basic spell-checking program
What made maddy run, write a reflection on your thoughts : What Made Maddy Run," write a reflection on your thoughts of the story of Madison Holleran. Please share what you took away
Reports of failing school districts : With recent reports of failing school districts, should the government provide school vouchers that allow parents to send their children to any school, public,
Share your food safety knowledge with your family and friend : This is for you to demonstrate what you have learned and how you would share your food safety knowledge with your family and friends.
Describe how you would present the role of team leaders : explanation of how, as a nurse executive, you would make the case to team leaders in a healthcare setting for the importance of developing a culture

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Complete binary tree

Think about an n-node complete binary tree T, where n=2^d - 1 for some d. Each node v of T is labeled with a real number x_v.

  Create a doubly linked list with the given information

When the program opens it will read contact information from a text file and create a doubly linked list with the information.

  Explain the advantage of using arrays as the primary index

Explain the advantage of using Arrays as the primary index. Now, state which DS you would use for the primary index and why?

  Write a xml schema for the validation of the document notes.

write a XML schema for the validation of the document notes.xml. Write the schema according to the following three approaches;1.- Based on the document structure2.- Structured (bottom-up design)3.- Type-based (top-down design)

  Compare three implementations for a priority queue

Compare and contrast three implementations for a priority queue in terms of what the data structures represent; a sketch of the principal routines.

  Develop a class template for general search trees

Ask you to develop class templates for various trees. You should also write driver programs to test your answers as instructed at the end of this chapter.

  Compare running time of standard implementation of heapsort

Suppose that you have a hole at node X. The normal perc Down routine is to compare X's children and then move the child up to X if it is larger.

  Draw the two points of intersection in red

Output: Draw a circle centered at with the given radius in a window with coordinates running from -10,-10 to 10,10. Draw a horizontal line across the window with the given y-intercept. Draw the two points of intersection in red. Print out the x va..

  What is the output from the given sequence of priority queue

What is the output from the following sequence of priority queue ADT methods: insert(5,A), insert(4,B), insert(7,I), insert(1,D), removeMin(), insert(3,J).

  Implement the array-based stack class

Implement the array-based stack class - Use it in the client code to convert an infix expression into post-fix expression, and compute the result.

  Write a program that uses the bubble sort algorithm

You need to write a program that uses the bubble sort algorithm and load data into an array and then sort it into ascending order. It should output the first five and last five numbers from the file both before and after the sort.

  Question 1 consider we implement a priority queue as a heap

question 1 consider we implement a priority queue as a heap. suppose the queue has thousands of elements. consider

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd