second mid term

advertisement

Kingdom of Saudi Arabia

Ministry of Higher Education

Majmaah University

ميحرلا نمحرلا الله مسب

ةـيدوـعـسـلا ةـيـبرـعـلا ةـكلـمـمـلا

يـلاـعـلا مـيـلـعـتـلا ةرازو

ةـعـمـجـمـلا ةـعـماـج

يفلزلاب مولعلا ةيلك

College Of Sciences in Alzulfi

: ىوتسملا second exam CSI 312 : ةداملا زمرو مقر تانايبلا بيكارت : ةداملا مسا

1436 / 2 / 25 : ناحتملإا خيرات : بلاطلا مسا

Answer the following questions:

1- Assume array implementation of queue is used. Also, assume that the size of the array is 5, and that it is initially empty. show contents of the (array elements, front, rear) after all of the following operations have been completed. enqueue(39); enqueue(22); item1 = dequeue(); enqueue(59); item2 = dequeue(); item3 = dequeue();

2- Assume a binary search tree is used. Also, assume a group of numbers are inserted into that tree. Draw that BST in the following cases: a. the numbers entered in order that 20,30, 25,15,40, 60. b. Insert a node 35 in tree in (a).

1

Kingdom of Saudi Arabia

Ministry of Higher Education

Majmaah University

ميحرلا نمحرلا الله مسب

ةـيدوـعـسـلا ةـيـبرـعـلا ةـكلـمـمـلا

يـلاـعـلا مـيـلـعـتـلا ةرازو

ةـعـمـجـمـلا ةـعـماـج

يفلزلاب مولعلا ةيلك

College Of Sciences in Alzulfi

: ىوتسملا second exam CSI 312 : ةداملا زمرو مقر تانايبلا بيكارت : ةداملا مسا

1436 / 2 / 25 : ناحتملإا خيرات : بلاطلا مسا c. Delete the node with number 20 from tree in (a). d. the numbers entered in the order 15, 20, 25, 30, 40, 60.

Q3) Select the best answer:

1. The postfix equivalent of the prefix * + ab - cd is ? a. ab + cd - * b. abcd + - * c. ab + cd * - d. ab + - cd *

2. A BST is traversed in the order (left root right) the sequence will be : a. ascending b. decending c. bitomic sequence d. None of above

2

Kingdom of Saudi Arabia

Ministry of Higher Education

Majmaah University

ميحرلا نمحرلا الله مسب

ةـيدوـعـسـلا ةـيـبرـعـلا ةـكلـمـمـلا

يـلاـعـلا مـيـلـعـتـلا ةرازو

ةـعـمـجـمـلا ةـعـماـج

يفلزلاب مولعلا ةيلك

College Of Sciences in Alzulfi

: ىوتسملا second exam CSI 312 : ةداملا زمرو مقر تانايبلا بيكارت : ةداملا مسا

1436 / 2 / 25 : ناحتملإا خيرات : بلاطلا مسا

3. The complexity of linear search algorithm is a. O(n) b. O(log

2

n) c. O(n2) d. O(n log

2

n)

4. The complexity of Quicksort algorithm is a. O(n) b. O(log

2

n ) c. O(n 2 ) d. O(n log

2

n)

5. The depth of complete binary tree is given by ......

A. Dn = n log

2 n

B. Dn= n log

2 n+1

C. Dn = log

2 n

D. Dn = log

2 n+1

Q4) Write the output of postorder traversing of the following tree

3

Download