Please Run the program and show sample result . Implement a city database using
ID: 3571947 • Letter: P
Question
Please Run the program and show sample result .
Implement a city database using a Binary Search Tree (BST) to store the database records. Each database record contains the name of the city (a string of arbitrary length) and the coordinates of the city expressed as integer x- and y-coordinates. The BST should be organized by city name. Your database should allow records to be inserted, deleted by name or coordinate, and searched by name or coordinate. Another operation that should be supported is to print all records within a given distance of a specified point. Write a C++ code to implement the city database. Collect running-time statistics for each operation. Which operations can be implemented reasonably efficiently (i.e., in O(log n) time in the average case) using a BST? Can the database system be made more efficient by using one or more additional BSTs to organize the records by location? (Answering by just saying YES is not sufficient. Explain how.)Explanation / Answer
#include<iostream.h>
#include<conio.h>
#include<process.h>
struct tree_node
;
class bst
int isempty()
void insert(int item);
void inordertrav();
void inorder(tree_node *);
void postordertrav();
void postorder(tree_node *);
void preordertrav();
void preorder(tree_node *);
};
void bst::insert(int item)
if(item<parent->data)
parent->left=p;
else
parent->right=p;
}
}
void bst::inordertrav()
void bst::inorder(tree_node *ptr)
void bst::postorder(tree_node *ptr)
void bst::preorder(tree_node *ptr)