Preview

Avl Tree

Satisfactory Essays
Open Document
Open Document
324 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Avl Tree
//NAME: MANGUERRA JR, WILLIAM E.
//INSTRUCTOR: RUBY GLIPONEO
//YEAR AND SECTION: II-CpE 1
# include
# include
# include

using namespace std; struct node
{
int element; node *left; node *right; int height;
};
typedef struct node *nodeptr;

class avltree
{
public: void insert(int,nodeptr &); void del(int, nodeptr &); int deletemin(nodeptr &); void find(int,nodeptr &); nodeptr findmin(nodeptr); nodeptr findmax(nodeptr); void preorder(nodeptr); void inorder(nodeptr); void postorder(nodeptr); int bsheight(nodeptr); nodeptr srl(nodeptr &); nodeptr drl(nodeptr &); nodeptr srr(nodeptr &); nodeptr drr(nodeptr &); int max(int,int); int nonodes(nodeptr);
};
int main(int argc, char *argv[])
{

nodeptr root,root1,min,max; int a,choice,f,d,flag; char ch='y'; avltree bst; root = NULL; root1=NULL; do
{

coutright != NULL) { if(parent->left == curr) { parent->left = curr->right; delete curr; } else { parent->right = curr->right; delete curr; } } else // left child present, no right child { if(parent->left == curr) { parent->left = curr->left; delete curr; } else { parent->right = curr->left; delete curr; } } return; }

//We're looking at a leaf node if( curr->left == NULL && curr->right == NULL) { if(parent->left == curr) parent->left = NULL; else parent->right = NULL; delete curr; return; }

//Node with 2 children // replace node with smallest value in right subtree if (curr->left != NULL && curr->right != NULL) { tree_node* chkr; chkr = curr->right; if((chkr->left == NULL) && (chkr->right == NULL)) { curr =

You May Also Find These Documents Helpful

  • Good Essays

    Cse 373 Final Note

    • 955 Words
    • 4 Pages

    Path Compression- Every Node on the path from x to the root has its parents changed to the root.…

    • 955 Words
    • 4 Pages
    Good Essays
  • Powerful Essays

    Pt1420 Unit 1 Assignment 2

    • 1305 Words
    • 6 Pages

    Das, D., Gregersen, E., Hosch, L., Lotha, G., Sampaolo, M., Sinha, S. (2014). C++. In Encyclopedia Britannica.…

    • 1305 Words
    • 6 Pages
    Powerful Essays
  • Satisfactory Essays

    Evergreen Enhancement

    • 352 Words
    • 3 Pages

    PRINTED BY: mrvualex@gmail.com. Printing is for personal, private use only. No part of this book may be reproduced or transmitted without publisher's prior permission. Violators will be prosecuted.…

    • 352 Words
    • 3 Pages
    Satisfactory Essays
  • Good Essays

    Imagine the experience of living under the rule of a violent group of terrorists, with no freedom whatsoever. This is what it is like to Najmah in the book Under the Persimmon Tree, by Suzanne Fisher Staples. In this realistic setting, Najmah, the main character, loses most of her family due to the brutality and imposition of the Taliban. The novel depicted the Taliban as dangerous and strict, which is interchangeable for what the Taliban is like in reality. Staples used the Taliban conflict to deepen the reader's understanding of the impact of conflict on people's lives.…

    • 680 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Maximum Phylogenetic Tree

    • 495 Words
    • 2 Pages

    Maximum likelihood methods have been developed in order to construct the most probable phylogenetic tree. The earliest methods of calculating the maximum likelihood used gene frequency data, and more recent approaches involve algorithms of amino acid and nucleotide sequences.…

    • 495 Words
    • 2 Pages
    Good Essays
  • Powerful Essays

    - and he cried with a loud voice: Hurt not the earth, neither the sea, nor the trees -…

    • 1635 Words
    • 7 Pages
    Powerful Essays
  • Good Essays

    African Tree of Life

    • 422 Words
    • 2 Pages

    The name "Tree of life" was formed because of Baobab’s many uses medicinally, almost every part of it, was used for healing purposes. In traditional African medicine, baobab fruit is used for treating inflammation, fevers, asthma, gastric complaints, malaria, haemoptysis, smallpox and as a general health tonic, particularly in children, pregnant women and the elderly people.…

    • 422 Words
    • 2 Pages
    Good Essays
  • Better Essays

    Tree Plantation Programme

    • 2956 Words
    • 12 Pages

    A plantation is a long artificially established forest, farm or estate, where crops are grown for sale, often in distant markets rather than for local on-site consumption. The term plantation is informal and not precisely defined.…

    • 2956 Words
    • 12 Pages
    Better Essays
  • Good Essays

    tree

    • 1138 Words
    • 3 Pages

    et in the 1950s in the Philippines,[3] Tree was the story about an unnamed Filipino boy, the son of a plantation manager and “subjugator of other Filipinos”,[3] who grew up in an Ilocano town known as Rosales, Pangasinan. He was surrounded by acquaintances beneath his social class, relatives, and servants.[2] He was described as a youth who “searched for parental love” and a “place in a society with rigid class structures”. He was also the grandson of the landlord protagonized by José in the novel Po-on. In Tree, the boy narrated the weakening relatiThere were many others but of course there’s also the jaded Espiridion who went to work for Don Vicente in spite of his own wealth – just so he will be able to secure his own wealth – because he knew that if he didn’t, Don Vicente can and he will, take whatever catches his fancy.…

    • 1138 Words
    • 3 Pages
    Good Essays
  • Good Essays

    Beka Lamb Tree Analysis

    • 462 Words
    • 2 Pages

    Beka and her father have a rocky relationship from the beginning of the book. On page 19 Beka talks about how her father calling her names, like “phoney” are sometimes more hurtful than the physical abuse. Her father says that he “couldn’t understand how a girl with enough food to eat, decent clothes to wear, and a roof over her head could be such a trial.” The first instance of lying in front of her father resulted with the whipping her with his belt. She was cut across the face with the belt buckle and the scar is a constant reminder of the pain she experienced as a result of her lying.…

    • 462 Words
    • 2 Pages
    Good Essays
  • Satisfactory Essays

    Apple Tree

    • 379 Words
    • 2 Pages

    This article is about the fruit. For the technology company, see Apple Inc.. For the apple genus, see Malus. For other uses, see Apple (disambiguation).…

    • 379 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    The Hanging Tree

    • 153 Words
    • 1 Page

    VERSE 1 & 6 Are you, are you Coming to the tree They strung up a man They say who murdered three. Strange things did happen here…

    • 153 Words
    • 1 Page
    Satisfactory Essays
  • Good Essays

    Tree Plantation

    • 522 Words
    • 3 Pages

    Man has been closely related with the nature since the down of civilization. Nature is helpful for all human beings. Nature abounds with trees. Trees are one of the best gifts of nature. As the civilization proceeds towards development, valuable nature assets are also getting damaged day by day. So it is the ease with trees. Now the ecological balance is distributed and the life becomes difficult. Our life and existence on earth greatly depends on trees. So we should plant trees through an existence expedition and maintain our ecological balance smooth. The first and foremost thing we get from trees is oxygen. We inhale oxygen from air, which are provided by trees. Trees maintain the climate and the weather of a country. They help causing rainfall and save our country from destruction. Trees save our land from erosion and make it fertile. We get our major food production from trees we get our clothing material from trees. We also get some building materials from trees. Rural houses are mainly made by trees indirectly. We get furniture from trees which are provided by trees. Besides we get many kinds of medicines from trees. In real sense trees give us many things that we can not even count. In a matter of great regret the destruction of trees is common in Bangladesh. Our people cut trees at random. We use plants in the time of need but we can not plant more, which is greatly needed for for existence. Trees are the raw material of many industries, so it is widely used. People use trees as fuel in their kitchen, brick fields. They also cut them to make new houses. It is a great threat to our healthy atmosphere and our environment. The ratio of cutting and planting trees is very much different. We cut more but plant less. We have to plant more and more to prevent ourselves from natural disasters. Tress can be planted almost all the year but rainy season is the appropriate time to plant trees. Each and everybody should be conscious about that utility of trees and…

    • 522 Words
    • 3 Pages
    Good Essays
  • Better Essays

    Tree Plantation

    • 1871 Words
    • 8 Pages

    Tree plantation means planting trees and plants. The purpose of tree plantation is save the endangered environment and to beautify our life. Trees are valuable gifts of nature. They are known as the best friends of human beings. They benefit us in various ways. The lives of men and other animals and insects are inconceivable without the existence of trees in the world.…

    • 1871 Words
    • 8 Pages
    Better Essays
  • Good Essays

    The Last Leaf Analysis

    • 723 Words
    • 3 Pages

    The old artist Behrman got pneumonia and is taken to hospital, and He died two days later.…

    • 723 Words
    • 3 Pages
    Good Essays

Related Topics