聚合答案库

免费查题,不限次数,
扫描二维码立即使用。

了解更多
免费 数据结构(山东建筑大学) 最新智慧树知到答案-公众号-聚合答案库
作者:2023-03-04 00:00 点赞 收藏 热度:12

1、单选题:
方法f1的时间复杂度是( )public int f1(int n) {int x = 0;while (n >= (x + 1) * (x + 1)) {x = x + 1;}return x;}
选项:
A:O(n1/2)
B:O(n2)
C:O(logn)
D:O(n)
答案: 【O(n1/2)

2、单选题:
方法f2的时间复杂度是( )public int f2(int n) {int i = 0;int sum = 0;while (sum < n) {sum += ++i;}return i;}
选项:
A:O(logn)
B:O(n)
C:O(n1/2)
D:O(nlogn)
答案: 【O(n1/2)

3、单选题:
方法f3的时间复杂度是( )public int f3(int n) {int x = 2;while (x < n / 2) {x = 2 * x;}return x;}
选项:
A:O(nlogn)
B:O(n2)
C:O(logn)
D:O(n)
答案: 【O(logn)

4、单选题:
方法f4的时间复杂度是( )public int f4(int n) {int count = 0;for (int k = 1; k <= n; k *= 2) {for (int j = 1; j <= n; j++) {count++;}}return count;}
选项:
A:O(n)
B:O(n2)
C:O(logn)
D:O(nlogn)
答案: 【O(nlogn)

5、单选题:
记问题的规模n=a.length,方法f5的时间复杂度是( )public void f5(int[] a, int x) {int j = a.length;for (int i = 0; i < a.length; i++) {if (x > a[i]) {j = i;break;}}for (int i = a.length; i > j; i--) {a[i] = a[i - 1];}a[j] = x;}
选项:
A:O(logn)
B:O(n)
C:O(n2)
D:O(nlogn)
答案: 【O(n)

欢迎您对本文章进行评论
文明留言,请勿恶意评论,包括但不限于纯数字、敏感内容、非法昵称等
暂无讨论,说说你的看法吧
学习通答案

学习通答案

学习通答案
职教云答案

职教云答案

Q&A

备案号:冀ICP备20010840号 2020-2099辉辉网络科技 All Rights Reserved