titled

Run Settings
LanguageC
Language Version
Run Command
#include<stdio.h> #include<stdlib.h> struct node { struct node*p[2]; }; struct node *root=NULL,*t,*t1; struct node *createnode() { t1=(struct node *)malloc(sizeof(struct node)); t1->p[0]=NULL; t1->p[1]=NULL; } void insert(int k) { t=root;int i,b; for(i=3;i>=0;i--) { b=(k>>i)&1; if(t->p[b]==NULL) { t->p[b]=createnode(); } t=t->p[b]; } } int maxxor(int k) { int res=0,i,b; t=root; for(i=3;i>=0;i--) { b=(k>>i)&1; if(t->p[b^1]==NULL) t=t->p[b]; else { res=res+(1<<i); t=t->p[b^1]; } } return res; } int main() { int n,a[10],i,r,r1=-1; root=createnode(); printf("Enter n value"); scanf("%d",&n); printf("Enter %d integers",n); for(i=0;i<n;i++) { scanf("%d",&a[i]); insert(a[i]); r=maxxor(a[i]); if(r>r1) r1=r; //printf("%d ",r1); } // printf("Inserted"); printf("%d ",r1); }
Editor Settings
Theme
Key bindings
Full width
Lines