资源描述:
《亚信校招笔精彩试题目》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、实用文档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;文案大全实用文档}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];//初始化高速缓存数组文案
6、大全实用文档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<