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

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 

python program to take nested list input ...(nested list addition ,substraction etc)

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 #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Mar 13 14:25:56 2018 @author: beast Note this program is for holding int value to list only """ def inmatrix (): matrixA = list () # intialize matrix as empty list try : row,col = [ int (j) for j in ( input ( "Enter the row and col " ) . split())] print (row,col) inp = "" except ValueError : print ( "Please Enter row and col seperated by space eg: 2 2" ) inmatrix() for i in range (row): for j in range (col): inp += (( input ( "Enter the number--->" )) + "," ) try : lst = [ int (a) for a in inp . split( "," ) if a != "" ] #delete int for making it to hold any data

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

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 your blog. In this tutorial, I

3g what it is

Definition of 3G: 3G is the third generation of wireless technologies. It comes with enhancements over previous wireless technologies, like high-speed transmission, advanced multimedia access and global roaming. 3G is mostly used with mobile phones and handsets as a means to connect the phone to the Internet or other IP networks in order to make voice and video calls, to download and upload data and to surf the net. How is 3G Better?: 3G has the following enhancements over 2.5G and previous networks: Several times higher data speed; Enhanced audio and video streaming; Video-conferencing support; Web and WAP browsing at higher speeds; IPTV (TV through the Internet) support. 3G Technical Specifications: The transfer rate for 3G networks is between 128 and 144 kbps (kilobits per second) for devices that are moving fast and 384 kbps for slow ones(like for pedestrians). For fixed wireless LANs, the speed goes beyond 2 Mbps. 3G is a set of technologies and stand

[solution] Motorola moto G5S plus | xt1804|Sanders Magisk error 1 : cannot mount /vendor

Error: mainly all error 1 errors. can not mount /vendors... Cause : Since your current TWRP is not treble supported ,You need a Treble supported Recovery. Solution : Simpally download this file and then flash it .  this recovery is treble supported 1. VIA TWRP boot to twrp recovery  goto install .  touch on install image and then select this downloaded file (.img)  select recovery  then flash it 2. Using fastboot fastboot flash recovery <(downloaded.img)> NOW YOU CAN FLASH MAGISK zip file via recovery LINK : TWRP_SANDERS_r22_BY_GENETIC ENGINEER

Structure of C Programs

Objectives: Having completed this section you should know about: 1.C's character set 2.C's keywords 3.the general structure of a C program 4.that all C statement must end in a ; 5.that C is a free format language 6.all C programs us header files that contain standard library functions. C's Character Set: C does not use, nor requires the use of, every character found on a modern computer keyboard. The only characters required by the C Programming Language are as follows: A - Z a -z 0 - 9 space . , : ; ' $ " # % & ! _ {} [] () < > | + - / * = The use of most of this set of characters will be dicussed throughout the course. The form of a C Program: All C programs will consist of at least one function, but it is usual (when your experience grows) to write a C program that comprises several functions. The only function that has to be present is the function called main. For more advanced programs the main functi

python program get union of two list (program to get A union B ) list method .

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 #!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Mar 16 17:08:52 2018 @author: beast """ def version1 (): a = [ 'a' , 'b' , 'c' , 'd' , 'e' ] # list 1 b = [ 'a' , 'b' , 'c' , 'd' , 'e' , 'f' , 'g' , 'h' ] # list 2 c = [k for k in (a) if (k in (a) and k not in (b))] # include unique item from list 1 : items are (list1-list2)(set thoery) d = [l for l in (b) if l in (a ) and l in (b) or (l not in (a) and l in (b))] #include all the comman from list 1 and unique from list 2 lst = c + d # append above two comprehensed list to get union of list1 U list2 lst . sort() # not neccessay but makes list easy to understand (sorting in ascending order )

C Program for Password Login IN CUI

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 #include <stdio.h> char str; char passwd[ 100 ]; void main () { int i = 0 ,j; printf( "Enter the text now \n " ); while ((str = getch()) != '\r' ) { if (str == '\b' ){ // if a backspace key is used then go back printf( " \b \b " ); i -- ; } else { passwd[i ++ ] = str; printf( "*" ); // hide the password } } printf( " \n Finished " ); printf( " \n Your password is ->" ); for ( j = 0 ;j < i;j ++ ) printf( "%c" ,passwd[j]); getch(); }