数据结构例题
数据结构例题
3.( )The worst-time for removing an element from a sequence list (Big-Oh) is .
a. O(1) b. O(n) c. O(n2) d. O(n3)
4.( )In a circular queue we can distinguish(区分) empty queues from full queues by .
a. using a gap in the array
b. incrementing queue positions by 2 instead of 1
c.keeping a count of the number of elements
d. a and c
5. ( )A recursive function can cause an infinite sequence of function calls if .
a. the problem size is halved at each step
b. the termination condition is missing
c. no useful incremental computation is done in each step
d. the problem size is positive
Fig. 1
11. Here is an array of ten integers:
5389170264
Suppose we partition this array using quicksort's partition function and using 5 for the pivot.
Which shows the array after partition finishes:
a. 5 3 4 2 1 0 7 9 6 8
b. 0 3 4 2 1 5 7 9 6 8
c. 3 1 0 2 4 5 8 9 6 7
d. 3 1 0 2 4 5 8 9 7 6
e. None of the above
1.Graph G shown in Fig 2 is a directed graph, please describe G with adjacency matrix and write
the orders of breadth first traversal and depth first traversal.
B C
A E
Fig.2
3. Show the results of inserting 53,17,78,09,45,65,87 each , one at a time, in a initially empty max
heap(大根堆)
4. write the sequence of preorder,postorder traversals and add inorder threads in the tree.
A
B C
D E F
Fig. 3
5. Build a Huffman tree and determine Huffman code when the probability distribution( 概率分布)
over the 8 alphabets ( c1, c2, c3, c4, c5, c6, c7, c8 ) is (0.05, 0.25, 0.03, 0.06, 0.10, 0.11, 0.36, 0.04
6. Graph G shown in Fig 4 is a directed graph, please describe G with adjacency list and write
topological ordering.
Fig. 4
if ( ) return 1;
else return 0;
V Programming (30)
1. Write efficient functions (and give their Big-Oh running times)that take a pointer to a binary
tree root T and compute:
– The number of leaves of T
typedef struct BiTNode
{ TElemType data;
struct BiTNode *lchild,*rchild;
} BiTNode , *BiTree;
3. Write a function with linked list that inserts a number into a sorted linked list.
Firstly, you should write a function creates a list that like this:
L={3,5,8,12,32,48}
and then insert 25 into this list.