Ilovepdf Merged
Ilovepdf Merged
1. Write a function that takes a binary search tree as input and checks whether it is an AVL
tree (i.e., whether it is balanced). The program should allow the user to input a binary tree
and check whether it satisfies the AVL balancing property.
2. Write a program to implement an AVL Tree with an insert operation. The program should
allow the user to input a sequence of numbers, insert them into the AVL tree, and display
the in-order, pre-order, and post-order traversal of the tree after each insertion.
3. Extend your AVL tree implementation to include a delete operation. The program should
allow the user to input a sequence of numbers, delete a specific node, and then display the
tree's traversals (in-order, pre-order, post-order).
4. Write a program that computes the height of an AVL Tree. The program should take a
sequence of numbers as input, insert them into the AVL tree, and then compute and display
the height of the AVL tree.
Assignment 9: Binary Search Tree
1. Write a program that accepts user input to create a BST using recursion.
2. Write a program that accepts user input to create a BST using iteration.
3. Searching in BST
a. Write a program that allows searching for an element using recursion. The program
must handle edge cases, such as:
• An empty tree (return a suitable message).
• Duplicate entries (only one instance should be stored in the BST).
• The program should support multiple search attempts for different elements
after tree construction.
b. Extend the BST to support non-recursive (iterative) search implementation.
4. Write a program to delete an element from a BST.
5. Write a program to generate BST from the given pre-order traversal of tree.
Assignment 8: Tree
1. Write a program to create a Binary Tree.
2. Write a program to determine if a binary tree is
a. Strict binary tree
b. Complete
c. Almost complete
3. Two binary trees are similar if they are both empty or if they are both
nonempty. Their left subtrees are similar, and their right subtrees are similar.
Write an algorithm to determine if two binary trees are similar.
4. Write a recursive program to traverse a binary tree using the following
traversal:
a. Inorder Traversal
b. Preorder Traversal
c. Postorder Traversal
5. Write an iterative program to traverse a binary tree using the following
traversal:
a. Inorder Traversal
b. Preorder Traversal
c. Postorder Traversal
6. Write a program that accepts a binary tree representing an expression and
returns the infix version of the expression that contains only those parentheses
that are necessary.
7. Write a program to perform level-order traversal of a binary tree.
8. Write a program to generate tree from a given Pre-order and Inorder Traversal
of a binary tree.
9. Write a program to generate tree from a given Postorder and Inorder Traversal
of a binary tree.
10.Write a program to count the height of a binary tree
11.Write a program to count the total number of nodes in a binary tree
12.Write a program to count the number of following nodes in a binary tree:
a. Nodes with Degree Zero (0)
b. Nodes with Degree One (1)
c. Nodes with Degree Two (2)
Data Structures (Lab)
Assignment-7
Q. No. Description
2. Write the matrix transpose function for the matrices that may not be square
using dynamically allocated arrays.
3. Write a program to check whether the two structure are equal or not?
4. Write a program to add two polynomial expressions (use ARRAY for storing
the coefficient and exponent values).
6. A 𝑚 ∗ 𝑛 matrix is said to have a saddle point if some entry 𝑎[𝑖][𝑗] is the smallest
value in row 𝑖 and the largest value in column 𝑗. Write a function that determines
the location of saddle point if one exists.
Data Structures (Lab)
Assignment-6 (Stack & Queue )
1. WAP to implement Stack.
a. Push an element onto a stack.
b. Pop the stack.&
c. Display the contents of the stack.
2. WAP to convert the following expressions:
a. Infix to Postfix.
b. Infix to Prefix.
c. Postfix to Infix.
d. Postfix to Prefix.
e. Prefix to Infix.
f. Prefix to Postfix.
3. WAP to evaluate a postfix expression.
4. WAP to implement two stacks in a single array.
5. WAP to implement Queue.
a. Insert an element into the queue.
b. Delete an element from the queue.
c. Display the contents of the queue.
6. WAP to implement Circular Queue.
a. Insert an element into the circular queue.
b. Delete an element from the circular queue.
c. Display the contents of the circular queue.
7. WAP to implement Double Ended Queue.
a. Insert an element into the double ended queue.
b. Delete an element from the double ended queue.
c. Display the contents of the double ended queue.
8. WAP to implement Priority Queue.
a. Insert an element into the priority queue.
b. Delete an element from the priority queue.
c. Display the contents of the priority queue.
Data Structures (Lab)
Assignment- 5
Experiment Description
No.
1.
2.
3.
4.
5.
6.
Assignment -2
(Array)
Note: Always try to write menu driven program with proper comments in your code
1. Consider the elements of the array are given as {2 7 9 5 8 7 4}. Write a program in C to
find minimum number of swaps required to gather all elements less than or equals to k.
3. Write a program in C to merge two arrays of same size sorted in descending order.
6. Write a program in C to display the lower triangular and upper triangular matrix of given 3x3
matrix.
7. Write a program in C to find two elements whose sum is closest to zero. (Elements of array
can be negative no. also).
8. Write a program in C to rearrange an array in such an order that– smallest, largest, 2nd
smallest, 2nd largest and so on.
Data Structures (Lab)
Assignment-1 (Fundamentals)