面試總結2

一、MySQL查詢方式:https://www.cnblogs.com/bypp/p/7755307.htmlphp

二、hhvmhtml

三、如何判斷一個二叉樹是否爲二叉搜索樹java

中序遍歷:node

  /**
    * Definition for binary tree
    * public class TreeNode {
    * int val;
    * TreeNode left;
    * TreeNode right;
    * TreeNode(int x) { val = x; }
    * }
    */
    import java.util.*;
    public class Solution {
        public boolean isValidBST(TreeNode root) {
            ArrayList<TreeNode> list = new ArrayList<TreeNode>();
            if(root ==null){
                return true;
            }
            inorder(root,list);
            for(int i=0;i<list.size()-1;i++){
                if(list.get(i).val>=list.get(i+1).val){
                    return false;
                }
            }
            return true;
        }
        
        public static void inorder(TreeNode root,ArrayList<TreeNode> list){
            if(root!=null){
                inorder(root.left,list);
                list.add(root);
                inorder(root.right,list);
            }
        }
    }

四、二叉樹層次遍歷php-fpm

	public void levelIterator(TreeNode n){  
		Queue<TreeNode> queue = new LinkedList<TreeNode>();  
		queue.offer(n);  
		while (!queue.isEmpty()) {  
			TreeNode t = queue.poll();  
			if (t !=null) {  
				System.out.println("key:"+t.key+"--name:"+t.data);
			}  
			if (t.leftChild !=null) {  
				queue.offer(t.leftChild);  
			}  
			if (t.rightChild !=null) {  
				queue.offer(t.rightChild);  
			}
		}
	}  

五、二叉樹非遞歸後續遍歷spa

//前序遍歷的非遞歸實現  
        public void nonRecPreOrder(TreeNode p){    
            Stack<TreeNode> stack=new Stack<TreeNode>();    
            TreeNode node=p;    
            while(node!=null||stack.size()>0){    
                while(node!=null){    
                    System.out.println("key:"+node.key+"--name:"+node.data);;     
                    stack.push(node);   
                    node=node.leftChild;    
                }    
                if(stack.size()>0){   
                    node=stack.pop();    
                    node=node.rightChild;   
                }    
            }    
        } code

 

//中序遍歷的非遞歸實現    
        public void nonRecInOrder(TreeNode p){    
            Stack<TreeNode> stack =new Stack<TreeNode>();    
            TreeNode node =p;    
            while(node!=null||stack.size()>0){    
                //存在左子樹    
                while(node!=null){    
                    stack.push(node);    
                    node=node.leftChild;    
                }    
                //棧非空    
                if(stack.size()>0){    
                    node=stack.pop();    htm

      System.out.println("key:"+node.key+"--name:"+node.data);  blog

                    node=node.rightChild;    
                }    
            }    
        }    

遞歸

//後序遍歷的非遞歸實現    
    public void noRecPostOrder(TreeNode p){    
        Stack<TreeNode> stack=new Stack<TreeNode>();    
        TreeNode node =p;    
        while(p!=null){    
            //左子樹入棧    
            for(;p.leftChild!=null;p=p.leftChild){    
                stack.push(p);    
            }    
            //當前結點無右子樹或右子樹已經輸出    
            while(p!=null&&(p.rightChild==null||p.rightChild==node)){    
                System.out.println("key:"+p.key+"--name:"+p.data);;        
                //紀錄上一個已輸出結點    
                node =p;    
                if(stack.empty())    
                    return;    
                p=stack.pop();    
            }    
            //處理右子樹    
            stack.push(p);    
            p=p.rightChild;    
        }    
    }

六、php-fpm的運行方式

七、Innodb和missame 全部有什麼區別

相關文章
相關標籤/搜索