You are on page 1of 6

Activity No.

6
Trees
Course Code BCS 120 Program:
Course Title Fundamentals of Programming Date Performed:
and Data Structures
Section: Date Submitted:
Name: Instructor:
1. Objective:
The goal of this laboratory activity is to understand and apply the concepts in tree
structures. The student must be able to both create a tree and navigate through it.
2. Intended Learning Outcomes (ILOs):
After completion of this activity the students should be able to:
2.1 Write a short program to create a tree and search for specific elements in
it
2.2 Execute programs to navigate the tree in prefix, post-fix, and in-order
2.3 Examine the navigation techniques and their differences
3. Resources:
Computer with 32-bit Operating System
Dev C++

4. Procedure:

Programming Exercise A
Create a program that first allows the user to select an order to read and compute
for an expression in a specific notation. Program must be limited to 5 values and
4 operations.

Ex.
Enter a notation: PREFIX
Enter the expression: 52 2 + 48 2 + -
Answer: 4

Programming Exercise B
Create a program that would construct the tree below and print out all paths that
would lead to the root. (Only the creation of the tree can be hard-coded)
Programming Exercise C
Given the same tree in exercise 2, print out the elements in each level. (The root
shall be referred to as Level 1)

Programming Exercise D
Given the same tree in exercise 2, print out all nodes that do not have siblings.

5. DATA ANALYSIS:
1. Where is the concept of treex usually applied?

2. Solve for the following:


Infix Expression: ( AX + ( B * C ) )
Postfix Expression:
Prefix Expression:

Infix Expression:
Postfix Expression: AX B CY * + D E - /
Prefix Expression:

Infix Expression:
Postfix Expression:
Prefix Expression: * + A B + C E

Infix Expression: ( AX * ( BX * ( ( ( CY + AY ) + BY ) * CX ) ) )
Postfix Expression:
Prefix Expression:

Infix Expression:
Postfix Expression: H A B C + D * + F * G * E * * J +
Prefix Expression:

3. What would happen if you delete the root of a tree? What would happen to its
children and leaves?
7. DISCUSSION
8. CONCLUSION
9. Assessment (Rubric for Laboratory Performance):

You might also like