Produce a tree adt

Assignment Help Data Structure & Algorithms
Reference no: EM13923168

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.

Reference no: EM13923168

Questions Cloud

Individual personality profiles : After filling out apersonality test, students were given individual personality profiles. Mostsaid that their profiles were fairly good descriptions of themselves, and theywere amazed to discover that they had all received the same profile. Thisil..
Is it possible for organisations to follow emergent strategy : Examine the criticisms of prescriptive strategies in Section 2.1. Is it possible for organisations to follow both prescriptive and emergent strategies or do they need to choose?
Present an entity-relationship model? : The company has several branch offices. Each branch is identified by a branch_number. The name, address (street, city, ZIP), and revenue_target of each branch office are maintained.
Leading cause of death in the united states : According to the National Heart Lung and Blood Institute, "COPD is the 3rd leading cause of death in the United States.
Produce a tree adt : 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.
Determine degree of turbulence in hollywood film industry : Determine the degree of turbulence in the Hollywood film industry. Give reasons for your views. Develop and compare the key factors for success in the following three industries.
Describing a situation affects moral awareness : The type of language used when describing a situation affects moral awareness
Warranties-an interesting liability on a clients books : Product Warranties Provide an original and substantive response to the questions posed in your Journal in a minimum of 200 words. Product warranties are an interesting liability on a client's books.
Advantages and disadvantages for each selection method : Use the table provided or create one of your own using the program of your choice-MS Word, MS Excel, etc.-to define each selection method. Explain the nature of the method and its importance. Then list all the advantages and disadvantages for each..

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  What is the relationship of object model to data structure

What are the reasons for object orientation? What is the relationship of the object model to the data structure

  Designing an algorithm for task-array of person numbers

You have been allotted task of designing an algorithm for following task. Someone has built the array of person numbers of all n students enrolled in 331 this fall.

  What is complexity of the gnome sort for the average case

What is the complexity of the gnome sort for the average case? Justify your answer. The justification can be based on approximate calculations.

  Create greedy algorithm to find market to buy apples

Assume we drive pickup truck from city A to city B. Along high way, we will go through n apple markets, labeled with 1, 2, ..., n, where you can buy or sell apples. which means you buy and sell apples at the same market i.

  Write a program that creates a two-dimensional array in heap

Write a program that creates a two-dimensional array in the heap and then analyzes it to determine the minimum, maximum, and average of each column.

  Algorithm for partitioning a set of n weights into k

give a greedy algorithm for partitioning a set of n weights into k bins. b) does it find the perfect solution?

  What do you mean by query evaluation plan what are its

question 1 what is a query evaluation plan? what are its advantages and disadvantages?question 2 discuss the different

  Unctions for doing sort, search, display, replace, delete

create functions for doing sort, search, display, replace, delete, and add. You can use dynamic memory allocation for enlarge the size of pointer array for adding a new country.

  Construct the huffman code for the java keyword

Construct the Huffman code for the Java keyword and weights given in the following table

  Design and build a prototype data warehouse

Design and build a prototype data warehouse using the data on Spend over £500 in the Department of Energy and Climate Change for the financial year 2012-2013 (April 2012 to March 2013 inclusive).

  Discuss new security features in windows server

Which of the system changeover methods is the most expensive? Why? Which of the system changeover methods is the most risky? Why?

  Design an adt for a two-color

Design an ADT for a two-color, double-stack ADT that consists of two stacks one "red" and one "blue" and has as its operations color-coded versions of the regular stack ADT operations.

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