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

  Finding approximation algorithm and ratio of the algorithm

finding approximation algorithm and the ratio of the algoirthm.

  Is an array that is in reverse sorted order a heap

What is the expectation of the index of the maximum element in the array and expectation of the index of the minimum element in the array?

  Explaining adaptive playout delay algorithm

Consider adaptive playout delay algorithm. Demonstrate through simple example which adjusting playout delay at beginning of each talk spurt results in compressing

  Solving information technology question

XYZ Corporation has a small office with eighty users in California. The office employs a file and print server that caters to user requests.

  Write algorithm for graph minimum number of semesters

You are given a DAG called G which is the prerequisite graph for a set of courses required for a degree. Each vertex corresponds to course. Provide a high-level description of algorithm which labels each vertex in G with minimum number of semesters..

  Problems on edges and graphs

Suppose if we add an edge to a biconnected graph with k strongly connected components, then there are 3-situations: the endpoints of edge lie in different strongly connected component and there is no path between 2 in the original graph,

  Code division multiple access (cdma)

Last week we examined the multiple access problem and its solutions. This week, as part of our study of wireless and mobility, we are considering another solution to the same problem, namely Code Division Multiple Access (CDMA).

  Define file type

Define File Type and provide some of the important information to know about it and where do file types come from?

  Consider that the size of the hash tab is m=16. apply linear

Consider that the size of the hastable is M=16. Apply linear probing with f(i)=i for the following keys. Convert each of the keys to a number associated with the sequence of English alphabet and then draw a table that indicates successful and unsucce..

  Discuss and define normalization

Discuss and define normalization and what are the basic steps of the normalization process?

  Compiler to separate the numbers using dashes

write this code using structures.with writing the SSN in one line this ask the compiler to seperate the numbers using dashes.

  Data structures class

data structures class this project will give you an introduction. There are two important data structures that you will learn and use. The first is a stack, it is a LIFO (Last In First Out) structure. You can think of it like a a stack of plates in y..

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