Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C++数据结构代写 | SENG1120/6120 Assignment 3

C++数据结构代写 | SENG1120/6120 Assignment 3



In lectures, we have discussed the benefits of using binary search trees and hash tables to store
information. In this assignment you will implement both and compare their performances in terms of
speed of access.


You are in charge of inventory management support in a factory. You are required to create binary
search tree and hash table data structures to store instances of a class MechPart. Both data
structures should have functions to add, remove, display, overloaded operators, among others. The
classes MUST be implemented as class templates. The binary search tree class must be called
BSTree and will use as nodes instances of BTNode. The hash table class must be named HTable.

You will be provided a demo file, a MechPart class, and a text file with a list of part codes and
quantities, and your classes need to interface with them. The binary search tree contents must be
printed using an inorder traversal. The hash table class must store the instances of MechPart in
an array of size 5,000, and the contents can be printed from position 0 to n-1, but only for those
positions that contain a valid entry. The hash function to be used is provided below. You can copy-
and-paste that code to your HTable class:

template <typename T>
int HTable<T>::hashfun(const T& value) {
int position = 0;
string temp = value.get_code();

for (int i=0; i<(int)temp.length(); i++)
position += (i+1) * (i+1) *;
return position % TABLE_SIZE;

A few points:

  • As you implement the classes, you will notice that even though HTable and BSTree are
    generic class templates, they only work with MechPart. That is, some public methods in
    the HTable and BSTree classes refer directly (and only make sense) with MechPart.
  • That was a design decision for this assignment. We could get around that, but it would make
    the assignment extremely challenging for most students.
  • When you implement the classes, start small and then add more and more functionality as
    you go. Start by implementing BSTree and comment out everything in the demo file and in
    the makefile that refers to HTable. This way, you can test your code as you go. Once
    BSTree is working, you can move on to HTable.
  • The solution provided in the next page is the result that you should get if your code is correct.
    The computational time will differ, as this was run in my personal computer, but the hash
    table will be faster than the binary search tree for sure.
  • What does the demo code do? The demo code reads the code and quantity of 100 mechanical
    parts from a file and populates the binary search tree. Then, it removes and adds some of the
    elements 100,000 times, and prints some statistics about the process. After that, it does the
    same for the hash table, and the program finishes.