100% found this document useful (1 vote)
323 views7 pages

Assignment 3 TREE and GRAPH Data Structure 10% Instruction:: CCS20503/DCS20303/TCS21203 Assignment 3

This document contains an assignment on tree and graph data structures. It includes 6 questions - the first two questions define and differentiate between binary trees and binary search trees. The third question asks students to draw binary search trees for two data sets. The fourth question asks students to draw expression trees for three arithmetic expressions. The fifth question briefly defines graph data structures. The sixth and final question provides a directed graph and asks students to perform depth-first search, breadth-first search, draw the adjacency list representation, and construct the adjacency matrix for the given graph.

Uploaded by

Zhen Wei
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
323 views7 pages

Assignment 3 TREE and GRAPH Data Structure 10% Instruction:: CCS20503/DCS20303/TCS21203 Assignment 3

This document contains an assignment on tree and graph data structures. It includes 6 questions - the first two questions define and differentiate between binary trees and binary search trees. The third question asks students to draw binary search trees for two data sets. The fourth question asks students to draw expression trees for three arithmetic expressions. The fifth question briefly defines graph data structures. The sixth and final question provides a directed graph and asks students to perform depth-first search, breadth-first search, draw the adjacency list representation, and construct the adjacency matrix for the given graph.

Uploaded by

Zhen Wei
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

CCS20503/DCS20303/TCS21203 Assignment 3

ASSIGNMENT 3
TREE and GRAPH Data Structure
10%

Instruction:
Answer All Questions

Question 1 (2 marks)
In your own word, briefly explain about Binary Tree.

Binary tree is a special type of tree made up of multiple nodes used in computer data
structure which every node has either no child, one or two child nodes.

A binary tree typically consists of root, nodes and leaves as its main components.
In addition to that, a binary tree can be described by the depth and height. The
measurement is based on the number of edges from the root to the node and the number
of edges from the node to the deepest leaf respectively.

Question 2 (2 marks)
How do you differentiate between Binary Tree and Binary Search Tee?

In a binary tree, each node is limited to maximum of two child nodes and there is no definite
order or sequence in terms of how the nodes are organized in the binary tree. However,
search tree is essentially the same as binary tree as in how many child nodes a node can
hold. The difference lays on how the available nodes are organized with relative order or
sequence.

1
CCS20503/DCS20303/TCS21203 Assignment 3

Question 3 (10 marks)


Draw Binary Search Tree for the following sets of data:

1. F, A, X, C, S, E, R, H, M, B

A X

C S

B E R

2. 8, 12, 5, 6, 3, 12, 7, 16, 2, 20

5 12

3 8 16

2 7 20

2
CCS20503/DCS20303/TCS21203 Assignment 3

Question 4 (15 marks)


Draw the expression tree for the following arithmetic expression:

1. ((2+8)*8)-(5*(5+2)

* *

8 + + 5

2 8 5 2

2. a/b*(c+d-e)

/ -

a b + e

c d

3
CCS20503/DCS20303/TCS21203 Assignment 3

3. (a + b) / c + 2 * d

/ *

+ c 2 d

c b

Question 5 (2 marks)
Briefly explain about graph data structure.

A graph data structure is a type of non-linear and consisting component such as nodes and
edges in order to construct the graph data structure. Each component plays an important
role, nodes act as vertices of data and edges are the lines connecting two nodes within the
graph. An adjacency represents two nodes that is positioned adjacent to each other and is
connected through a line of edge.

4
CCS20503/DCS20303/TCS21203 Assignment 3

Question 6 (40 marks)


Given the following directed graph:

1. Show the result of the depth-first search traversal starting from vertex 1 and the vertex
is visited in ascending order. Use appropriate diagram to show how you get the result
for the traversal.

5
CCS20503/DCS20303/TCS21203 Assignment 3

2. Show the result of the breadth -first search traversal starting from vertex 1 and the
vertex is visited in ascending order. Use appropriate diagram to show how you get the
result for the traversal.

3. Draw the adjacency list representation of the graph. Assume that the first vertex
inserted into the graph is 1, and in numerical order.

6
CCS20503/DCS20303/TCS21203 Assignment 3

4. Construct the adjacency matrix for the graph. Assume that the first vertex inserted into
the graph is 1, and in numerical order.

Punctuality - (9 marks)

Student Name : IDHAM IZZUDIN BIN SHAMSUL BAHRI


Student ID : 012019070072
Program : Bachelor in Computer Science

~~~~~~~~~~~~~ GOOD LUCK ~~~~~~~~~~~~

You might also like