编程实现:请用折半查找法在下面的数组中查找出数据成员92。
Array = {7,12,34,105,37,58,5,43,25,46,80,92}
Array = {7,12,34,105,37,58,5,43,25,46,80,92}
解决方案 »
- JMS 两个j2ee程序之间发消息
- java.lang.OutOfMemoryError: Java heap space
- 关于OpenSessionInView的问题,求大大帮忙。
- java 题 !!!!!
- JSP mysql批量插入数据的一问题 用的是方法executeBatch
- struts+hibernate+spring架构是怎样搭建的
- tomcat不认contains方法
- 当session失效后重新登录成功,如何实现页面不跳转到主页而是跳转到session失效时的页面
- 简单问题
- 急: jboss3+mysql3发布EJB问题~
- 用HttpUrlConnection和URL类如何将本地的文件保存到服务器
- javase过渡到javaee的方法和路线
2分查找随便找下都一大堆。。
public static int findNum(int nums[],int find_num){
int left = 0;
int right = nums.length-1;
while(left <= right){
int midle = (left+right)/2;
if(nums[midle] > find_num){
right = midle - 1;
}else if(nums [midle] < find_num){
left = midle + 1;
}else {
return midle;
}
}
return -1;
}
public static void main(String args[]){
int [] array = {7,12,34,105,37,58,5,43,25,46,80,92};
Arrays.sort(array);
for(int i = 0 ; i< array.length ; i++){
System.out.print(array[i]+" ");
}
System.out.println(findNum( array,92));
}
简单写了个。。
无序的数组 要先排序 才能2分查找。 最终结果是得到排序后的位置。
大于-1表示存在,等于-1表示不存在
I send you this email following up the conversation we had about the DWH report discrepancies Marketing recently detected.Marketing produced a report on 2010-09-16 which contained 1,722 events generated from 2010-02-07 to 2010-09-16. They compared this report to the one they created on 2010-07-13 which contained 13,837 events generated from 2010-01-08 to 2010-07-13.
The main discrepancy is on the number of events. The latest report covers a wider period of time, so it is supposed to have a bigger number of events that the older one, but instead of that it has a smaller number of events: 1,722 against 13,837.
After analysing and comparing the information from both reports we see that the latest report has lost the period of time from 2010-01-08 to 2010-02-07. The other difference we discovered is that the number of events for several MSISDN has dramatically decreased, as you can see on the following table:
MSISDN Number of events on 2010-07-13 report Number of events on 2010-09-16 report difference
34610514481 604 1 -603
34647480305 610 0 -610
34662472305 2038 8 -2030
34662478906 731 43 -688
34662682566 618 0 -618
34663083476 613 2 -611
34664943947 656 0 -656
34667405067 2357 469 -1888
34670413695 655 9 -646
34670515186 380 1 -379
34670544195 664 58 -606
34680422250 1222 0 -1222
34687110014 1409 0 -1409
We assume Huawei recalculated the statistics taking out the events coming from the testing MSISDN. There are 3 MSISDN (highlighted in yellow) which still have a significant number of events, though.
We need you to confirm this assumption and clarify the method you used to clean up the testing events.
Although, Marketing agrees on cleaning up the events coming from testing MSISDN, from now on we strongly request Huawei not to change anything on the existing statistics data-base without getting written approval from Vodafone.
We need you to clarify which is the method VBP uses to update statistics on Vodafone DWH: is VBP generating and sending each time the whole data-base from the beginning to DWH or is VBP generating a partial set of data only containing the events from the last report sent to Vodafone DWH?