1.
a)Consider the general tree T in Figure 1. Find the corresponding binary tree T′. (6 marks)
[Figure 1: General tree T — root A with children B, F and J; B has children C, D, E; F has children G and H; J has children K, L, M and N; M has children P and Q.]
b)Traverse the above general tree T in: (i) Preorder (ii) Post-order (6 marks)
c)Give the in-order algorithm for traversing a binary tree T. (5.5 marks)
2.
a)Suppose the following sequences list the nodes of a binary tree T in preorder and in-order, respectively:
Pre-order: G, B, Q, A, C, K, F, P, D, E, R, H
In-order: Q, B, K, C, F, A, G, P, E, D, H, R
Draw the diagram of the tree. (5.5 marks)
b)Draw the binary tree corresponding to each of the following algebraic expressions:
i) (4 marks)
ii) (4 marks)
c)Give the pre-order traversal of each of the trees. (4 marks)
3.
a)Consider the graph G in Figure 2.
[Figure 2: Graph G — five nodes a, b, c, d, e joined by edges.]
i) Describe G formally in terms of its set V of nodes and its set E of edges. (2.5 marks)
ii) Find the degree of each node. (5 marks)
b)i) Give the breadth-first search algorithm for traversing a graph. (3 marks)
ii) Use the algorithm to traverse the above graph. (3 marks)
c)What is the adjacency matrix representation of the graph in Figure 2? (4 marks)
4.
a)An automobile company uses an array SIMPLE to record the number of automobiles sold each year from 1956 through 2010. What is the length of this array? (4 marks)
b)ABC + * CBA − + * is a postfix expression with the assumption A = 2, B = 3, and C = 4. If the above postfix expression is evaluated, what is the final stack value? (7 marks)
c)Show that {((({(A+B)−(C×D)})))} is a valid expression. (6.5 marks)
5.
a)Consider the following queue which can be allocated eight integers and five operations:
front = 3, rear = 5, Queue = −, −, 2, 4, 5, −, −, −
(for notational convenience "−" is used to denote an empty cell)
The following operations have to be performed:
(i)6 is added to the queue.
(ii)Two elements are deleted from the queue.
(iii)10 and 12 are added to the queue.
(iv)Two elements are deleted from the queue.
(v)2 and 3 are added to the queue.
What are the final front and rear values when the above operations are performed on a circular queue? (Show the state of the stack after each operation) (10 marks)
b)Explain any two (2) advantages of a linked list. (2 marks)
c)With the aid of diagrams, differentiate between a Linked List and a Stack. (5.5 marks)
6.
a)Convert the expression (A + B) * C + D / (E + F * G) − H + (I ^ (J * K)) from infix to postfix. (10 marks)
b)I have implemented a queue with a linked list, keeping track of a front pointer and a rear pointer. Use an example to show that both pointers will change during insertion into the EMPTY queue. (4 marks)
c)Write an algorithm for inserting a node between two nodes in a singly linked list. (3.5 marks)

