算法与数据结构Java工程师单选难度 3真题改编 · 2023
3259. 若栈 S1 中保存整数,栈 S2 中保存运算符,函数 F()依次执行下述各步操作:
(1)从 S1 中依次弹出两个操作数 a 和 b;
(2)从 S2 中弹出一个运算符 op;
(3)执行相应的运算 b op a;
(4)将运算结果压人 S1 中。
假定 S1 中的操作数依次是 3, 9, 3, 2(2 在栈顶),S2 中的运算符依次是*, - , +(+在栈顶)。调 用 3 次 F()后,S1 栈顶保存的值是?
练习本题 ›
操作系统单选难度 3真题改编 · 2024
3262. 假设操作系统中有5个作业,它们的到达时刻分别是0,2,4,6,8,运行时间分别是2,3,1,4,2,系统在t=2时开始作业调度,如果采用优先级调度算法,其中作业的优先级按到达时刻从小到大依次递增,那么在t=2时,选中的作业是()。
练习本题 ›
编程语言单选难度 3真题改编 · 2024
3263. 下面 C++ 程序的运行结果为()
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {
return a.second < b.second;
}
int main() {
std::vector<std::pair<int, int>> v_p;
v_p.emplace_back(1, 2);
v_p.emplace_back(2, 1);
v_p.emplace_back(3, 4);
v_p.emplace_back(4, 3);
sort(v_p.begin(), v_p.end(), cmp);
for (auto t : v_p)
{
std::cout << t.first << " " << t.second << std::endl;
}
return 0;
}
练习本题 ›
编程语言单选难度 3真题改编 · 2024
3279. 实现一个函数,将两个有序整数数组合并为一个有序数组,并返回新的数组 public class MergeArrays {
public static int[] merge(int[] arr1, int[] arr2) {
int[] result = new int[arr1.length + arr2.length];
int i = 0, j = 0, k = 0;
while (i < arr1.length && j < arr2.length) {
if (____) { // 填空
result[k++] = arr1[i++];
} else {
result[k++] = arr2[j++];
}
}
while (i < arr1.length) {
result[k++] = arr1[i++];
}
while (j < arr2.length) {
result[k++] = arr2[j++];
}
return result;
}
public static void main(String[] args) {
int[] arr1 = {1, 3, 5};
int[] arr2 = {2, 4, 6};
int[] merged = merge(arr1, arr2);
System.out.println(Arrays.toString(merged));
}
}
填空内容是:
练习本题 ›
算法与数据结构单选难度 3真题改编 · 2023
3289. 一组记录的关键码为(21,88,19,45,13,25,66,33,18),则利用快速排序的方法,以第一个记录为基准,从小到大排序得到的一次划分结果为()
练习本题 ›