Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Data Structures Assignment: InOrder, PreOrder, and PostOrder Traversal in a Binary Search Tree (BST)

In this assignment, you will implement inorder, preorder, and postorder traversal functions on a binary search tree.  

public:

void inOrder(void(*func)(const T &)) const;

void preOrder(void(*func)(const T &)) const;

void postOrder(void(*func)(const T &)) const;

private:

void inOrder(void(*func)(const T &), bst_node* node) const;

void preOrder(void(*func)(const T &), bst_node* node) const;

void postOrder(void(*func)(const T &), bst_node* node) const;

Each of these traversal methods matches a public method that takes a function pointer as a parameter with an overloaded private method that takes a function pointer and a binary-search-tree node pointer as parameters. The private method is recursive.  The reason the matching of public and private functions is necessary is that the private function takes a node pointer in the second parameter position; node pointers are private to the binary search tree.

Please download the starter files for this assignment from the Files tab (Assignment8.zip). Do not alter the class definition or driver code in any way. Programs that crash are subject to a 50% penalty.   Please submit the class header file only ("bst.h").  PLEASE NOTE: You may not use any Standard Template Library (STL) classes for this assignment; use code provided by the instructor only. 

Here is an example: suppose you have the following BST:

2374_Figure.png

BST.inOrder(); yields 14->21->24->25->28->31->32->36->39->41->47

BST.preOrder(); yields 32->24->21->14->28->25->31->41->36->39->47

BST.postOrder(); yields 14->21->25->31->28->24->39->36->47->41->32

Attachment:- Assignment Files.rar

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92280380

Have any Question?


Related Questions in Computer Engineering

You are starting a company on a tight budget you can get

You are starting a company on a tight budget. You can get DSL line to your office with a static IP address, but ISP does not offer any DNS services. At this point you do not want to set up your own DNS, so you want to fi ...

Information systemsdirections answer the following if you

Information Systems Directions : Answer the following: If you were asked to develop a logical model of the registration system at a school, would it be better to use a top-down or bottom-up approach? Explain your reasoni ...

You have been offered a contract worth 1 million per year

You have been offered a contract worth 1 million per year for five years. However, to take the contract, you will need to purchase some new equipment. Your discount rate for this project is 12%. You are still negotiating ...

What is the role of arp and how does it cause a security

What is the role of ARP and how does it cause a security concern? What is the different between global and private IP addresses? How does using NAT change a private IP address into a global IP address, and why is this so ...

Two manufacturing firms are located on the banks of the

Two manufacturing firms are located on the banks of the Crimea River. Riditna Paper withdraws river water for use in its paper mill, and returns it, along with waste effluent, back into the river. (Effluent is a co-produ ...

Innbspmid-2009 rite aid hadnbspccc-ratednbsp20-year bonds

In? mid-2009, Rite Aid had? CCC-rated, 20-year bonds outstanding with a yield to maturity of 17.3%. At the? time, similar maturity Treasuries had a yield of 5%. Suppose the market risk premium is 4% and you believe Rite? ...

Question after you have analyzed the existing material used

Question: After you have analyzed the existing material used by the company for their day-to-day duties, the current Access database, and the additional requirements that the current system does not meet, the following r ...

Question suppose that counting sort is used to sort n

Question : Suppose that counting sort is used to sort n numbers in the range [0, M]. What is the running time of the algorithm? Justify your answer. The response must be typed, single spaced, must be in times new roman f ...

What are the two potential souces of inefficiency in the

What are the two potential souces of inefficiency in the health care market?

Write a c program please follow instructions exactly this

Write a C++ program. PLEASE FOLLOW INSTRUCTIONS EXACTLY. This program takes its inputs from a file that contains numbers. The program reads them in as type double. The program outputs to the screen the  standard deviatio ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As