2012--数据结构英文试卷A及答案

2026/4/30 2:54:48

北 京 交 通 大 学 软 件 学 院

2012―2013学年第一学期期末考试试题

Data Structure and Algorithm Design(A)

Class: ____Student Number: _____Name: ________ Teacher________ No. Mark I II III IV V VI Total I. Single-Choice(20 points)

1. The height of a binary tree that contains 1023 elements is at most ( 1 ) and at least ( 2 ).

A. 1022 B.1023 C. 1024 D.9 E.10 F.11

2. If the sequence of pushing elements into a stack is a,b,c, which output sequence is impossible?( ).

A.abc B.bca C.cba D.cab

3.How many minimum-cost spanning trees are there for an undirected connected graph with n vertices and e edges? ( ) A. must be only one B. n-1 C. n-e D. not sure

4. When using the adjacency matrix A to represent a undirected graph with n nodes and e edges, the degree of the node vi can be computed by formula ( ).

A.

B.

/2 C. e /2 D.

5. In the worst case, time complexity of quicksort will be degraded to ( ).

A.O(n) B.O(n2) C.O(nlogn)

6.In order to find a specific key in an ordered list with 100 keys using binary search

algorithm, the maximum times of comparisons is ( ). A. 25 B.10 C. 1 D.7

7. Consider the following pseudo-code, which indicates part of a standard binary tree algorithm. print( node )

{ print data;

if( there is a left child ) print( left child ); if( there is a right child ) print( right child ); }

Which of the following is the standard name for this algorithm? ( ) A. Inorder traversal B. Preorder traversal C. Postorder traversal D. Binary search

8.Which is not the property of a B-tree of order m? ( )

A. The root node has m subtree at most B. All leaf nodes are at the same level.

C. The keys in every node are ordered. D. All leaf nodes are connected by links.

9. Suppose that we have 1000 distinct integers, which are in the range from 0 to 50. If using Radix Sort according to the Least Significant Digit first, ( ) buckets are needed to constructed.

A. 10 B. 50 C. 51 D. 1000

Answer table for Question I (write your answers of Question I here) 1(1) B 1(2) E 2 D 3 D 4 A 5 B 6 D 7 B 8 D 9 A

II. Fill in the blank (2points * 5)

Answer table for II (Please write your answers of II here) 1 preorder 2 11 2 2,3,⑤,5 3 i*n+j 4 5,4,3,2,1 1. The strategy of depth-first searching algorithm for a graph is similar to that of___ _ traversal algorithm for a normal tree. 2. Here is a hash table, whose size is 18, hashing function is

H1(key)=key (% here is the modulus operator), and which uses Linear Probing strategy to cope with the collisions and inserts 26, 25, 72,

38, 8, 18, 59 into the hash table in turn. The address of 59 is _ _ _. 3. Given a key sequence {2,5,⑤,3}, please write its ascending ordered sequence after being sorted using heap sort. (Note 5=⑤, just 5 is before ⑤ in original sequence) . Please distinguish 5 and ⑤. 4. If a 2-dimensions matrix A[m][n] is stored in an 1-D array with row-major mapping, then the address of element A[i][j] relative to A[0][0] is ___ ____ 5. If the in-order and pre-order series of the nodes in a binary tree are “1,2,3,4,5” and “1,2,3,4,5” respectively, the postorder sequence should be __________.

III. (40 points)

1. (8 points) Suppose there is a string abcadececdcdeeeded that comprises the characters a, b, c, d and e. We may encode the symbols using variable-length codes in order to make the length of string the shortest. Please draw the Huffman tree used to encode the characters, calculate the weighted path length for the Huffman tree and write the code for each character.

(1) Draw the Huffman tree (3 points)

a:2, b:1, c:4, d:5 , e: 6

(3 points)

(2) Calculate the weighted path length for the Huffman tree (2 points) WPL(T)= 6?2+5?2+2?3+1?3+4?2 =39

(3) write the code for each character. (3 points) 错一个扣一分,扣光为止

a 100 b 101 c 11 d 01 e 00 2. (8 points) Please respectively give two unsorted lists whose length are 4 to illustrate that quick sort and selection sort are unstable.

(1) An example list for quick sort and the sorting procedure using quick

sort. (4 points)

(4, 2, ②, 3)-------------------------- (2 points) sorting procedure

The first pass: 3,2, ②,4 -------------------------(1point) The second pass: ②,2,3,4 -----------------------(1point)

(2) An example list for selection sort and the sorting procedure using

selection sort. (4 points)

(2,②,3,1)-------------------------- (1 points) sorting procedure

The first pass: 1, ②, 3 , 2 ------------------------(1point) The second pass: 1, ②, 3 , 2 ----------------------(1point) The third pass: 1, ②, 2, 3 ----------------------(1point)

3. (8 points) Given the key sequence (331, 166, 367, 236, 268, 137, 337, 138), Please give the procedure (distributing and collecting) of sorting using radix sort method. not necessary to write queue front and rear pointer if queue is null. (1) The first pass (3 points)

(2) The second pass (3 points)


2012--数据结构英文试卷A及答案.doc 将本文的Word文档下载到电脑
搜索更多关于: 2012--数据结构英文试卷A及答案 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219