Uploaded by muhmmadahmed794

Data Structure Theory Assigment No 2 Iqra Uni

advertisement
DATA STRUCTURES
Assignment 3 – Tree $ graph
Question 1:
Implement simple binary tree data structure with following operations, (assume data
elements)
•
•
•
•
•
InsertLeft
InsertRight
RemoveLeft
RemoveRight
Traverse (pre-order, in-order and post-order)
Question 2:
1. Develop max and min heap 35 33 42 10 14 19 27 44 26 31
2.Create an avl tree also check balancing factor on each and every node:
45, 70, 35,3,7425,81,60
Question No 3.
Apply topological sorting algorithm
Designed By: Hira Farman
Question No 4.
Consider the following graph
a. Find all the simple paths from node A to node E
b. Find indeg(D) and outdeg(D)
c. Are there any sources or sinks
d. Find the adjacency matrix for the graph
Question No 5:
HUFFMAN TREE
Given Letters A, B, C, D, E with following frequencies.
Frequency Table
Character
Frequency
Huffman Codes
M
20
10
N
11
1110
O
8
1111
P
12
110
Q
49
0
A) Create a Single Huffman tree to determine the binary codes for each character.
B) Fill the codes into the table above.
C) Encode the following sequence MNOPQ.
Videos link for understanding:
https://youtu.be/KS11-woBnRI
Designed By: Hira Farman
Download