网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

如果用low和high分别指向搜索区间的下界和上界,折半查找失败的判定条件是low>high的结果为真值。


参考答案和解析
A
更多 “如果用low和high分别指向搜索区间的下界和上界,折半查找失败的判定条件是low>high的结果为真值。” 相关考题
考题 ENUM类型的字段level定义为(LOW、MIDDLE、HIGH),ORDERBYlevelasc的顺序是() A、HIGH、LOW、MIDDLEB、LOW、MIDDLE、HIGHC、MIDDLE、LOW、HIGHD、HIGH、MIDDLE、LOW

考题 ●试题三阅读下列函数说明和C代码,将应填入(n)处的字句写在答题纸的对应栏内。【说明】函数move(int*a,int n)用于整理数组a[]的前n个元素,使其中小于0的元素移到数组的前端,大于0的元素移到数组的后端,等于0的元素留在数表中间。令a[0]~a[low-1]小于0(初始为空);a[low]~a[i-1]等于0(初始为空);a[i]~a[high]还未考察,当前考察元素为a[i]。a[high+1]~a[n-1]大于0(初始为空)。【函数】move(int*a,int n){int i,low,high,t;low=i=0;high=n-1;while( (1) )if(a[i]0){t=a[i];a[i]=a[low];a[low]=t;(2) ;i++;}else if( (3) ){t=a[i];a[i]=a[high];a[high]=t;(4) ;}else (5) ;}

考题 N个有序整数数列已放在一维数组中,给定下列程序中,函数fun()的功能是:利用折半查找算法查找整数m在数组中的位置。若找到,则返回其下标值:反之,则返回-1。折半查找的基本算法是:每次查找前先确定数组中待查的范围:low和high(low<high),然后把m与中间位置(mid)中元素的值进行比较。如果m的值大于中间位置元素中的值,则下一次的查找范围放在中间位置之后的元素中;反之,下次查找范围落在中间位置之前的元素中。直到low>high,查找结束。请改正程序中的错误,使它能得出正确的结果。注意:不要改动main函数,不得增行或删行,也不得更改程序的结构。试题程序:include <stdio.h>define N 10/*************found*********************/void fun(int a[],int m){ int low--0,high=N-l,mid;while (low<=high){ mid=(low+high)/2;if(m<a[mid])high=mid-1;/*************found*********************/else if(m>=a [mid])low=mid+1;else return(mid);}return(-1);}main (){ int i,a[N]={-3,4,7,9,13,24,67,89,100,180},k,m;printf ("a数组中的数据如下: ");for(i=0;i<N;i++) printf("%d",a[i]);printf ("Enter m: "); scanf ("%d", m);k=fun (a,m);if (k>=0) printf ("m=%d, index=%d\n",m, k);else printf("Not be found!\n");}

考题 在11个元素的有序表A[1…11)中进行折半查找[L(low+high)/2],查找元素A[11]时,被比较的元素的下标依次是(49)。A.6,8,10,11B.6,9,10,11C.6,7,9,11D.6,8,9,11

考题 在华为Quidway系列路由器中,缺省情况下PQ的各队列的默认长度为( )。 A. high-20 medium-40 normal-60 low-80B. high-20 medium-20 normal-20 low-20C. high-10 medium-20 normal-40 low-80D. high-80 medium-60 normal-40 low-20

考题 The desirable properties of a marine fuel oil should include .A.high flash point and high viscosityB.low flash point and high viscosityC.low heating value and high sulphur contentD.high heating value and low sulphur content

考题 在11个元素的有序表A[1..11]中进行折半查找(|(low+high)/2|),查找元素A[11]时,被比较的元素的下标依次是(44)。A.6,8,10,11B.6,9,10,11C.6,7,9,11D.6,8,9,11

考题 The soundings on the chart are based on the depth of water available at ______.A.mean low waterB.mean lower low waterC.mean high waterD.mean high water springs

考题 Mean low water is the average height of ______.A.the surface of the seaB.high waters and low watersC.all low watersD.the lower of the two daily low tides

考题 Every vent system outlet to atmosphere from a valve shall be located as high and at the furthest distance from a source of ignition as is practicable ______.A.low and at the shortest distanceB.low and at the furthest distanceC.high and at the shortest distanceD.high and at the furthest distance

考题 A barometer showing falling pressure indicates the approach of a ______.A.high pressure systemB.low pressure systemC.high dew pointD.low dew point

考题 第四题 阅读以下说明、C函数和问题,回答问题1和问题2将解答填入答题纸的对应栏内。 【说明】 当数组中的元素已经排列有序时,可以采用折半查找(二分查找)法查找一个元素。下面的函数biSearch(int r[],int low,int high,int key)用非递归方式在数组r中进行二分查找,函数biSearch_rec(int r[],int low,int high,int key)采用递归方式在数组r中进行二分查找,函数的返回值都为所找到元素的下标;若找不到,则返回-1。 【C函数1】 int biSearch(int r[],int low,int high,int key) //r[low..high] 中的元素按非递减顺序排列 //用二分查找法在数组r中查找与key相同的元素 //若找到则返回该元素在数组r的下标,否则返回-1 { int mid; while((1)) { mid = (low+high)/2 ; if (key ==r[mid]) return mid; else if (key (2); else (3); }/*while*/ return -1; }/*biSearch*/ 【C 函数 2】 int biSearch_rec(int r[],int low,int high,int key) //r[low..high]中的元素按非递减顺序排列 //用二分查找法在数组r中查找与key相同的元素 //若找到则返回该元素在数组r的下标,否则返回-1 { int mid; if((4)) { mid = (low+high)/2 ; if (key ==r[mid]) return mid; else if (key return biSearch_rec((5),key); else return biSearch_rec((6),key); }/*if*/ return -1; }/*biSearch_rec*/ 问题:4.1 (12分) 请填充C函数1和C函数2中的空缺,将解答填入答题纸的对应栏内。 问题:4.2 (3分) 若有序数组中有n个元素,采用二分查找法查找一个元素时,最多与( )个数组元素进行比较,即可确定查找结果。 (7)备选答案: A.[log2(n+1)] B.[n/2] C.n-1 D.n

考题 给定包含n个正整数的数组A和正整数x,要判断数组A中是否存在两个元素之和等于x,先用插入排序算法对数组A进行排序,再用以下过程P来判断是否存在两个元素之和等于x。low=1;high=n;while(high>low)if A[low]+A[high]=x return true;else if A[low]+A[high]>x low++;else high--;return false;则过程P的时间复杂度为( ),整个算法的时间复杂度为(请作答此空)。A.O(n) B.O(nlgn) C.O(n2) D.O(n2lgn)

考题 数据结构与算法里,折半查找中,low指向低端的记录,high指向高端的记录,每次计算中间位置mid的公式是()。A、(lowhigh)/2B、(low+high)/2C、(low-high)/2D、low/2+high/2

考题 数字口可以输出(),可以输入()。A、0(LOW)或1(HIGH);0-1023B、0(LOW)或1(HIGH);0.1023C、0(LOW)或1(HIGH);0或1D、0(LOW)或1(HIGH);0

考题 设定电机4号针脚为HIGH,5号为150时,此时电机以中等速度反转。如果想要让电机更快速度正转,则4号针脚是(),5号针脚是()。A、LOW;220B、LOW;100C、HIGH;220

考题 The population decreased from the 1840s until about 1970,largely because of().A、a low birth rateB、a high death rateC、a low employment rateD、a high emigration rate

考题 HIGH(或高)和LOW(或低)分别表示电机的正转或反转,这取决于电机的接线。

考题 完成下列折半插入排序算法。 Void binasort(struct node r[MAXSIZE],int n) {for(i=2;i=n;i++){ r[0]=r[i];low=1;high=i-1; while(low=high){ mid=(low+high)/2; if(r[0].key else low=mid+1 ; } for(j=i-1;j=low;j- -)r[j+1]=r[j] ; r[low]=() ; } }

考题 风挡排雨系统风挡雨刷的工作由P5板底部的三位旋钮(HIGH,LOW,OFF)控制:()A、HIGH位马达线圈串联, LOW位马达线圈并联,OFF位马达反转到停留位后断电B、HIGH位马达线圈并联, LOW位马达线圈串联,OFF位马达反转到停留位后断电C、HIGH位马达线圈并联, LOW位马达线圈串联,OFF位马达正转到停留位后断电D、HIGH位马达线圈串联, LOW位马达线圈并联,OFF位马达正转到停留位后断电

考题 单选题数据结构与算法里,折半查找中,low指向低端的记录,high指向高端的记录,每次计算中间位置mid的公式是()。A (lowhigh)/2B (low+high)/2C (low-high)/2D low/2+high/2

考题 单选题Two well-developed high pressure areas may be separated by a().A Hill of low pressureB Trough of low pressureC Valley of low pressureD Ridge of low pressure

考题 单选题The direction of the surface wind is().A directly from high pressure toward low pressureB directly from low pressure toward high pressureC from high pressure toward low pressure deflected by the earth's rotationD from low pressure toward high pressure deflected by the earth's rotation

考题 单选题The population decreased from the 1840s until about 1970,largely because of().A a low birth rateB a high death rateC a low employment rateD a high emigration rate

考题 单选题The soundings on the chart are based on the depth of water available at ().A mean low waterB mean lower low waterC mean high waterD mean high water springs

考题 单选题A tide is called diurnal when().A only one high and one low water occur during a lunar dayB the high tide is higher and the low tide is lower than usualC the high tide and low tide are exactly six hours apartD two high tides occur during a lunar day

考题 单选题Operational amplifiers, used primarily in analog circuits, are characterized by()A high input impedance, high gain and low output impedanceB high input impedance, high gain and high output impedanceC low input impedance, low gain and high output impedanceD low input impedance, high gain and low output impedance

考题 单选题The meaning of ebb tide is that ().A tide is falling from high water to low waterB tide is rising from low water to high waterC tide is reaching to a highest levelD tide is reaching to a lowest level