EBK DATA STRUCTURES AND ALGORITHMS IN C
4th Edition
ISBN: 9781285415017
Author: DROZDEK
Publisher: YUZU
expand_more
expand_more
format_list_bulleted
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
7. Draw an AVL tree of height 3 with the smallest possible number of nodes.
Then draw an AVL tree of height 4 with the smallest possible number of nodes.
In pseudocode, write a function that returns the number of nodes in the smallest possible AVL tree
of height h. You may assume that only valid heights from -1 up to 25 will be supplied.
Write your solution below.
function minAvlSize (int height)
Create a binary linked tree, and traverse the tree by using the recursive function.
The structure of the tree is as follow: //PICTURE//
You should input the nodes in pre-order sequence. If a child of a node is NULL, input a space.
Write the function of create binary tree, pre-order to print the nodes, in-order to print the nodes and post-order to print the nodes. Also Count the height of the tree.
PLEASE USE C LANGUAGE
Create a binary linked tree, and traverse the tree by using the recursive function.
The structure of the tree is as follow: //PICTURE//
You should input the nodes in pre-order sequence. If a child of a node is NULL, input a space.
Write the function of create binary tree, pre-order to print the nodes, in-order to print the nodes and post-order to print the nodes.
Count the height of the tree.
Chapter 6 Solutions
EBK DATA STRUCTURES AND ALGORITHMS IN C
Knowledge Booster
Similar questions
- Construct a Binary Search Tree (BST) using the data provided in shaded row and name it “BST-1”. 50 45 65 60 75 90 15 35 70 45 55 40 20 80 95 85 25 50 74 5 Provide answers to the following considering your constructed BST-1: Write a C++ code that finds and delete a node having exactly two Childs in a BST. Simulate your code on BST-1 and provide a step-by-step procedure to delete “15” and “75” from it.arrow_forward5. Write a function that will compute the sum of leaf nodes in each level of a binary tree and will find the maximum among those. Considering the following example also show the steps executed by your proposed function. Input: 1 2 4 8 6 Output: 13arrow_forwardConstruct a Binary Search Tree (BST) using the data provided in shaded row and name it “BST-1”. 50 45 65 60 75 90 15 35 70 45 55 40 20 80 95 85 25 50 74 5 Provide answers to the following considering your constructed BST-1: Write a C++ code for the in-order traversal of BST-1. Also, dry run your code on it and elaborate its each step. Compute the total number of used and unused (null) references defined in BST-1. And construct an equivalent two-way in-order threaded BST-1 that has minimum number of null references.arrow_forward
- write a c++ code using binary search tree to store ten names of cities, search city names in tree, remove three cities name, beside the used cities in code add two new names of cities and search those newly added cities (code consist of all of above tasks)arrow_forwardComputer Science Exercise: shape [★★★] Write a function same_shape : 'a tree -> 'b tree -> bool that determines whether two trees have the same shape, regardless of whether the values they carry at each node are the same. Hint: use a pattern match with three branches, where the expression being matched is a pair of trees. please use Ocaml for the codingarrow_forwardWrite a function which will take a binary tree as input and return the total number of nodes in: the tree. Your code must count the nodes by traversing the tree. a. b. Wite a function which will take a binary tree as input and return the number of total number ef leaves in the tree. Your code must count the leaves by traversing the tree. c. Write code fer building (insertion) a ternary tree. A node (Ternary tree class) in a ternary tree may have at most 3 ehildren. You may need to modify the TreeNode class discussed ir. class and adl functions to insert nodes. d. We discussed a methodology to delete a node which has 2 children from BST and in ormally argued avout the correctness of this methodology, An alternative methodology is shown below. The node X has two children, and we wish to delete X. The tree is rearanged as shown in the right after deleting X. Show that the alternative technique also preserves BST property. Write code to implement the alternative technique. [20]arrow_forward
- 4. a) The preorder traversal of a Binary Search Tree (BST) is given below. 75 55 45 50 60 65 95 85 110 100 Draw the BST and briefly explain the process you followed to build the tree. b) Write a function f1 that takes the root of a binary tree as a parameter and returns the sum of the nodes, which are the right child of another node. The root of the tree is not a child of any node. Consider the following class definitions while writing your code. class Node { public: int key; Node* left; Node* right; } ;arrow_forward3) Create a JavaFX program that visualizes a given tree data structure, e.g.: 14 (A H K The tree nodes should dynamically change as new nodes are added or deleted. Create your own implementation if a tree (using BST in activity 2 is allowed) and visualize your insertion and deletion procedure. Provide the following:arrow_forwardCreate a binary linked tree, and traverse the tree by using the recursive function. The structure of the tree is as follow: You should input the nodes in pre-order sequence. If a child of a node is NULL, input a space. Write the function of create binary tree, pre-order to print the nodes, in-order to print the nodes and post-order to print the nodes. Count the height of the tree. Header file typedef char ElemType; typedef struct node//define the type of binary tree node { }BTnode; Source file #include <stdio.h> #include <stdlib.h> #include "tree.h" BTnode * createTree()//create the binary tree,return the root { BTnode *tnode;// tnode is the root char elem; ;//input the character //if the input is a space,set the pointer as NULL Else// if the input is not a space,generate the binary node and create its left sub-tree and right…arrow_forward
- Build a Binary Search Tree with the given input order. You must show step by step process of inserting the inputs including both recursive calls and tree diagrams for each step. [ refer to the Insertitem function of Lecture 10 slides to get an idea of doing this.] N.B: Unique Input orders for each student to build the tree are given on a separate file. Write down the input order on your answer script before answering the question. You must use the assigned input order. Do not change the order. TREE INPUT: 4,1,9,3,2,5,6,8,7arrow_forwardWrite a menu-based program that implement simple binary Search Tree and write the following functions for that: 1.Write a function Add () that add a single leaf on each call according to BST. 2. Write function Delete () that delete the provided value on each call if exist.3.Write function In order () to display list of all nodes using in order traversing technique.4.Wire function Preorder () to display list of all nodes using preorder traversing technique.5.Wire function Post order () to display list of all nodes using post order traversing technique.arrow_forwardin c++ Draw the tree after the insertion of keys 33, 31, 60,90,86,81,96,87,94, 21, 11 and 18, in this order. Consider the above values and perform The Following: 1) Write code for Insertion of above values in trees. 2) perform Breadth First Search AND Depth First Search and display results. 3) Perform Preorder, in order, and post order traversal and show the outputs. 4) Write a code to delete 87 and 21, and 90 from above tree.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education