


版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領
文檔簡介
1、華師大數(shù)據(jù)結構期中考試試卷(含答案)華東師范大學期中試卷20072008學年第二學期課程名稱:_數(shù)據(jù)結構_ 姓 名:_ 學 號:_專 業(yè):_ 年級/班級:_課程性質:專業(yè)必修一二三四五六七八總分閱卷人簽名一、 單項選擇題(共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 outb) first in and last outc) first in and
2、 first out2. 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) list3. 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; q
3、uiz(n - 1); cout << 1; quiz(n - 1); a)00011011 b) c) d)01100011 e)0011014. 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)
4、2ib) 2i-1c) 2i-2d) 2i+15. given the recursive function int func( /* in */ int i, /* in */ int j ) if (i < 11) if (j < 11) return i + j; else return j + func(i, j - 2); else return i + func(i - 1, j); what is the value of the expression func(12, 15) a)81 b)62 c)19 d)72 e)none of the above6. she
5、ll sort finally perform an ordinary ( )a) heap sortb) insertion sortc) selection sortd) quick sort二、 填空題(共22分,每空2分)1. if the following function is called with a value of 75 for n, the resulting output is _【1】_. void func( /* in */ int n ) if (n > 0) func(n / 8); cout << n % 8; 2. give the o
6、utput of the following program. _【2】_.template <class list_entry>void print(list_entry &x)cout<<x<<" "void main( )list<int> mylist;for(int i=0;i<5;i+)(i,i);cout<<"your list have "<<()<<" elements:"<<endl;(0,i);(2,i)
7、;(i,i);(print);( );for(i=1;i<3;i+)(i, i);(print);3. read the following program and fill the blank to complete the method.template <class node_entry>struct node post: the current node pointer references the node at position . */if (current_position <= position)for ( ; current_position !=
8、position; current_position+) 【3】 ;elsefor ( ; current_position != position; 【4】 )current = current->back;4. read the following program and fill the blank to complete the method.error_code recursive_binary_2(const ordered_list &the_list, const key &target, int bottom, int top, int &pos
9、ition)/* pre: the indices bottom to top define the range in the list to search for the target .post: if a record in the range from bottom to top in the list has key equal to target , then position locates one such entry, and a code of success is returned. otherwise, not_present is returned, and posi
10、tion is undefined.uses: recursive_binary_2, together with methods from the classes ordered_list and record . */record data;if (bottom <= top) int mid = 【5】 ; (mid, data);if (data = target) 【6】 ;return success;else if (data < target)return recursive_binary_2(the_list, target, 【7】 , top, positio
11、n);elsereturn 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. node<record> * divide_from (node<record> *sub_list)/* post: the list of n
12、odes 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 second.*/node<record> *position, position = midpoint
13、->next;while (【9】 ) position = position->next;if (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
14、 first key in the sublist and (b) the last key in the sublist. in each case, draw the tree of recursive call.tim dot eva roy tom kim guy amy jon ann jim kay ron jan2. (16分)write the following overload operator for stacks:1) bool stack:operator = (const stack & s);2) bool stack:operator += (const
15、 stack & s);using recursion, implement the following functions:int max (node *f ); int num (node *f );if success returns the 數(shù)據(jù)結構期中考卷參考答案9一、 單項選擇題(3×618)1 c2 a3 e4 d5 a6 b二、 填空題(2×1122)【1】113【2】your list have 5 elements:1 2 4 3【3】current = current->next【4】current_position-【5】(bottom
16、 + top)/2【6】position = mid【7】mid + 1【8】mid 1【9】position != null【10】midpoint = midpoint->next;【11】midpoint->next三、 編程題(16×2101860)1,a) p344 b)2. 1) bool stack:operator=(const stack &s)stack s1=s, s2=*this;while (!( )if ( )!= ( ) return false;else ( ); ( );2) bool stack: operator+=(cons
17、t stack &s)stack ss=s, s2;while (!( )( );( );while (!( )if(push( ) = outcome) return false;( );3template <class t> void reverse (queue<t> & q)stack<t> s t data;while ( !( ) (data ); ( data); ( );while (!( )( );( );4. int max (node *f ) if ( f ->next = null ) return f ->entry;int temp = max ( f ->ne
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
- 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
- 6. 下載文件中如有侵權或不適當內容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 手術室感染管理制度及職責
- 婦產科門診護士崗位職責
- 2025小學數(shù)學教材使用教學計劃
- 教育管理干部教師培訓心得體會
- 信息技術教研組實訓基地建設計劃
- 醫(yī)院檢驗科實驗室安全管理制度和流程
- 學校食堂員工崗位職責一覽
- 學校食堂安全檢查三防措施
- 邊坡錨索施工專項進度計劃
- 學校社團活動統(tǒng)計業(yè)務工作流程
- 支架植入知情同意書模板
- 茶文化講座優(yōu)選ppt資料
- 綠化工程施工技術方案及措施(可編輯)
- 會計知識競賽題庫附答案2021
- 廠房鋼筋混凝土地坪板工程施工方案
- 項目延期申請表(樣本)
- AS9100D體系標準中文版
- 固井工藝技術培訓教學課件(77p)
- 入團志愿書(2016版本)(可編輯打印標準A4) (1)
- 《復分解反應》教學設計
- 盤扣式腳手架模板與支撐架專項施工方案
評論
0/150
提交評論