PCA2 (40 Marks) Code 30 Marks Viva 10 Marks
PCA2 (40 Marks) Code 30 Marks Viva 10 Marks
PCA2 (40 Marks) Code 30 Marks Viva 10 Marks
Code = 30 marks
Viva = 10 marks
1> Write the code for a program that makes a doubly linked list with 9 random numbers
between 10 and 99, print it and then go to the 5th node. Write the code to do a random
traversal i.e. generate -1 or +1 randomly and if it is -1 go 1 place left else for +1 go 1
place right. Stop printing the sequence once any end is reached.
2> Write the code to generate a 20 node binary search tree with randomly generated
sequence containing numbers between 10 and 99. Print the inorder and pre order
traversal, along with the height of the tree thus generated.
3> Write the code for inserting into an AVL tree with 20 nodes with random numbers
from 10 to 99. After each insertion, print the inorder traversal and the height of the
tree, also print the rotation case selected.
4> Generate a random tree with 20 nodes with numbers from 10 to 99. Random tree:
in every insertion you can insert the newly formed node to either the left or right
subtree, chosen randomly.
Now check whether the random tree is a BST or not, print the inorder traversal also.
5> Make a random array of size 20 with random numbers ranging from 10 to 99. Then
use tree sort to sort the array. Print both the raw and sorted array.
6> Take an expression from the user (containing (,),0-9,*,+,-,/ and evaluate the
expression.
7> Take n from the user and then ask for n names iteratively. After each entry insert
them into a BST so that they are alphabetically sorted. After the n names are entered
do an inorder traversal with each node printed in a line.
Question mapping