Implement a hash table and binary search tree

Assignment Help Data Structure & Algorithms
Reference no: EM133701151

Purpose - 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++.

Introduction
The Mythos Creatures are legendary creatures that have existed since the dawn of time, each embodying the elemental forces of nature. These beings maintain balance and protect the world from chaos. Each Mythos Creature is a guardian of a specific domain, from fiery mountains and frozen tundras to enchanted forests and vast oceans. They possess unique powers that reflect their elemental origins and are revered by those who understand their true nature. As the world changed, the Mythos Creature adapted, forming an intricate web of life that ensures harmony and stability across the realms. Tales of their exploits are passed down through generations, inspiring awe, and respect for the natural world they so fiercely protect.

As a seasoned creature tracker, you've dedicated your life to studying these elusive Mythos Creatures. From the fiery peaks where the Blazefox reigns to the icy expanses patrolled by the majestic Frostwing, your journey has taken you to the most remote and dangerous corners of the earth. Armed with your knowledge and keen instincts, you track these awe-inspiring beings, unravelling the mysteries of their existence and ensuring that their secrets are preserved and protected from those who would exploit them. Your encounters with the Mythos Creatures are tales of wonder and peril, each discovery bringing you closer to understanding the delicate balance they maintain in the natural world.

Overview
This assignment will test your ability to implement a hash table and binary search tree, then use their functionality to implement a creature tracker that will maintain information about the creatures you have encountered along your journey. The creature tracker program will use a binary search tree to store creature details and a hash table (with separate chaining) to store information about the different types of creatures. The creature tracker will then have basic functionality to add creatures, remove creatures, and query various information.

The Supplied Files
This section gives an overview of the files that you are provided as part of this assignment, none of which you should modify. You are not provided with (skeleton) implementation files - you will be expected to create these files from scratch. You are recommended to take some time to understand the overall structure of the program before starting your implementation.

main.cpp - contains the main function and the logic to initialise the creature tracker dictionary and perform basic operations. This file should not be modified.

empty_collection_exception.h - contains the definition of an exception that can be thrown when an operation is attempted on an empty tree. Note: there is no accompanying .cpp file - the .h file contains the complete definition and implementation of the exception. This file should not be modified.

creature.h - contains the header for the Creature class, which includes the instance variables and behaviours that a creature contains. This file should not be modified.
creature_type_stats.h - contains the header for the CreatureTypeStats class, which includes the instance variables and behaviours for the object that maintains information about a particular type of creature. This file should not be modified.

bt_node.h - contains the header for the BTNode class, which includes the instance variables and behaviours that the binary tree node contains. This file should not be modified.

bs_tree.h - contains the header for the BSTree class, which includes the instance variables and behaviours that the binary search tree contains. This file should not be modified.

hash_table.h - contains the header for the HashTable class, which includes the instance variables and behaviours that the hash table contains. This file should not be modified.
creature_tracker.h - contains the header for the CreatureTracker class, which includes the instance variables and behaviours that the creature tracker contains. This file should not be modified.

makefile - the makefile for the project, which outlines the build recipe. The -g flag is set for you to make debugging and/or memory leak detection more convenient, should you wish to use these tools. This file should not be modified.

creatures.txt - a text file containing a list of 250 Mythos Creature records. Each creature has a name, type, and power level. This file should not be modified. You may consider using a smaller version for testing if you wish.

Running the Program
Of course, you will need to ensure the program is compiled prior to running it. You can use the supplied makefile for this - it will produce an executable called CreatureTracker. The program can be executed as normal using the command:

./CreatureTracker

This will read a file named creatures.txt to populate the creature tracker with the data of 250 creatures that you have encountered. Several operations are then performed to test its functionality. However, this testing is not exhaustive and you are encouraged to tester broader functionality. An example of the program execution is shown in Figure 2, Figure 3, and Figure 4 - it is provided in 3 separate figures given the length of output. Note: not all output is captured in these screenshots.

The Tasks

The first (and simplest) task is to implement the Creature and CreatureTypeStats classes. These classes will require a few operators to be overloaded such that they can be used in the tree and hash table and be inserted into a stream for printing.
The next task is to implement the templated BTNode, BSTree, 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 lecture and lab but may differ in a few minor ways. In particular, the hash table will use std::list for separate chaining and a few function definitions have been modified and/or added for completeness.

Finally, you will use your BSTree and HashTable classes to provide the expected functionality for the CreatureTracker class.

Some additional details about each class are provided below, but you should also examine the documentation in the provided files, which also contains important information about the expected behaviour.

Creature

The Creature class is a simple data class that stores information about a creature, particularly its name, type, and power rating. For a full list of methods required and some important details, you should examine the creature.h file and its associated documentation.

CreatureTypeStats

The CreatureTypeStats class is a simple data class that stores information about a specific type of creature, particularly the type, a count of the number of creatures of that type, and the

total power of creatures of that type. For a full list of methods required and some important details, you should examine the creature_type_stats.h file and its associated documentation.

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. 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 all three traversals discussed in lecture (namely preorder, postorder, and inorder).

HashTable
The HashTable class is a templated version of a hash table that uses a linked list for separate 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.

Note: you will notice that hash_table.h contains a few helper methods implemented for you. For example, Figure 1 shows the hash function, which you are expected to use.

Additional helper methods are provided to support operations you will need to perform with the std::list, such as finding, removing, and printing items. You are encouraged to review these methods, and use them where appropriate. Further details about when a helper method may be appropriate are given in hash_table.h.

CreatureTracker
The CreatureTracker class contains the main logic of the creature tracking process and uses your BSTree and HashTable classes to support the functionality, 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 creature_tracker.h file and its associated documentation.

The add_creature method will accept the name, type, and power of creature and should then record this creature's information. This includes both inserting a Creature object into the tree and adding or updating a CreatureTypeStats object in the hash table. Conversely, the remove_creature method should remove the Creature object from the tree and update the CreatureTypeStats object accordingly. Particularly, the CreatureTypeStats object should be removed from the hash table when no creatures of its type remain.

Reference no: EM133701151

Questions Cloud

Researching options to help manage his glucose : A patient with Type 2 Diabetes has been researching options to help manage his glucose.
Some details about your present relationship : Can you provide some details about your present relationship? Have there been instances where you felt threatened in your ongoing relationship?
How do different types of natural sweeteners compare : How do different types of natural sweeteners compare to artificial sweeteners in terms of their impact on human gut microbiota composition and metabolic health?
Describe the pathophysiology of hypertension : Describe the pathophysiology of hypertension.? What risk factors are present in this case study?? Describe the pathophysiology of myocardial infarction.?
Implement a hash table and binary search tree : Measure the students ability to implement and/or use complex data structures (e.g., hash tables and binary search trees) to solve an underlying problem in C++
What is the purpose of enteric coated tablets : What is the purpose of enteric coated tablets? What special instructions/precautions should you give your patients?
Experiences of burnout in new graduate nurses : What are the experiences of burnout in new graduate nurses in the first three years of professional practice?
Identify groups with diverse cultures and diverse abilities : Identify two groups with diverse cultures and/or diverse abilities in your community. How you might engage these groups to discover how best to help.
What is the main ingredient in gelatin : What is the main ingredient in gelatin? What is a protease and what does it do? What happens to an enzyme when it is heated to a very high temperature?

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Transmitting image using raster scan order

If we were to transmit this image using raster scan order, after 15 seconds how many rows of the image will the user have received?

  Explain the need for complex data structures

Explain the need for complex data structures. Explain the design and application of arrays to program logic and data manipulation.

  Order statistic tree to count number of inversions in array

Demonstrate how to use an order-statistic tree to count the number of inversions in an array of size n in time O(n lg n).

  Addition and subtraction of numbers in binary

Addition and Subtraction of numbers in binary and round to the nearest decimal number with three significant decimal digits

  Define sorting algorithms in terms of the complexity

Compare and contrast some of the most important sorting algorithms in terms of their complexity and when they are used. Define all types of the sorting.

  Compare client-server computing and cloud computing

Compare and contrast client-server computing and cloud computing. Determine the major risks and rewards that each offers to the organizations that use such approaches. Justify your response.

  Create a flowchart to determine the cause of problems

Assume you are the 1st level help desk technician at a average sized corporations. Your job is to handle the initial calls from corporation  computer users with personal computer related problems.

  Algorithm to find the second largest integer

Write an algorithm to find the second largest integer in a list of n integers. How many comparisons does your algorithm do in the worst case?

  Calculation of a binary tree

Computations of a Binary Tree Write a function in C programming language that can find and return the height of a Binary Tree.

  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.

  Write operations for binary file operations

C++: templates, char arrays and their null terminated representation, sizeof operator, seekp, seekg, read and write operations for binary file operations, eof() function, proper opening and closing of files with different arguments, code to proces..

  Discuss the use of a binary tree

Discuss the use of a binary tree when searching for keys in an array. Discuss the use of a binary tree when searching for keys in a linked list.

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