Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Lab_3: // The startup code builds a binary tree where elements can be stored. // The nodes can be displayed with inorder, preorder, and postorder

Lab_3:

// The startup code builds a binary tree where elements can be stored.

// The nodes can be displayed with inorder, preorder, and postorder algorithms.

//

//

// Assignment:

// Using this startup code as a starting point:

// Implement a database program such an address book similar to our phone address book, i.e.:

// 1 - Accept simple entries as name, and phone number

// 2 - Store the address book entries in a form of Binary tree by inserting the entries, you will have to modify the current implementaion to accept strings

// 3 - Adjust the entries and save the new info in the table (and eventually in the file) (simillar to lab_1)

// Upon exit: Save tree info (will be be already sorted) in the phonebook file

// 4 - Upon startup, load the stored phone info from the phonebook file

// 5 - Display phone numbers info in a sorted order, limit the entries to few

// 6 - Verify that you can insert, display, delete and update entries

// 6 - Your implementaion should behave very simillar to your phonebook

// 7 - Upload code along with your run test cases (report) to CANVAS

Main.cpp

#include "stdafx.h"

#include

#include "IntBinaryTree.h"

using namespace std;

int main()

{

IntBinaryTree tree;

// Insert some nodes.

cout

tree.insertNode(5);

tree.insertNode(8);

tree.insertNode(3);

tree.insertNode(12);

tree.insertNode(9);

cout

// Display inorder.

cout

tree.displayInOrder();

// Display preorder.

cout

tree.displayPreOrder();

// Display postorder.

cout

tree.displayPostOrder();

cout

// Search for the value 3.

if (tree.searchNode(3))

cout

else

cout

cout

// Search for the value 100.

if (tree.searchNode(100))

cout

else

cout

cout

// Delete the node with value 8.

cout

tree.remove(8);

// Delete the node with value 12.

cout

tree.remove(12);

cout

// Display the stored node values.

cout

tree.displayInOrder();

return 0;

}

IntBinaryTree.h

image text in transcribed

image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

Students also viewed these Databases questions