Dept. of Computer Science and Information Engineering, National Dong Hwa University Data Structures - Middle Exam, Nov. 8, 2010 1.
(A band matrix a is an n-by-n array in which a[i][j]==0, if |i-j|≧k , where k is a positive integer constant and 1 ≦ k ≦ n-1 . a. b.
(05%) What is the maximum number of nonzero elements in such a matrix? Write your answer in terms of n and k. (15%) Suppose that these elements (nonzero elements) of the matrix is stored in a one-dimensional array b with the row-major way sequentially. Develop an algorithm for mapping a[i][j] to array b, where |i-j|<k=2. Note that the first element of array a is a, which is stored in b. That is a=b, a=b, and ….
(10%)Transform the prefix expression * + A / B C + D * / - E F G H to infix and postfix expressions. Draw its expression tree.
(10%)Assume that A = 2, B = 4, C = 5 and D = 3. Compute the postfix expression AB*C+ADC-*+ with the help of a stack. Please explain your algorithm and illustrate it with the example (Do not write a program.).
(05%) (a) In a circular queue with array implementation, where do the pointers front and rear point to? (05%) (b) In a circular queue with array implementation, what are the conditions of an empty queue and a full queue?
(10%) Convert the following polynomial into the generalized list which its node type like vble/*down/coef
((x10 + 2x8) y + 3x8y2) z2 + ((x4 + 6x3) y4 +2y ) z 6.
Given the doubly linked list node structure following LLink
LLink: pointer to previous node, RLink: pointer to next node. a. (07%)Please draw a diagram to show the actions of insertion and deletion. b. c.
(08%)Please write a code segment to implemaent insertion and deletion. (10%) Write a C/C++ function to compute the minimum of all elements of a doubly linked list of integers.
Suppose that we are given the post-order sequence ＤＢＧＥＨＪＦＣＡ and the in-order sequence ＤＢＡＥＧＣＨＦＪof the same binary tree. a. b.
(07%) Draw a binary tree defined by such a pair of sequence. (08%) What is the pre-order of this tree ?