Skip to main content

Binary Search Tree in C++( dynamic memory based )

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include<bits/stdc++.h>
using namespace std;
struct bst
{
    int val;
    bst *left,*right;

};
bst *root=nullptr;
void srch(int num,bst * head)
{if (head==nullptr){
cout<<"\nNumber is not present\a"<<endl;
return;
}
if (head->val==num)
{
    cout<<"\nNumber is present\n\a";
    return;
}

else
{

    if(num<head->val) srch(num,head->left);
    else srch(num,head->right);
}


}
void insrt(int num)
{
     bst *node=new bst;
    node->val=num;
    node->left=node->right=nullptr;
if(root==nullptr)
{

    root=node;

}else
{bst * temp=root;
while(temp!=nullptr)
{
    if(num<=temp->val)
    {// to the left

        if (temp->left!=nullptr)
            temp=temp->left;

         else   {temp->left=node;
         return;
         }


    }else
    {// goto r1111ight
        if(temp->right!=nullptr)
        {

            temp=temp->right;
        }else
        {
           temp->right=node;
           return;

        }

    }



}


}

}
void display(bst * head)
{if(head==nullptr)
return;
display(head->left);
cout<<" "<<head->val<<" ";
display(head->right);


}
int main()
{
char ch;
   do
    {
    cout<<"\nPress\n1 To insert\n2. to display \n 3. to search\nq to exit--->";
    ch=getchar();
    if(ch=='1')
    {int i;
    cout<<"\nenter number to insert-->";
    cin>>i;
        insrt(i);
       cout<<"\n_________________________\n\tdisplay\n_________________________\n\n";
        display(root);
        cout<<"\n_________________________\n\n";
    }

    if (ch=='2')


    {cout<<"\n_________________________\n\tdisplay\n_________________________\n\n";
        display(root);
        cout<<"\n_________________________\n\n";

    }

    if(ch=='3')
    {
        int i;
        cout<<"\nNUMBER TO SEARCH-->";
        cin>>i;
        srch(i,root);

    }fflush(stdin);
    cout<<" \npress Enter key to continue\n";

    getchar();
    }while
    (ch!='q');


}

Comments

  1. Your Affiliate Money Printing Machine is ready -

    And getting it running is as easy as 1---2---3!

    This is how it all works...

    STEP 1. Choose which affiliate products you want to promote
    STEP 2. Add some PUSH BUTTON TRAFFIC (it LITERALLY takes JUST 2 minutes)
    STEP 3. See how the affiliate system explode your list and sell your affiliate products all on it's own!

    Are you ready to make money ONLINE??

    Click here to check it out

    ReplyDelete
  2. Easy "water hack" burns 2 lbs OVERNIGHT

    More than 160,000 men and women are hacking their diet with a simple and secret "liquid hack" to lose 2lbs each and every night in their sleep.

    It's scientific and it works on anybody.

    Just follow these easy step:

    1) Get a clear glass and fill it up with water half glass

    2) And now use this crazy hack

    you'll be 2lbs thinner as soon as tomorrow!

    ReplyDelete
  3. Did you realize there's a 12 word phrase you can communicate to your man... that will induce intense emotions of love and impulsive attractiveness to you buried within his chest?

    Because deep inside these 12 words is a "secret signal" that triggers a man's instinct to love, adore and protect you with his entire heart...

    ===> 12 Words Who Fuel A Man's Love Response

    This instinct is so hardwired into a man's mind that it will drive him to try harder than ever before to make your relationship the best part of both of your lives.

    As a matter of fact, triggering this dominant instinct is absolutely mandatory to achieving the best ever relationship with your man that the moment you send your man one of the "Secret Signals"...

    ...You will immediately find him open his mind and heart to you in a way he's never experienced before and he'll perceive you as the only woman in the world who has ever truly attracted him.

    ReplyDelete
  4. Your Affiliate Profit Machine is waiting -

    And getting it set up is as simple as 1-2-3!

    It's super easy how it works...

    STEP 1. Input into the system which affiliate products the system will advertise
    STEP 2. Add some PUSH button traffic (it takes JUST 2 minutes)
    STEP 3. See how the system explode your list and sell your affiliate products on it's own!

    Are you ready to make money ONLINE???

    Get the full details here

    ReplyDelete
  5. If you're looking to lose weight then you have to get on this brand new custom keto meal plan.

    To create this keto diet service, licensed nutritionists, personal trainers, and chefs united to develop keto meal plans that are efficient, suitable, price-efficient, and fun.

    From their grand opening in January 2019, 100's of individuals have already completely transformed their body and health with the benefits a good keto meal plan can offer.

    Speaking of benefits; in this link, you'll discover 8 scientifically-proven ones offered by the keto meal plan.

    ReplyDelete
  6. Your Affiliate Profit Machine is waiting -

    Plus, getting it set up is as easy as 1...2...3!

    Here are the steps to make it work...

    STEP 1. Tell the system what affiliate products you want to promote
    STEP 2. Add some PUSH BUTTON TRAFFIC (it ONLY takes 2 minutes)
    STEP 3. See how the system explode your list and sell your affiliate products all by itself!

    So, do you want to start making money???

    Your MONEY MAKING affiliate solution is RIGHT HERE

    ReplyDelete

Post a Comment

share your thoughts ....

Popular posts from this blog

Download pocket tank delux with 295 weapons free total 295 weapons version 1.6

Download Pocket Tanks Deluxe Full Version Free With 295 Weapons Pack | Size: 30MB UPDATED 2019 /19/april Description: Pocket Tanks is a 1-2 player computer game for Windows and Mac OS X, created by Blitwise Productions, developer of Super DX-Ball and Neon Wars. Adapted from Michael Welch's earlier Amiga game Scorched Tanks, this newer version features modified physics, dozens of weapons ranging from simple explosive shells to homing missiles, and the ability to move the tank. It supports several expansion packs. At the moment, players can have up to 295 different weapons total. Pocket Tanks is often abbreviated as PTanks. Have Fun! NOTE: FILE NAME IS SCRAMBLED FOR AVOIDING HARD DETECTION & FILE TAKEN DOWN . How to Play: Best with 2 players on the same computer at school or at work. UPDATED LINK https://mirr.re/d/u1Y https://nl26.seedr.cc/ff_get/447027537/ptd16.295.exe?st=lUp-PbRp4YOwToHIOGwStQ&e=1555747979 http://www.uploadmagnet.com/7gfzhbyfe...

Mafia 2 PC Game Download Free ISO Full DLC

Mafia 2 PC Game Review: Mafia 2 Plaza free download game is first person shooting game released for pc and PlayStation 3. PC Game game mafia II is the second  Sequel of Mafia Series Launched  By Daniel Vávra in 2010. Mafia 2 is an open world map game. Just like  GTA IV For PC easy to install and run  on windows 10 64 bit. Game story is based on gang war in which the mafia runs the city and do all the crimes.  Gangs Run The City however  the player plays the important role in the game to be a cop in the game.Best weapons and New Graphics In mafia II Game For PC, World Wide Multiplayer Game For PC Play it online low system Requirements. PROOF :- Mafia 2 Complete Free Download. And find out the eve dance in the game. The game has been played by most of the Pro Games.The game can be played in Core 2 Duo mafia system requirements. Download Game for pc direct single link free.  Gta v download full game and install  it on pc. Mafi...

Binary Search Tree in Java implementation (reference based, dynamic memory)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 import java.util.Scanner ; class BST { static BST . Node root = null ; public void insert ( int num ) { if ( root == null ) { root = new BST . Node ( num ); } else { // root node is not empty BST . Node temp = root ; while ( temp != null ) { if ( num <= temp . getVal ()) { if ( temp . getLeft () != null ) temp = temp . getLeft (); ...

how free is microsoft sql server developer edition really

Five reasons to take a chance It is free – although the commercially licensed version of SQL Server is often less expensive that other leading database products anyway, you cannot get it cheaper than for zero cost. While it may only be used for non-operational purposes, the developer edition is still a good way of trying out new functions, testing, training, and so on. It is fully loaded – it has all the same functions as the licensed SQL Server 2016 Enterprise edition, not a cut down version. This is important if you are using it to build applications that will eventually become real products or services. It is unlimited – you can deploy any number of copies on an unlimited number of devices, including virtual machines hosted on multitenant infrastructure. It is easily downgradeable – you can use the license to access SQL Server 2014 Developer Edition, without having to acquire a separate license for it. It is free – did I mention that already? Five reasons to skip this opti...

How to Put Google Adsense Below Post Title in Blogger?

Adsense is used by majority of expert bloggers for their website monetization because it is a cookie based contextual advertising system that shows targeted ads relevant to the content and reader. As bloggers are paid on per click basis, they try various ad placements on the blog to  increase the revenue  and get maximum clicks on the ad units. Well, on some blogs, you might have seen Adsense ad units placed below the post title. Do you know why? It is because the area just below the post title gets the most exposure and is the best place to put AdSense ad units to increase  Click Through Rate (CTR). Even though ads below post title work like a charm but this doesn’t mean that it will work for you as well. If you want to find out the best AdSense ads placement for your blog, try experimenting by placing ads at various locations such as header, sidebar, footer, etc. You can try other  blog monetization methods  as well to effectively monetize y...

download Code blocks 13.12 mingw.setup .exe 97 mb

NOTE: A newer version is been updated on the site ... visit here  http://vastgk.blogspot.com/2017/07/download-code-blocks-1601-mingwsetup.html File Date Download from codeblocks-13.12-setup.exe 27 Dec 2013 BerliOS  or  Sourceforge.net codeblocks-13.12mingw-setup.exe 27 Dec 2013 BerliOS  or  Sourceforge.net codeblocks-13.12mingw-setup-TDM-GCC-481.exe 27 Dec 2013 BerliOS  or  Sourceforge.net NOTE : The codeblocks-13.12mingw-setup.exe file  includes  the GCC compiler and GDB debugger from  TDM-GCC  (version 4.7.1, 32 bit). The codeblocks-13.12mingw-setup-TDM-GCC-481.exe file includes the TDM-GCC compiler, version 4.8.1, 32 bit. While v4.7.1 is rock-solid (we use it to compile C::B), v4.8.1 is provided for convenience, there are some known bugs with this version related to the compilation of Code::Blocks itself. IF UNSURE, USE "codeblocks-13.12mingw-setup.exe"!  \ Linux 32-bit: Dis...

Dragon Age: Inquisition Digital Deluxe Edition + All DLCs (torrent) Repack Size: 20.1~23.9 GB

Brief : Dragon Age: Inquisition  is an  action role-playing video game  developed by  Bioware Edmonton  and published by  Electronic Arts . The third major game in the  Dragon Age  franchise,  Dragon Age: Inquisition  is the sequel to  Dragon Age: Origins  and  Dragon Age II . The game was released worldwide in November 2014 for  Microsoft Windows ,  PlayStation 3 ,  PlayStation 4 ,  Xbox 360 , and  Xbox One . Repack Size: 20.1~23.9 GB