• Technology News

    Binary Search Tree

    #include<stdio.h> #include<stdlib.h> typedef struct treeNode { int data; struct treeNode *left; struct treeNode *right; }treeNode; treeNode* FindMin(treeNode *node) { if(node==NULL) { /* There is no element in the tree */ return NULL; } if(node->left) /* Go to the left sub tree to find the min element */ return FindMin(node->left); else return node; } treeNode* FindMax(treeNode…

  • Technology News

    Insertion Sort in c++

    #include<conio.h> #include<iostream.h> void main() { clrscr(); int a[20],i,j,temp,size,ptr; cout<<”Enter the size of array “; cin>>size; cout<<”Enter the elements in array “; for(i=1;i<=size;i++) cin>>a[i]; a[0]=0; for(i=2;i<=size;i++) { temp=a[i]; ptr=i-1; while(temp<a[ptr]) { a[ptr+1]=a[ptr]; ptr–; } a[ptr+1]=temp; cout<<a[1]<<” “<<a[2]<<” “<<a[3]<<” “<<a[4]<<” “<<a[5]<<endl; } cout<<”\n\n\nAfter insertion “; for(i=1;i<=size;i++) { cout<<a[i]<<endl; } getch(); }

  • Technology News

    Radix Sort Program in c++

    #include<stdio.h> #include<conio.h> #include<iostream.h> void main() { clrscr(); int sorted[10],k=0; int size,arr[20],i,j ; int bucket[10][10],temparr[20];; cout<<”Enter size of array “; cin>>size; cout<<”Enter elements in array “; for(i=0;i<size;i++) { cin>>arr[i]; }   //find the largest int largest=arr[0]; for(i=1;i<size;i++) { if(arr[i]>largest) { largest=arr[i]; } } cout<<”\nLargest no. is “<<largest; //no. of digits in largest int count=0; while(largest>0) {…

  • Technology News

    Polyalphabetic with autokey Vignere

    #include<conio.h> #include<iostream.h> #include<string.h> void main() { clrscr(); char st[26],k[26],key[26]; int stl,i; cout<<”Enter simple text “; cin>>st; stl=strlen(st); cout<<”Enter key “; cin>>k; int kk=strlen(k),j=0,r=0; for(i=0;i<stl;i++,j++) { key[i]=k[j]; if(i>(kk-1)) { key[i]=st[r]; r++; } } key[i]=’\0′; cout<<”\nKey after repeat :”<<key; int add,add1,add2; char ct[26]; for(i=0;i<stl;i++) { add1=int(st[i])-97; add2=int(key[i])-97; add=add1+add2; ct[i]=(add%26)+97; } ct[i]=’\0′; cout<<”\n Cipher text is : “;…

  • Technology News

    Polyalphabetic simple without autokey

    #include<conio.h> #include<iostream.h> #include<string.h> void main() { clrscr(); char st[26],k[26],key[26]; int stl,i; cout<<”Enter simple text “; cin>>st; stl=strlen(st); cout<<”Enter key “; cin>>k; int kk=strlen(k),j=0; for(i=0;i<stl;i++) { key[i]=k[j]; j++; if(i==(kk-1)) { j=0; } } key[i]=’\0′; cout<<”\nKey after repeat :”<<key; int add,add1,add2; char ct[26]; for(i=0;i<stl;i++) { add1=int(st[i])-97; add2=int(key[i])-97; add=add1+add2; ct[i]=(add%26)+97; } ct[i]=’\0′; cout<<”\n Cipher text is : “;…

  • Technology News

    Monoalphabetic program in c++

    #include<conio.h> #include<iostream.h> #include<string.h> void main() { clrscr(); char alpha1[26],pt[26],ct[26]; int a=97,i,z; for(i=0;i<26;i++) { cout<<”Enter char for : “<<char(a+i)<<” “; cin>>alpha1[i]; } cout<<”\nEnter Plain Text “; cin>>pt; for(i=0;i<strlen(pt);i++) { z=int(pt[i]-97); ct[i]=alpha1[z]; } ct[i]=’\0′; cout<<”\nThe cipher text is : “<<ct; char rt[26]; for(int y=0;y<strlen(pt);y++) { for(i=0;i<26;i++) { if(ct[y]==alpha1[i]) { rt[y]=char(i+97); } } } rt[y]=’\0′; cout<<”\nThe plain text…

  • Technology News

    Diffie Hellman program in c++

     #include<conio.h> #include<iostream.h> #include<math.h> void main() { int p,q,gen[20][20],pr=2,count=0,i,n,flag[20],pw,y; int prr,a,b,k1,k2; gen[0][0]=0; clrscr(); cout<<”\nEnter the value of p (should be prime number)”; cin>>p; cout<<”\nvalue of q (should be primitive root of p\n\n”; cin>>q; /* for(i=1;i<p;i++) { for(n=1;n<p;n++) { pw=pow(pr,n); gen[i][n]=pw%p; cout<<gen[i][n]<<”\t”; } pr=pr+1; cout<<”\n”; } for(int x=1;x<p;x++) { for(int z=1;z<p;z++) { for(y=1;y<p;y++) { if(gen[x][z]==gen[x][y]) { }…

  • Technology News

    DES (Data Encryption Standard) Program in c++

    #include<iostream.h> #include<string.h> #include<math.h> #include<conio.h> int ip1[4][8]; int ip2[4][8]; void ip_shift(); int cnt=0; int bb=0; int binaryBits[64]; void binary(int y); void ip(); int k=0,rem[20]; int hexa[64]; void main() { clrscr(); char msg[16],z; int i; cin>>msg; for(i=0;i<strlen(msg);i++) { cnt=cnt+4; if(msg[i]==’A’) { binary(10); } else if(msg[i]==’B’) { binary(11); } else if(msg[i]==’C’) { binary(12); } else if(msg[i]==’D’) { binary(13);…