Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

COLLEGE OF ENGINEERING AND INFORMATION TECHNOLOGY EDUCATION

Name:Richmond B. Rico Data Structure and Algorithm

Year & Program: 1BSCPE1 Date: 05/04/2023

QUIZ / SEATWORK / AGREEMENT FOR FINALS PERIOD Score:

General Directions:
1. NO ERASURES. ERASURES will be considered INVALID. Erasures on the solutions are accepted.
2. Any form of CHEATING will result for failure of the exam
------------------------------------------------------------------ Exam Proper --------------------------------------------------------------------
PART I. MULTIPLE CHOICE. CHOOSE THE CORRECT d). sorting
LETTER THAT CORRESPOND TO THE PROBLEM.
B 1. Which data structure allows deleting data
elements from front and insert at rear? D 6. Popping is an act of……..
a). stacks a). adding values
b). queues b). taking off values from stack
c). dequeues c). transferring values from stack
d). binary search tree d). none them

D 2. The use of pointers to refer elements of data B 7. Stack in Data structure is using what algorithm?
structure in which elements are logically adjacent a). FIFO
is…. b). LIFO
a). stack c). LILO
b). queue d). none of these
c). pointers
d). linked list allocation. A 8.Queues in Data structure is using what
algorithm?
A 3. ________ is the term used to insert an element a). FIFO
into stack? b). LIFO
a). push c). LILO
b). pull d). none of these
c). pop
d). All of the above B 9.New nodes are added to the ________ of the
queue.
C 4. ________ is the term used to delete an element a). front
from the stack? b). back
a). push c). middle
b). pull d). both and b
c). pop
d). All of the above A 10.Deletion operation is done using ________ in a
queue.
B 5. The operation of processing each element in the a). front
list is known as…….. b). rear
a). merging c). top
b). traversal d). list
c). inserting
COLLEGE OF ENGINEERING AND INFORMATION TECHNOLOGY EDUCATION

PART II. Given the operation, perform the simulation for QUEUES. (2 POINTS EACH)
Operation in Queues Queue Contents Return Value

Initialize(Q) P9,P8,P7,P6,P5 -

ADD (P0,Q) P9,P8,P7,P6,P5, P0 -

ADD(P1,Q) P9,P8,P7,P6,P5, P0, P1 -

ADD(P2,Q) P9,P8,P7,P6,P5, P0, P1, P2 -

REMOVE(Q) P8,P7,P6,P5, P0, P1, P2 P9

ADD(P3,Q) P8,P7,P6,P5, P0, P1, P2, P3 -

IS_EMPTY(Q) FALSE -

DESTROY(Q) - P8,P7,P6,P5, P0, P1, P2, P3

IS_FULL(Q) FALSE -

ADD(P10,Q) P10 -

ADD(P11,Q) P10, P11 -


COLLEGE OF ENGINEERING AND INFORMATION TECHNOLOGY EDUCATION

PART III. A. Given the tree:

Identify the following: (1 POINT EACH)


A
1. The root of the tree - A
2. The set of nodes - 15 (A, B, C, D, E, F, G, H, I, J, K, L, M, O, P)
B C

3. The subtrees - 2
D G 4. The degree of each subtree - 2
E F
5. The degree of the tree -2
6. The set of leaf nodes or terminal nodes - L, M, F, J, O, P
7. The set of non-terminal nodes - A, B, C, D, E, G, H, I, K
J K
H I
8. The children of node “K” - O, P
9. The parent of node “I” - E

10. All siblings - BC, DE, FG, JK, OP


11. The grandparent of node “J” - C
M O P 12. The ancestor of node “O” - ACGK
L
13. The level of node “H” - 4
14. The height of the TREE - 5
15. How forest is there? If I remove Root Node “A”? - If I remove the
16. root node “A” we get a forest with three (2) trees.
B. List the nodes of the binary tree in the figure below in:
+
(3 POINTS EACH)
1. Preorder - +-A*BC-D/EF
2. Inorder - A-B*C+D-E/F
- -
3. Postorder - ABC*-DEF/-+

A * D /

B C E F
COLLEGE OF ENGINEERING AND INFORMATION TECHNOLOGY EDUCATION

C. Convert the following postfix statements into expression trees. (3 POINTS)


1. ABC+-DE-FG**
*

- *

A + F G

B C -

D E

D. Convert the following arithmetic expression into expression tree. (3 POINTS)


1. {(A+B) – (C*(D-E ))} / {((F-G)/H) – I}

- -

+ * I /
COLLEGE OF ENGINEERING AND INFORMATION TECHNOLOGY EDUCATION

You might also like