Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class LinkList {
- private Node tmp;
- private int len;
- public LinkList(){
- len=0;
- tmp=null;
- }
- void add(int val){
- if(tmp==null){
- tmp=new Node(val, null,null);
- }
- else{
- while(tmp.r!=null) tmp=tmp.r;
- Node t = new Node(val,tmp,null);
- tmp.r=t;
- }
- }
- public void show(){
- while(tmp.r!=null)tmp=tmp.r;
- while(tmp!=null){
- System.out.println(tmp.val+" ");
- tmp=tmp.l;
- }
- }
- }
- class Node{
- int val;
- Node l,r;
- public Node(int val, Node l, Node r) {
- this.val = val;
- this.l = l;
- this.r = r;
- }
- }
- smartAdd
Add Comment
Please, Sign In to add comment