Question
Can anyone finish this for me? Thank you so much. Complete the implementation of B-Tree using the class set as shown in the attached C++
Can anyone finish this for me? Thank you so much.
Complete the implementation of B-Tree using the class set as shown in the attached C++ and header files. You should closely follow the pseudo code/algorithm described in the book in your implementation. Write a driver code that will test each function in your B-Tree implementation.
I can post links to the book and code if needed. The template class has missing code, and the source.cpp. I believe the set.h is fine.
//SOURCE.CPP
#include
using namespace std; using namespace main_savitch_11;
int main() { set
return 0; }
//SET.H
// FILE: set.h (part of the namespace main_savitch_11) // TEMPLATE CLASS PROVIDED: set
#ifndef MAIN_SAVITCH_SET_H #define MAIN_SAVITCH_SET_H #include
namespace main_savitch_11 { template
// CONSTRUCTORS and DESTRUCTOR set(); set(const set& source); //THIS NEEDS TO BE FIXED ~set() { clear(); }
// MODIFICATION MEMBER FUNCTIONS void operator =(const set& source); void clear(); bool insert(const Item& entry); std::size_t erase(const Item& target); //THIS NEEDS TO BE FIXED
// CONSTANT MEMBER FUNCTIONS std::size_t count(const Item& target) const; //THIS NEEDS TO BE FIXED bool empty() const { return (data_count == 0); }
// SUGGESTED FUNCTION FOR DEBUGGING void print(int indent) const; //THIS NEEDS TO BE FIXED
private: // MEMBER CONSTANTS static const std::size_t MINIMUM = 2; static const std::size_t MAXIMUM = 2 * MINIMUM;
// MEMBER VARIABLES std::size_t data_count; Item data[MAXIMUM + 1]; std::size_t child_count; set *subset[MAXIMUM + 2];
// HELPER MEMBER FUNCTIONS bool is_leaf() const { return (child_count == 0); } bool loose_insert(const Item& entry); std::size_t get_index(const Item& entry); bool loose_erase(const Item& target); //NEEDS CODE void remove_biggest(Item& removed_entry); //NEEDS CODE void fix_excess(std::size_t i); void fix_shortage(std::size_t i); //NEEDS CODE set* b_tree_copy(const set* root_ptr); //THIS NEEDS TO BE FIXED void b_tree_clear(set*& root_ptr); // NOTE: The implementor may want to have additional helper functions }; }
#include "set.template"
#endif
//SET.TEMPLATE
//#include "set.template" // Include the implementation. #include "stdafx" #include
using name space std; namespace main_savitch_11 {
template
template
template
template
template
template
template
template
template
if (i < data_count && !(entry < data[i]) { return false; }
if (child_count == 0) { for (std::size_t ix = data_count - 1; ix >= i; ix--) { data[ix + 1] = data[ix]; } data[i] = entry; data_count++; return true; }
bool b = subset[i]->loose_insert(entry);
if (subset[i]->data_count == MAXIMUM + 1) { fix_excess(i); } }
template
subset[i + 1] = new set
for (std::size_t ix = MINIMUM + 1; ix < MAXIMUM + 2; ix++) { subset[i + 1]->subset[ix - MINIMUM - 1] = subset[i]->subset[ix]; } for (std::size_t ix = MINIMUM + 1; ix < MAXIMUM + 1; ix++) { subset[i + 1]->data[ix - MINIMUM - 1] = subset[i]->data[ix]; }
subset[i]->data_count = MINIMUM; subset[i + 1]->data_count = MINIMUM; subset[i]->child_count = MINIMUM + 1; subset[i + 1]->child_count = MINIMUM + 1;
for (std::size_t ix = data_count - 1; ix >= i; ix--) { data[ix + 1] = data[ix]; }
data_count++; data[i] = subset[i]->data[MINIMUM]; }
template
//THESE 3 need to be finished
template
//CODE HERE
}
template
CODE HERE
}
template
//CODE HERE
}
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started