1. Bubble Sort the list: 33, 56, 17, 8, 95, 22。 Make sure the final result is from small to large. Write out the list after the 2nd pass.
2. Give a sorted array as list={60,65,75,80,90,95}. Design an algorithm to insert the value of x into the sorted array. Then test the algorithm with value 50,67,99. 思考: 为什么选择插入点在list头上、 中间、 尾巴上的三个数作为 算法测试的数据, 你能解释吗?
3. What is the state of the stack after the following sequence of Push and Pop operations? Push “anne”; Push “get”; Push “your” ; Pop; Push “my” Push “gun”
1.
1) . 33,56,17,8,95,22
2) 33,17,56,8,95,22
3) 33,17,8,56,95,22
4) 17,33,8,56,95,22
5) 17,8,33,56,95,22
6) 8,17,33,56,95,22
7) 8,17,33,56,22,95
8) 8,17,33,22,56,95
9) 8,17,22,33,56,95
So 33,17,8,56,95,22
2. 输入插入数据A
for (i = 0; i < 6; ++i) {
if ( a[i] < A < a[i + 1])
链表 a[i] < A < a[i + 1]
else if (A < a[0])
链表 A < a[0]
else
链表 A > a[5]
}
恰好对应链表的三种情况
3. Gun
My
Get
anne