Recursive tree algorithmsalgorithms to write1 write a

Assignment Help Data Structure & Algorithms
Reference no: EM13346646

Recursive tree algorithms

Algorithms to Write:

1. Write a recursive function to determine if a binary tree is a binary search tree.  For example, in the trees above, the tree on the left is a binary search tree, while the tree on the right is not.

1889_Recursive tree algorithms.png              1562_Recursive tree algorithms1.png

120_Recursive tree algorithms2.png

2. The location of a node in a binary search tree is defined as a string such as LLRRL, which represents the node that you find by starting at the root, and traversing Left, traverse Left, traverse Right, traverse Right, and traverse Left.   Write a function to print a path to some target 'x' based on the direction from the root to the target.  For example, in the tree above, the path from 65 to 52 is LRR. Hint: use a stack to store the path.

3. Write a recursive algorithm to count the number of right children in a binary search tree.

4. Write the method levelCount whose header is given below. Method levelCount returns the number of nodes on the specified level.

int BinarySearchTree<Type> :: levelCount(BinaryNode<Type>* t, int level);

For this problem, the root is at level zero, the root's children are at level one, and for any node N its level is one more than N's parent's level. For example, for the bean-tree diagrammed below, the call levelCount(t,1) should return 2 (chickpea and navy are on level 1); the call levelCount(t,2) should return 3; and the call levelCount(t,4) should return 0.

2176_Recursive tree algorithms3.png

Hint: when the level is 0, there is always just one node at that level, the root node (assuming it isn't empty), so return 1. If the level isn't zero, recursive calls will be used to determine the number of nodes at the requested level, and the level-requested should change in the recursive calls.

5. Write a recursive algorithm to delete the leaves of a binary tree.

Programming Requirements

You must use the binary search tree code provided.  Each algorithm must be implemented as both a private method and a public method of the class.  Your code will be tested using the program provided.

Other Requirements 

  • File names must match exactly to the file names provided
  • Clearly state any additional assumptions you may need to make.

Reference no: EM13346646

Questions Cloud

Question 1approximate the torque and power necessary to : question 1approximate the torque and power necessary to rotate the inner 20 cm diameter cylinder shown in figure 1. sae
The users will use a browser to access the on-line store : the users will use a browser to access the on-line store. the web server software for the production web server is
Structural modelingstructural modeling is a different view : structural modelingstructural modeling is a different view of the same system that you analyzed from a functional
Q1a express the shannon-hartley capacity theorem in terms : q1a express the shannon-hartley capacity theorem in terms of where is the energybit and is the psd of white
Recursive tree algorithmsalgorithms to write1 write a : recursive tree algorithmsalgorithms to write1. write a recursive function to determine if a binary tree is a binary
Project socket programming - udp objectives - learn socket : project socket programming - udp objectives - learn socket programming in java udp-nbsp cement your understanding of
Create a web site for an apple farm john smith has been a : create a web site for an apple farm. john smith has been a farmer for a number of years and he has been using an
Stock market project1 building portfolionbsp select five : stock market project1. building portfolionbsp select five companies for the purpose of tracking the stock market
Shopping cart program for web applications classpurpose - : shopping cart program for web applications classpurpose - allows user to browse while keeping track of the items in

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Determine how long the specific algorithms take

Some problems can be theoretically solved (we can explain the algorithm solving problem). How long does the specific algorithms take?

  Data speed effect on fundamental business decisions

Can the speed in which data is transmitted have an adverse effect on fundamental business decisions? Yes, speed that is traveling at big rates of speed can have an affect on fundamental business decisions.

  Write schedule produced by earliest deadline first algorithm

Given below are two sets of real-time, periodic tasks. For (a), will the schedule produced by Earliest Deadline First algorithm meet all the deadlines?

  Evaluate algebraic expression by code with three-operand

Evaluate a short algebraic expression using code with three-operand instructions. The expression should have a minimum of three operands and 2 operators.

  Question about indexed strategy

Think about a file system on a disk that has both logical and physical block sizes of 512 bytes. Suppose that the data about each file is already in memory.

  Determine the mean salary as well as the number of salaries

Determine the mean salary as well as the number of salaries.

  Write a breadth-?rst search algorithm

Write an algorithm to classify the edges of a directed graph G into the four categories: tree edge, back edge, forward edge and cross edge (de?ned in De?nition 7.14, pages 342-343).

  Creating a table of xml documents

Make a table of XML documents with a type of XML. Use a primary key so add a field of type INT that is an identity. Insert many records into XML field in this new table.

  Inventory tracking database

Construct a relational database of your choice. The DB should contain no more than six tables. Define three business requirements that this database will provide.

  Create algorithm to count of integers less than average

Create the algorithm which will prompt for and get 10 integers from the operator at terminal, and then count number of integers whose value is less than average value of integers.

  Er modeling

A supplier supplies certain number parts for a assignment, a assignment uses the parts from the different suppliers, and the same kind parts from different suppliers are used by different assignments.

  Greedy strategy for finding a shortest path

Think about the given greedy strategy for finding a shortest path from vertex start to vertex goal in a connected graph.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd