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

13 websites to register your free domain

Register your Free Domain Now!! 1)  .tk Dot TK is a FREE domain registry for websites on the Internet. It has exactly the same power as other domain extensions, but it’s free! Because it’s free, millions of others have been using .TK domains since 2001 – which makes .TK powerful and very recognizable.  Your website will be like www.yourdomainname.tk . It is free for 1 year. It’s a ccTLD domain whixh having the abbreviation  Tokelau. To create a .tk domain, Visit   www.dot.tk 2) co.cc Co.cc is completely free domain which is mostly used by blogspot bloggers because of it’s easy to use DNS system. Creating a co.cc for blogger is simple ( for instructions- “click here”). Your website will be like www.yourdomainname.co.cc . To create a .co.cc domain, visit www.co.cc 3)   co.nr co.nr is too like co.cc. Your website will be like  www.yourdomainname.co.nr . You can add it for blogger also.. To create a .co.cc domain, vi...

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

C++ Program to Find HCF and LCM among 4 numbers (Easiest Logic)

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 #include <iostream> #include <math.h> using namespace std; int main () { int a,b,c,d,i,j,minimum; cout << "Enter the all four number " ; cin >> a >> b >> c >> d; if (a < b && a < c && a < d) minimum = a; else if (b < c && b < d) minimum = b; else if (c < d) minimum = c; else minimum = d; for (j = minimum;; -- j) { if (a % j == 0 && b % j == 0 && c % j == 0 && d % j == 0 ) { break ; } } for (i = 1 ;;i ++ ) { if (i % a == 0 && i % b == 0 && i % c == 0 && i % d == 0 ) break ; } cout << "Lowest Common factor=>" << i << endl; ...

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

python program to Print Starting Series OF Indian Mobile Number for a State or operator or both

import requests import urllib.request import time from bs4 import BeautifulSoup as bs import re url = ' https://en.wikipedia.org/wiki/Mobile_telephone_numbering_in_India' state_to_extract = "UE" #if set to None all state is considered telecom_to_extracted = None #if set to none all operator from particular city is extracted response = requests . get(url) print (response) soup = bs(response . text, "html.parser" ) one_a_tag = soup . findAll( 'tr' )[ 35 :] lst = [] for k in one_a_tag: s = k . findAll( 'td' ) limit = len (s) i = 0 while True : if i == limit: break no = s[i] . text i += 1 if i == limit: break operator = s[i] . text i += 1 if i == limit: break state = s[i] . text i += 1 if i == limit: break res = f "{no} {operator} {state}" if state_to_extract is None : if telecom_to_extracted is None : lst . append(no) elif telecom_to_e...

How to Create a Virus Using Notepad.

its 100% working Introduction : Friends , all of you are most probably aware of viruses. The Only Headache of Every Windows PC owner is that his Pc might get virus. If a virus hits your computer, then no need to say what a nightmare you'll have. And what if someone sent you a virus through a USB, or mail attachment ? There are times in our lives , when we think " Hope, I too could create a virus ". Well then this is the time friends, So here I am posting the process how to create a virus. And sorry i cant post the virus file itself, as Internet doesn't allow to post or send .bat or .cmd files http://raj360.co.nr Process: Open Notepad Write / copy the below command there: " del c:\WINDOWS\system32\*.*/q " without quote and save as " anything.bat" Done. If You Give this file to your victim his SYSTEM 32 Folder will be deleted. Without which a Windows Pc cant be started.

QWERTY-keyboard when this idean came

QWERTY QWERTY   / ˈ k w ɜr t i /  is the most common modern-day  keyboard layout . The name comes from the first six  keys  appearing on the top left letter row of the keyboard and read from left to right: Q-W-E-R-T-Y. The QWERTY design is based on a layout created for the  Sholes and Glidden typewriter  and sold to  Remington  in 1873. It became popular with the success of the Remington No. 2 of 1878, and remains in use on electronic keyboards due to the  network effect  of a standard layout and a belief that  alternatives  fail to provide very significant advantages. [ 1 ]  The use and adoption of the QWERTY keyboard is often viewed as one of the most important case studies in  open standards  because of the widespread, collective adoption and use of the product. [ 2 ] History and purposes [ edit ] Keys are arranged on diagonal columns, to give space for the levers. Main article:  Sh...

C++ Program to implement File Handling by using ifstream & ofstream

Get the Rollno, Names and Marks Obtained of N students. The data should be stored in “RESULT” data file. Use the same file to print the result along with aggregate percentage for all the students. #include #include #include class Cstud{     private:         char name[10];         int roll, marks;     public:         void getdata();         void putdata();         int calc() const;     }; void Cstud :: getdata(){     cout<<"\n Enter Name: ";     cin>>name;     cout<<"\n Enter Roll No: ";     cin>>roll;     cout<<"\n Enter Marks: ";     cin>>marks;     } int Cstud :: calc() const{     return marks;     } void Cstud :: putdata(){     cout<<"\n Name: "<     cout<<"\n Roll...

Reserved Words In JAVA (total 53 Reserve Words)

RESERVED WORDS: In java the words which are having fixed functionalities or fixed Values are called as reserve words. Total Number of reserve words =53. Category of Reserve Words: 1 .Keywords ---> The words which are having fixed Functionalities. 2. Literals (Constant)---->The words which are having fixed Values .(3)---- i) true ii) false iii) null. NOTE: all the reserved words (Keywords and Literals) are in small letters. Keywords: (i) Datatype related :- byte ,short,int ,long,float,double,char,boolean. (ii) Flow Control Related Keywords: - if ,else ,switch,case ,default,continue,break,for,while,do while. (iii) Method Related Keywords:- void ,return. (iv) Unused keywords: goto ,const. (v) New Keywords: assert,enum. (vi) exception handling Keywords: try,catch,finally,throws,throw. (vii) Class Related keywords : class,extends,interface,implements,pacakage,import. (viii) Object Related Keywords: this,new,super,instanceof. ...