Recent Question/Assignment

Question 1:
Input file: input-qla2.txt
Output file: output-q1-a2.txt
You are required to create an AVL tree by inserting numbers. Numbers that need to be inserted are given in the input file. After each insertion, write the contents of the tree in the output file using breadth-first traversal. Print the level and then the values at that level (root is at level 0). In the input file first line contains the number of data elements. The second line contains all the data elements separated by space.
Sample input file:
8
23 12 58 10 21 11 17
Interpretation: Line 1 says that there are 8 numbers to be inserted in the tree. Line 2 has the 8 numbers separated by space.
Output file:
0: 12
1: 8 21
2: 5 10 17 23
3: 11
Question 2:
Input file: input-q2a2.txt
Output file: output-q2-a2.txt
You are required to create a binary max heap by inserting numbers (you may use arrays or dynamic data structure). Numbers that need to be inserted are given in the input file. After each insertion, write the contents of the heap, before and after the heap operation in the output file. In the input file, first line contains the number of data elements. The second line contains all the data elements separated by space.
Sample input file:
8
23 12 58 10 21 11 17
Interpretation: Line 1 says that there are 8 numbers to be inserted in the heap. Line 2 has all the 8 numbers separated by space.
Output file: (if doing breadth-first traversal or in case of an array, simple contents)
23
23
23 12
23 12
23 12 5
23 12 5
23 12 5 8
23 12 5 8
23 12 5 8 10
23 12 5 8 10
23 12 5 8 10 21
23 21 5 12 10 8

Looking for answers ?


Recent Questions