資源描述:
《亞信校招筆精彩試題目》由會員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、實(shí)用文檔1.BSTpublicclassBSTMinLength{publicstaticvoidmain(String[]args){TreeNodetNode11=newTreeNode(10,null,null);TreeNodetNode12=newTreeNode(50,null,null);TreeNodetNode13=newTreeNode(5,null,null);TreeNodetNode14=newTreeNode(30,null,null);TreeNodetNode21=newTreeNode(30
2、,tNode11,tNode12);TreeNodetNode22=newTreeNode(30,tNode13,tNode14);TreeNodetNodeRoot=newTreeNode(100,tNode21,tNode22);System.out.println(minlength(tNodeRoot));}privatestaticintminlength(TreeNodetNode){if(tNode!=null){returngetlength(tNode,0);}return-1;}privatestatic
3、intgetlength(TreeNodetNode,intcurLength){intminLeft=-1;intminRight=-1;if(tNode.leftNode!=null){minLeft=getlength(tNode.leftNode,curLength+tNode.value);}if(tNode.rightNode!=null){minRight=getlength(tNode.rightNode,curLength+tNode.value);}if(tNode.leftNode==null&&tNo
4、de.rightNode==null){returncurLength+tNode.value;文案大全實(shí)用文檔}if(tNode.leftNode==null){returnminRight;}if(tNode.rightNode==null){returnminLeft;}returnminLeft>minRight?minRight:minLeft;}}classTreeNode{intvalue;TreeNodeleftNode;TreeNoderightNode;TreeNode(intvalue,TreeNode
5、lefeNode,TreeNoderightNode){this.value=value;this.leftNode=lefeNode;this.rightNode=rightNode;}}2.lru#includeusingnamespacestd;intlruCountMiss(intmax_cache_size,intpages,intlen){intcount=0;inti,j,k,n;boolflag=false;inta=newint[max_cache_size];//初始化高速緩存數(shù)組文案
6、大全實(shí)用文檔for(i=0;i7、用文檔{a[n]=a[n+1];}a[max_cache_size-1]=pages[j];}else{flag=false;for(n=i;n8、[max_cache_size-1]=pages[j];}elseflag=false;}}returncount;}intmain(){intarr[]={7,0,1,2,0,3,0,4};cout<