Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use the following numbers to insert into each Tree below. Display the final Tree

ID: 3580114 • Letter: U

Question

Use the following numbers to insert into each Tree below. Display the final Tree after all numbers are inserted. 50, 10, 90, 20, 30, 80, 70, 5, 1, 75, 79 Binary Tree Retrieve the numbers using preorder Retrieve the numbers using postorder Retrieve the numbers using inorder Red-Black Tree (The Red-Black Tree Applet is allowed.) 2-3-4 Tree Use the following numbers to create a Hash Table using the methods described below. Show the final array after all numbers are inserted. Assumes that the Hash Table is implemented using an array of size 13. 27, 42, 107, 83, 185, 130, 12, 207 Linear Probing Quadratic Probing Double Hashing Separate Chaining

Explanation / Answer

Please find below the c++ program:

#include <iostream>
using namespace std;

int binarySearch(const int a[], int size, int key);
int binarySearch(const int a[], int iLeft, int iRight, int key);
void print(const int a[], int iLeft, int iRight);

int main() {
const int SIZE = 11;
int a1[SIZE] = {50, 10, 90, 20, 30, 80, 70, 5, 1,75, 79 }; // sorted List

cout << binarySearch(a1, SIZE, 8) << endl;
cout << binarySearch(a1, SIZE, 12) << endl;
cout << binarySearch(a1, SIZE, 24) << endl;
cout << binarySearch(a1, SIZE, 21) << endl;
}

// This will Search the array for the given key
// If it is found, return array index; otherwise, return -1
int binarySearch(const int a[], int size, int key) {
// This will Call recursive helper function
return binarySearch(a, 0, size-1, key);
}

// This is Recursive help function for binarySearch
int binarySearch(const int a[], int iLeft, int iRight, int key) {
// This is for tracing the algorithm
print(a, iLeft, iRight); //print section

// This will Test for empty list
if (iLeft > iRight) return -1;

// This will Compare with middle element
int mid = (iRight + iLeft) / 2; // truncate
if (key == a[mid]) {
return mid;
} else if (key < a[mid]) {
// Recursively search the lower half
binarySearch(a, iLeft, mid - 1, key);
} else {
// This will Recursively search the upper half
binarySearch(a, mid + 1, iRight, key);
}
}

// The below will Print the contents of the given array from iLeft to iRight (inclusive)
void print(const int a[], int iLeft, int iRight) {
cout << "{";
for (int i = iLeft; i <= iRight; ++i) {
cout << a[i];
if (i < iRight) cout << ","; //IF statement
}
cout << "}" << endl;
}