


版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進行舉報或認領
文檔簡介
1、華師大數(shù)據(jù)結(jié)構(gòu)期中考試試卷(含答案)華東師范大學期中試卷20072008學年第二學期課程名稱:_數(shù)據(jù)結(jié)構(gòu)_ 姓 名:_ 學 號:_專 業(yè):_ 年級/班級:_課程性質(zhì):專業(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ù)結(jié)構(gòu)期中考卷參考答案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)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
- 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025初三升高一數(shù)學暑假銜接講義25講含答案(必修一內(nèi)容)5.6 三角函數(shù)倍角公式
- 統(tǒng)編版2025年七年級語文下學期期末總復習(專題訓練)專題04文言文閱讀(考題猜想)(學生版+解析)
- 愛崗敬業(yè)14課件
- 考研復習-風景園林基礎考研試題【奪冠】附答案詳解
- 風景園林基礎考研資料試題及參考答案詳解【綜合題】
- 《風景園林招投標與概預算》試題A附參考答案詳解(考試直接用)
- 2025-2026年高校教師資格證之《高等教育法規(guī)》通關題庫含答案詳解(考試直接用)
- 泰州市2024-2025學年三年級下學期數(shù)學期末試題一(有答案)
- 2023國家能源投資集團有限責任公司第一批社會招聘筆試備考題庫含答案詳解ab卷
- 2025年河北省定州市輔警招聘考試試題題庫及參考答案詳解一套
- 湖南省懷化市鶴城區(qū)2023年數(shù)學三下期末監(jiān)測試題含解析
- 授權(quán):如何激發(fā)全員領導力
- 禽病防治-禽流感(動物傳染病防治技術(shù))
- 兒童少年生長發(fā)育與體育運動
- 交通協(xié)管員外包服務方案
- 外科學研究進展智慧樹知到答案章節(jié)測試2023年浙江中醫(yī)藥大學
- 醫(yī)院護士落實VTE預防措施不規(guī)范原因分析品管圈魚骨圖
- 循跡避障小車答辯
- 《保障農(nóng)民工工資支付條例》考試試題和答案
- 華南理工大學自主招生考試綜合素質(zhì)測試面試試題答題技巧匯總
- 山東財經(jīng)大學《微觀經(jīng)濟學》課程期末重點考試內(nèi)容
評論
0/150
提交評論