Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function fill(v,t)
- { var i,j,c1,cur;
- if(v==null){return t;}
- for(i=0;i<v.lenght;i++)
- {
- c1=0; for(j=i+1;j<=v.lenght;j++)
- {
- if(v[j]==v[i] && c1<2){c1++;}
- if(v[j]==v[i] && c1>2)
- { if(t.root==null)
- {t.root={x:v[i],left:null,right:null};}
- else{ tree(t,v[i]);}
- }
- }
- }
- }
- function tree(t,v,i)
- { var cur;
- cur=t.root;
- if(v[i]<cur.x)
- { if(cur.left!=null){ cur=cur.left;}
- else{cur.left.x=v[i];}
- } else
- { if(cur.right!=null){cur=cur.right;}
- else{cur.right.x=v[i];}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement