软件学院数据结构与算法分析期末试题(2006级A)

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

四川大学期末考试试题

(2007-2008学年第1学期)

课程号:课程名称:数据结构与算法分析(A卷)任课教师:适用专业年级:06级软件工程学号:姓名:

(1)An algorithm must be or do all of the following EXCEPT:

a) correct

b) composed of concrete steps

c) ambiguous

d) composed of a finite number of steps

(2)For set P, the notation |P| indicates

a) The number of elements in P. b) The inverse of P.

c) The powerset of P. d) None of the above.

(3)Pick the quadratic growth rate.

a) 5n b) 20 log n

c) 2n^2 d) 2^n

(4)

(5)Huffman coding provides the optimal coding when:

a) The messages are in English.

b) The messages are binary numbers.

c) The frequency of occurrence for a letter is independent of its context within the message.

d) Never.

(6)A sorting algorithm is stable if it:

a) Works for all inputs.

b) Does not change the relative ordering of records with identical key values.

c) Always sorts in the same amount of time (within a constant factor) for a given input size.

(7)Here is a series of C++ statements using the list ADT in the book.

L1.append(10);

L1.append(20);

L1.append(15);

If these statements are applied to an empty list, the result will look

like:

a) < 10 20 15 >

b) < | 10 20 15 >

c) < 10 20 15 | >

d) < 15 20 10 >

e) < | 15 20 10 >

f) < 15 20 10 | >

(8)An entry-sequenced file stores records sorted by:

a) Primary key value. b) Secondary key value.

c) Order of arrival. d) Frequency of access.

(9)Breadth-first search is best implemented using:

a) A stack or recursion. b) A queue.

c) A tree.

(10)A recurrence relation is often used to model programs with

a) for loops. b) branch control like "if" statements.

c) recursive calls. d) None of the above.

2.(10 scores)

Assume a list has the following configuration:

<| 6, 28, 16, 8, 9>

Write a series of C++ statements using the List ADT as follows to delete the element with value 16.

// List abstract class

template class List {

public:

// Reinitialize the list. The client is responsible for

// reclaiming the storage used by the list elements. virtual void clear() = 0;

// Insert an element at the front of the right partition.

// Return true if successful, false if the list is full. virtual bool insert(const Elem&) = 0;

// Append an element at the end of the right partition.

// Return true if successful, false if the list is full. virtual bool append(const Elem&) = 0;

// Remove the first element of right partition. Return

// true if successful, false if right partition is empty.

// The element removed is returned in the parameter. virtual bool remove(Elem&) = 0;

// Place fence at list start, making left partition empty virtual void setStart() = 0;

// Place fence at list end, making right partition empty virtual void setEnd() = 0;

// Move fence one step left; no change if already at start virtual void prev() = 0;

// Move fence one step right; no change if already at end virtual void next() = 0;

// Return length of left partition

virtual int leftLength() const = 0;

// Return length of right partition

virtual int rightLength() const = 0;

// If pos or more elements are in the list, set the size

// of left partition to pos and return true. Otherwise,

// do nothing and return false.

virtual bool setPos(int pos) = 0;

// Return in first parameter the first element of the

// right partition. Return true if successful, false

// if the right partition is empty.

virtual bool getV alue(Elem&) const = 0;

// Print the contents of the list

相关文档
最新文档