华师大数据结构期中考试试卷(含)(最新版)新修订

上传人:l****6 文档编号:148780393 上传时间:2020-10-22 格式:PDF 页数:10 大小:105.82KB
返回 下载 相关 举报
华师大数据结构期中考试试卷(含)(最新版)新修订_第1页
第1页 / 共10页
亲,该文档总共10页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述

《华师大数据结构期中考试试卷(含)(最新版)新修订》由会员分享,可在线阅读,更多相关《华师大数据结构期中考试试卷(含)(最新版)新修订(10页珍藏版)》请在金锄头文库上搜索。

1、华东师范大学期中试卷 20072008 学年第二学期 课程名称:_数据结构_ 姓 名:_ 学 号:_ 专 业:_ 年级/班级:_ 课程性质:专业必修 一二三四五六七八总分阅卷人签名 一、一、单项选择题(共 18 分,每题 3 分) 1. Stack has the property called last in and first out, then which of the following describes the property of Queue? a) Last in and first out b) First in and last out c) First in and f

2、irst out 2. A list of items from which only the item most recently added can be removed is known as a ( ) a) stack b) queue c) circular linked list d) list 3. If the following function is called with a value of 2 for n, what is the resulting output? void Quiz( int n ) if (n 0) cout 0; Quiz(n - 1); c

3、out 1; Quiz(n - 1); a)00011011 b)11100100 c)10011100 d)01100011 e)001101 4. A heap is a list in which each entry contains a key, and, for all positions i in the list, the key at position i is at lease as large as the keys in positions 2i+2 and ( ), provided these positions exist in the list. a) 2i b

4、) 2i-1 c) 2i-2 d) 2i+1 5. Given the recursive function int Func( /* in */ int i, /* in */ int j ) if (i 11) if (j 0) Func(n / 8); cout n % 8; 2. Give the output of the following program. _【2】_. template void print(List_entry void main( ) List mylist; for(int i=0;i5;i+)mylist.insert(i,i); coutYour li

5、st have mylist.size() elements:endl; mylist.remove(0,i); mylist.remove(2,i); mylist.insert(i,i); mylist.traverse(print); mylist.clear( ); for(i=1;i3;i+)mylist.insert(i, i); mylist.traverse(print); 3. Read the following program and fill the blank to complete the method. template struct Node / data me

6、mbers Node_entry entry; Node *next; Node *back; / constructors Node( ); Node(Node_entry item, Node *link_back = NULL, Node *link_next = NULL); ; template void List : set_position(int position) const /* Pre: position is a valid position in the List : 0 =position count . Post: The current Node pointer

7、 references the Node at position . */ if (current_position back; 4. Read the following program and fill the blank to complete the method. Error_code recursive_binary_2(const Ordered_list if (bottom = top) int mid = 【5】 ; the_list.retrieve (mid, data); if (data = target) 【6】 ; return success; else if

8、 (data target) return recursive_binary_2(the_list, target, 【 7】 , top, position); else return recursive_binary_2(the_list, target, bottom, 【 8】 , position); else return not_present; 5. The following program is the divide_from function of Merge Sort. Please fill the blank to complete the function. No

9、de * divide_from (Node *sub_list) /* Post: The list of nodes referenced by sub_list has been reduced to its first half, and a pointer to the first node in the second half of the sublist is returned. If the sublist has an odd number of entries, then its first half will be one entry larger than its se

10、cond.*/ Node *position, / traverses the entire list *midpoint, / moves at half speed of position to midpoint *second_half; if (midpoint = sub_list) = NULL) return NULL; / List is empty. position = midpoint-next; while (【9】 ) / Move position twice for midpoints one move. position = position-next; if

11、(position != NULL) 【10】 ; position = position-next; second_half = 【11】 ; midpoint-next = NULL; return second_half; 三、三、编程题(共 60 分) 1. (16 分) Apply quicksort to the following list of 14 names, where the pivot in each sublist is chosen to be (a) the first key in the sublist and (b) the last key in the

12、 sublist. In each case, draw the tree of recursive call. Tim Dot Eva Roy Tom Kim Guy Amy Jon Ann Jim Kay Ron Jan 2. (16 分) Write the following overload operator for stacks: 1) bool Stack:operator = (const Stack 2) bool Stack:operator += (const Stack / pushes the contents of the given stack onto this

13、 stack; 3. (10 分) Write the following function temple: Template void reverse(Queue / reverses the contents of the given queue; 4. (18 分) struct Node / data members int entry; Node *next; / constructors Node( ); Node(int item, Node *link = NULL); ; f is the head pointer of a link list of nodes. Using

14、 recursion, implement the following functions: 1) int Max (Node *f ); /return the max value in the link list. 2) int Num (Node *f ); /return the number of the nodes in the link list 3) Node * Search ( Node *f, int x ); /Search the first occurrence of the x in the link list. If success returns the /p

15、ointer to the node, else returns NULL. 数据结构期中考卷参考答案 一、单项选择题(3618) 1 c 2 a 3 e 4 d 5 a 6 b 二、填空题(21122) 【1】113 【 2】 Your list have 5 elements: 1 2 4 3 【3】current = current-next 【4】current_position- 【5】(bottom + top)/2 【6】position = mid 【7】mid + 1 【8】mid 1 【9】position != NULL 【10】midpoint = midpoint- next; 【11】midpoint-next 三、编程题(162101860) 1,a) P344 F8.12 b) 2. 1) bool Stack:operator=(const Stack while (!s1.empty( ) if (s1.top( )!= s2.top( ) return false; else s1.pop( );

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 中学教育 > 教学课件 > 高中课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号