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

12 Tips to Maintain a Virus Free Computer

1. Email is one of the common ways by which your computer can catch a virus . So it is always recommended to stay away from SPAM. Open only those emails that has it’s origin from a trusted source such as those which comes from your contact list. If you are using your own private email host (other than gmail, yahoo, hotmail etc.) " then it is highly recommended that you use a good anti-spam software. And finally NEVER click on any links in the emails that comes from untrusted sources. 2. USB thumb/pen drives is another common way by which viruses spread rapidly." So it is always a good habit to perform a virus scan before copying any data onto your computer. NEVER double-click the pen drive to open it. Instead right-click on it and select the option “open”. This is a safe way to open a pen drive. 3. Be careful about using MS Outlook. Outlook is more susceptible to worms than other e-mail programs, unless you have efficient Anti-Virus programs running. Use Pegasus ...

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...

USE any TRIAL SOFTWARE FOREVER WITHOUT SERIAL NUMBER

USE any TRIAL SOFTWARE FOREVER WITHOUT SERIAL NUMBER(most wanted trick) Run a trial software forever now with time stopper you can run a trial software forever no need to fetch for serial numbers,activation codes,patch just DOWNLOAD TIME STOPPER now open it install it click browse select the .exe of the software or file which you want to run forever now simply click create desktop icon and now delete all its existing shortcuts now have fun enjoying software for life time

keyboard-shortcuts-that-work-in-all-web-browsers

Each major web browser shares a large number of keyboard shortcuts in common. Whether you’re using Mozilla Firefox, Google Chrome, Internet Explorer, Apple Safari, or Opera – these keyboard shortcuts will work in your browser. Each browser also has some of its own, browser-specific shortcuts, but learning the ones they have in common will serve you well as you switch between different browsers and computers. This list includes a few mouse actions, too. Tabs Ctrl+1-8 – Switch to the specified tab, counting from the left. Ctrl+9 – Switch to the last tab. Ctrl+Tab – Switch to the next tab – in other words, the tab on the right. (Ctrl+Page Up also works, but not in Internet Explorer.) Ctrl+Shift+Tab – Switch to the previous tab – in other words, the tab on the left. (Ctrl+Page Down also works, but not in Internet Explorer.) Ctrl+W, Ctrl+F4 – Close the current tab. Ctrl+Shift+T – Reopen the last closed tab. Ctrl+T – Open a new tab. Ctrl+N – Open a new browser window....

20 Windows Keyboard Shortcuts You Might Not Know

Global Windows Shortcuts Win+1, 2, 3, 4, etc. will launch each program in your taskbar. It is helpful then to keep your most used programs at the beginning of your task bar so you can open them one right after another. This also works in Windows Vista for the quick launch icons. Win+Alt+1, 2, 3, etc. will open the jump list for each program in the taskbar. You can then use your arrows to select which jump list option you want to open. Win+T will cycle through taskbar programs. This is similar to just hovering over the item with your mouse but you can launch the program with Space or Enter. Win+Home minimizes all programs except current the window. This is similar to the Aero shake and can be disabled with the same registry key. Win+B selects the system tray which isn’t always useful but can come in very handy if your mouse stops working. Win+Up/Down maximizes and restores down the current window so long as that window has the option to be maximized. It is exactly t...

what is LOREM ipsum and why do designers use it

What is Lorem Ipsum? Lorem Ipsum  is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. Why do we use it? It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now...

DOWNLOAD CODE BLOCKS 16.01 MINGW.SETUP .EXE 86.3 MB

Code::Blocks for Mac is a free C, C++ and Fortran IDE that has a custom build system and optional Make support. The application has been designed to be very extensible and fully configurable. Code::Blocks is an IDE packed full of all the features you will need. It has a consistent look, feel and operation across its supported platforms. It has been built around a plugin framework, therefore Code::Blocks can be extended with plugins. Support for any kind of functionality can be added by installing/coding a plugin. Key features include: Written in C++. No interpreted languages or proprietary libs needed.. Full plugin support. Multiple compiler support: GCC (MingW / GNU GCC), MSVC++, clang, Digital Mars, Borland C++ 5.5, and Open Watcom etc. Support for parallel builds. Imports Dev-C++ projects. Debugger with full breakpoints support. Cross-platform. Code::Blocks' interface is both customizable and extensible with Syntax highlighting, a tabbed interface, Class Br...

Google hoaxes and easter egges

Easter eggs [ edit ] Google has added many  Easter eggs  to its products and services. Calculator [ edit ] The Calculator accepts many  humorous units of measurement , including the  Beard-second  (5 nm),  Potrzebie  (2.2633 mm),  Smoot  (5 ft, 7 inches), ngogn (11.5938151 ml), blintz (36.4253863 g),  donkeypower  (250.033167 W); and the prefixes  hella - (10^27), furshlugginer- (10^6), etc. The Calculator recognizes a number of strings as numbers. They can be entered by themselves or used in expressions. They must be entered without quotation marks. When used in an expression, the phrases must be entered in lowercase. In addition to mathematical and scientific constants like  pi ,  e  and  Avogadro's number  the Calculator also accepts: "the answer to the ultimate question of life, the universe, and everything"  equals  42  as does  "the answer to life, the...

Internet Download Manager (IDM}

Internet Download Manager (IDM) is a tool to increase download speeds by up to 5 times, resume and schedule downloads. Comprehensive error recovery and resume capability will restart broken or interrupted downloads due to lost connections, network problems, computer shutdowns, or unexpected power outages. Simple graphic user interface makes IDM user friendly and easy to use.Internet Download Manager has a smart download logic accelerator that features intelligent dynamic file segmentation and safe multipart downloading technology to accelerate your downloads. Unlike other download managers and accelerators Internet Download Manager segments downloaded files dynamically during download process and reuses available connections without additional connect and login stages to achieve best acceleration performance. Internet Download Manager supports proxy servers, ftp and http protocols, firewalls, redirects, cookies, authorization, MP3 audio and MPEG video content processing. IDM integra...

C++ Program to find out the Prime number's By sieve Method

NOTE : YOU CAN DOWNLOAD EXE FILE HERE: SIEVE.EXE SORUCE CODE (RTF): source.cpp click here   1  #include <iostream>  2  #include <conio.h>  3  using namespace std ;  4  int main ()  5   6  {  7   8  int number , n = 2 ;  9  cout << "Program to find out Prime number by sieve method\n\n\a" ; 10  11  cout << "Enter upto which number you want to find out the prime number\n" ; 12  cin >> number ; 13  int arr [ number ]; 14  for ( int i = 0 ; i < number ; i ++) 15  arr [ i ]= i + 1 ; 16  cout << "  Original number:\n" ; 17  18  for ( int i = 0 ; i < number ; i ++) 19  { 20  21  22      cout << arr [ i ]<< "\t\a" ; 23  24  } 25  while (( n * n )< number )  // while n 2  ...