1) Assuming a Linear Quotient hashing scheme is used and that the size of the pr
ID: 3813927 • Letter: 1
Question
1) Assuming a Linear Quotient hashing scheme is used and that the size of the primary storage area, N, is 19 and that the default prime is 2311, calculate the first 3 indices (home index and 2 collision probes) for the following pseudo keys: pk = 119,651 pk = 4,456,556 1st index (home) 2nd index calculated 3rd index calculated
2) Assuming the first two nodes inserted into the structure had the pseudo keys in question 1 with (key 119,651 inserted first), give the index of the array element that would store the location of the deep copy of these nodes. ___________________________ and __________________________
3) Assuming a node whose pseudokey is 401,975 is the third node inserted into the structure, give the index of the array element that would store the location of the deep copy of this node. _____________________________________________________________________
4) What is the loading factor after the three nodes have been inserted into the structure? ____________________________________________________________________
Explanation / Answer
#include <iostream>
#include <cstdlib>
#define MAX_VALUE 65536
using namespace std;
/* category Node */
class Node
;
/* category ThreadedBinarySearchTree */
class ThreadedBinarySearchTree
builder */
ThreadedBinarySearchTree()
/* perform to clear tree */
void makeEmpty()
/* perform to insert a key */
void insert(int key)
else if (p->key > key)
else
}
Node *tmp = new Node();
tmp->key = key;
tmp->rightThread = tmp->leftThread = true;
if (p->key < key)
facet */
tmp->right = p->right;
tmp->left = p;
p->right = tmp;
p->rightThread = false;
}
else
}
/* perform to look for a part */
bool search(int key)
come false;
tmp = tmp->right;
}
else if (tmp->key > key)
come false;
tmp = tmp->left;
}
else
come true;
}
}
}
/* Fuction to delete a part */
void Delete(int key)
else if (dest->key > key)
else
}
Node *target = dest;
if (!dest->rightThread && !dest->leftThread)
2 children*/
p = dest;
/* realize largest node at left kid */
target = dest->left;
whereas (!target->rightThread)
/* exploitation replace mode*/
dest->key = target->key;
}
if (p->key >= target->key)
else if (target->rightThread)
{
Node *largest = target->left;
whereas (!largest->rightThread)
largest->right = p;
p->left = target->left;
}
else
{
Node *smallest = target->right;
whereas (!smallest->leftThread)
smallest->left = target->left;
p->left = target->right;
}
}
else
else if (target->rightThread)
{
Node *largest = target->left;
whereas (!largest->rightThread)
largest->right = target->right;
p->right = target->left;
}
else
{
Node *smallest = target->right;
whereas (!smallest->leftThread)
smallest->left = p;
p->right = target->right;
}
}
}
/* perform to print tree */
void printTree()
{
Node *tmp = root, *p;
for (;;)
{
p = tmp;
tmp = tmp->right;
if (!p->rightThread)
{
whereas (!tmp->leftThread)
}
if (tmp == root)
break;
cout<<tmp->key<<" ";
}
cout<<endl;
}
};
/* Main Contains Menu */
int main()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.