0% found this document useful (0 votes)
29 views12 pages

Ilovepdf Merged

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views12 pages

Ilovepdf Merged

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

Assignment 11: Graphs

1. Write a program that performs a breadth-first traversal of a given graph.


Ensure that your program can handle graphs with cycles, identifying and
marking any cycles encountered during traversal.
2. Write a program that performs a depth-first traversal of a given graph.
Additionally, implement functionality to detect and highlight back edges to
verify if the graph contains cycles.
3. Implement Prim's algorithm to find the minimum spanning tree (MST) of a
given weighted graph.
4. Implement Kruskal's algorithm to find the MST of a given graph, adding a
constraint that disallows specific edges (selected by the user at runtime). Your
algorithm should handle edge constraints, adjust the MST accordingly, and
output the cost difference compared to an unconstrained MST.
5. Implement the adjacency list representation of a graph with 𝑚 vertices and 𝑛
edges. Extend this functionality to check if a path of exactly k edges exists
between any given pair of vertices.
Assignment 9: AVL Tree

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

1. Write the recursive version of magic square program.

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).

5. Write a program to multiply two sparse matrices.

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

1.Write a C Program to Demonstrate Circular linked list.


(a) Creation of Circular linked list
(b) Insertion at beginning
(c) Insertion at remaining
(d) Deletion at beginning
(e) traverse
(f) Search
(g) sort
(h) update
(i) Exit
Data Structures (Lab)
Assignment- 4 (Linked List-1)

1. WAP to implement Linked List.

a. Create a linked list.

b. Insert an element at the start of the linked list.

c. Insert an element at the end of the linked list.

d. Insert an element before an existing element whose information is x in a linked list.

e. Insert an element after an existing element whose information is x in a linked list.

f. Delete the first element of the linked list.

g. Delete the last element of the linked list.

h. Delete the element whose information is x from a linked list.

i. Display the contents of the linked list.

2. WAP to find the length of the Linked List using recursion.

3. WAP to concatenate two Linked Lists.

4. WAP to delete duplicate elements from a sorted Linked List.

5. WAP to delete every alternate element of the Linked List.

6. WAP to check whether the Linked List is a palindrome or not.

7. WAP to reverse a Linked List.


Assignment 3
(Array & Structures)
Note: Always try to write menu driven program with proper comments in your code

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.

2. Write a program in C to count a total number of duplicate elements in an array.

3. Write a program in C to merge two arrays of same size sorted in descending order.

4. Write a program in C to count the frequency of each element of an array.

5. Perform the following operations on 2-D Array.


I. Addition
II. Subtraction
III. Multiplication
IV. Transpose of a Given Matrix

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)

1. WAP to check whether a given matrix is Magic Square or not?


2. WAP to implement Call by Value and Call by Reference mechanisms.
3. WAP to implement three different ways to swap two variables without using a third variable.
4. WAP to implement the following programs using recursion.
a. Factorial
b. Fibonacci Series
c. Greatest Common Divisor
d. Linear Search
e. Binary Search
f. Tower of Hanoi

You might also like