皮皮学,免费搜题
登录
logo - 刷刷题
搜题
【单选题】
给定按升序排列的n个不同整数存于数组a[1:n]中,请设计O(log n)的算法找到下标i,1 ≤ i ≤ n,使得a[i] = i,如不存在这样的下标,则返回0。要求写出函数实现。函数原型如下:int find(int a[],int n);正确的程序是( )
A.
int find (int [] a, int n) { int left = 1; int right = n ; int mid = ⌊ (left + right)/2 ⌋ ; while (left <= right) { if (a[mid]==mid) return mid; if (a[mid]> mid) right = mid – 1; else left = mid + 1; } return 0; }
B.
int find (int [] a, int n) { int left = 1; int right = n ; while (left < right) { int mid=⌊ (left + right)/2 ⌋ ; if (a[mid]==mid) return mid; if (a[mid]> mid) right = mid – 1; else left = mid + 1; } return 0; }
C.
int find (int [] a, int n) { int left = 1; int right = n ; while (left <= right) { if (a[mid]==mid) return mid; if (a[mid]> mid) right = mid – 1; else left = mid + 1; int mid = ⌊ (left + right)/2 ⌋ ; } return 0; }
D.
int find (int [] a, int n) { int left = 1; int right = n ; while (left <= right) { int mid=⌊ (left + right)/2 ⌋ ; if (a[mid]==mid) return mid; if (a[mid]> mid) right = mid – 1; else left = mid + 1; } return 0; }
手机使用
分享
复制链接
新浪微博
分享QQ
微信扫一扫
微信内点击右上角“…”即可分享
反馈
参考答案:
举一反三
【单选题】Each person’s genetic code is ____ except in the case of identical twins.
A.
strange
B.
unique
C.
rare
D.
odd
【判断题】A single gene mutation may predispose a person to developing cancer.
A.
正确
B.
错误
【单选题】在F11125型分度头上铣削z=80的直齿圆柱齿轮时,每次分度时分度手柄应转过( )。
A.
2r
B.
11/2r
C.
1/2r
【单选题】Listen to the talk about right and left hand. Q: What kind of gene does a person have if he/she is right- handed?
A.
A dominant gene
B.
A recessive gene
C.
Two dominant genes
D.
Two recessive genes
【单选题】Plomin's IQ-gene study is similar to the chopsticks gene finding in that ______.
A.
there may not be a causal link between gene and intelligence
B.
there is a close correlation between gene and' intelligence
C.
there may be a close relation between chopsticks flexibility and children's academic score
D.
there is not a close relation between chopsticks flexibility and children's academic score
【简答题】已知 ,并且角 是第二象限角,则角 的( __ )值为 。 (填“正弦”、“余弦”、“正切”、“余切”)
【单选题】二十四 式 太极拳右揽雀尾这个都做所运用的手法有 ?
A.
采.列.肘.靠
B.
分.云.推.搂
C.
棚.捋.挤.按
D.
分.云.推.按
【单选题】导致心浊音界扩大呈梨形的疾病是( )[1分]
A.
二尖瓣狭窄
B.
二尖瓣关闭不全
C.
主动脉瓣狭窄
D.
主动脉瓣关闭不全
E.
重症心肌炎
【判断题】Precision medicine is attempting to customize treatments on the basis of a person's gene tic's or environment.
A.
正确
B.
错误
【判断题】Precision medicine is attempting to customize treatments on the basis of a person's gene tic's or environment.
A.
正确
B.
错误
相关题目:
参考解析:
知识点:
题目纠错 0
发布
创建自己的小题库 - 刷刷题