Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Overview:

In this assignment you will combine the code you have written for Binary Search Trees (BSTs) and Red Black 'Rees (RBTs) in previous labs to produce a tree ADT which can be either a simple BST or a self-balancing RBT. You must write a main .c which will create a tree, fill it with words read from stdin, and then print them out in alphabetical order.

Specific details

• All instances of bst/rbt should be replaced with tree in your tree .c file.

• Add an enumerated type to tree .h so that tree_new() can be called like this tree t = tree_new(RBT);

• By default your program should create a tree which is a simple BST. If given -r as a command-line option it should create a tree which is an RBT instead.

• Words should be read using the getword() function from the lab book. It should not be possible to add duplicate words to your tree.

• By default your program should print out all of the words contained in your tree (one word per line) by passing a print_key() function to your tree_inorder () function.

• If given -p as a command-line option words should be printed using a pre-order traversal instead of an in-order one.

• Don't implement a tree_remove() function since removing nodes from an RBT can be a bit tricky. Get rid of your old bst_remove 0 code since using it would break an RBT.

• Add a tree_depth 0 function which should return the length of the path between the root node and the most distant leaf node (excluding the nils at the end of an RBT). If given -d as a command-line option the tree depth should be printed to stderr.

• You may have noticed that the RBT you implemented in labs doesn't ensure that the root is always black. This doesn't affect the structure of the tree at all, but we would like you to remedy this situation.

• We have provided a couple of functions for you to add to your tree .c which you can find in the file /home/cshome/coursework/242/Asgn3/out put -dot . txt

These functions will produce a representation of your tree in the DOT graph description language. This DOT representation can be converted to a pdf (as described in tree_output_dot 0's comment) to help you visualise what your tree looks like.

• If -o output-filename is given as a command-line option then you should call tree_output_dot 0 with output-filename and your tree as arguments (after your tree has been filled).

• If -h is given as a command-line option then a usage message should be printed and your program should exit.

• All memory allocated should be deallocated before your program finishes.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91596056
  • Price:- $80

Guranteed 48 Hours Delivery, In Price:- $80

Have any Question?


Related Questions in Computer Engineering

What is the importance of selling and salesmanship within a

What is the importance of selling, and salesmanship within a small business?

The freemont automobile factory has discovered that the

The Freemont Automobile Factory has discovered that the longer a worker has been on the job, the more parts the worker can produce. I need help finding an application that computes and displays a worker's anticipated out ...

What are the characteristics of perfect competition and

What are the characteristics of perfect competition, and does is exist in the real world?

1 under what circumstances is it advantageous for a company

1. Under what circumstances is it advantageous for a company competing in foreign markets to concentrate its value chain activities in a select few locations? Under what circumstances is it advantageous for a company com ...

How much work energy must you do to lift 1 tonne 1000 kg of

How much work energy must you do to lift 1 tonne (1000 kg) of coal from a depth of 500 m to the surface? What fraction of the heat energy in that coal was this? This is a simple calculation of one part of the emergy to t ...

I am struggling with this programmign exersice and would

I am struggling with this programmign exersice and would love to get some insight. any help would be greatly appreciated. Amanda and Tyler opened a business that specializes in shipping liquids, such as milk, juice, and ...

Synchronize threads write a program that launches 1000

Synchronize threads. Write a program that launches 1,000 threads. Each thread adds 1 to a variable sum that initially is 0. Define an Integer wrapper object to hold sum. Create two versions of the program with and withou ...

Take the input of numbers and reverse the order of elements

Take the input of numbers and reverse the order of elements in that vector using recursion.

What strategies might help redirect a disruptive student

What strategies might help redirect a disruptive student? What strategies might help an unmotivated student?

What is the prupose of adding nahco3 solution to dissolve

What is the prupose of adding NaHCO3 solution to dissolve the crude products in refinning process (Chemistry)

  • 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