Linked Lists
- Write a C program to create and display a singly linked list.
- Expected Output:
Linked List: 1 -> 2 -> 3 -> NULL
- Write a C program to insert an element at the beginning of a singly linked list.
- Input: Insert
5
- Expected Output:
Linked List after inserting 5: 5 -> 1 -> 2 -> 3 -> NULL
- Input: Insert
- Write a C program to insert an element at the end of a singly linked list.
- Input: Insert
4
- Expected Output:
Linked List after inserting 4: 1 -> 2 -> 3 -> 4 -> NULL
- Input: Insert
- Write a C program to delete an element from a singly linked list by key.
- Input: Delete
2
- Expected Output:
Linked List after deleting 2: 1 -> 3 -> 4 -> NULL
- Input: Delete
- Write a C program to find the length of a singly linked list.
- Expected Output:
Length of Linked List: 4
- Write a C program to reverse a singly linked list.
- Expected Output:
Reversed Linked List: 3 -> 2 -> 1 -> NULL
- Write a C program to concatenate two singly linked lists.
- Input: List1:
1 -> 2 -> 3
, List2:4 -> 5 -> 6
- Expected Output:
Concatenated List: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> NULL
- Input: List1:
- Write a C program to detect a loop in a singly linked list (if any).
- Expected Output:
Loop detected: Yes / No
- Write a C program to find the middle node of a singly linked list.
- Expected Output:
Middle Node: 2
- Write a C program to remove duplicates from a sorted singly linked list.
- Input: List:
1 -> 1 -> 2 -> 3 -> 3 -> 3
- Expected Output:
List after removing duplicates: 1 -> 2 -> 3 -> NULL
- Input: List:
Stacks
- Write a C program to implement a stack using an array. Include operations for push, pop, and display.
- Input: Push
5, 10, 15
- Expected Output:
Stack: [5, 10, 15]
- Input: Push
- Write a C program to implement a stack using linked list. Include operations for push, pop, and display.
- Input: Push
5, 10, 15
- Expected Output:
Stack: 15 -> 10 -> 5
- Input: Push
- Write a C program to evaluate a postfix expression using a stack.
- Input: Postfix expression:
6 5 2 3 + 8 * + 3 + *
- Expected Output:
Result: 288
- Input: Postfix expression:
- Write a C program to reverse a stack using recursion.
- Input: Stack:
[1, 2, 3, 4, 5]
- Expected Output:
Reversed Stack: [5, 4, 3, 2, 1]
- Input: Stack:
- Write a C program to check if parentheses in a string are balanced using a stack.
- Input: String:
((()))
- Expected Output:
Balanced parentheses: Yes
- Input: String:
Queues
- Write a C program to implement a queue using an array. Include operations for enqueue, dequeue, and display.
- Input: Enqueue
5, 10, 15
- Expected Output:
Queue: [5, 10, 15]
- Input: Enqueue
- Write a C program to implement a queue using linked list. Include operations for enqueue, dequeue, and display.
- Input: Enqueue
5, 10, 15
- Expected Output:
Queue: 5 -> 10 -> 15
- Input: Enqueue
- Write a C program to implement a circular queue using an array. Include operations for enqueue, dequeue, and display.
- Input: Enqueue
5, 10, 15
- Expected Output:
Circular Queue: [5, 10, 15]
- Input: Enqueue
- Write a C program to reverse the first K elements of a queue.
- Input: Queue
1, 2, 3, 4, 5
and K3
- Expected Output:
Queue after reversing first 3 elements: 3 -> 2 -> 1 -> 4 -> 5
- Input: Queue
Trees
- Write a C program to implement a binary search tree (BST). Include operations for insertion, deletion, and traversal (inorder, preorder, and postorder).
- Input: Insert
5, 3, 7, 2, 4, 6
- Expected Output: (Inorder traversal)
BST: 2 -> 3 -> 4 -> 5 -> 6 -> 7
- Input: Insert
- Write a C program to find the height of a binary tree.
- Input: BST
5, 3, 7, 2, 4, 6
- Expected Output:
Height of BST: 3
- Input: BST
- Write a C program to count leaf nodes in a binary tree.
- Input: BST
5, 3, 7, 2, 4, 6
- Expected Output:
Leaf nodes in BST: 3
- Input: BST
- Write a C program to find the lowest common ancestor (LCA) of two nodes in a binary search tree.
- Input: BST
5, 3, 7, 2, 4, 6
and Nodes2, 4
- Expected Output:
LCA of 2 and 4: 3
- Input: BST
- Write a C program to check if a binary tree is symmetric.
- Input: Binary Tree
1, 2, 2, 3, 4, 4, 3
- Expected Output:
Binary Tree is symmetric: Yes
- Input: Binary Tree
- Write a C program to perform level order traversal of a binary tree.
- Input: Binary Tree
1, 2, 3, 4, 5, 6, 7
- Expected Output:
Level Order Traversal: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7
- Input: Binary Tree
Latest posts by Mahesh Wabale (see all)
- Jacoco - January 3, 2025
- Dependency Track – End To End CI/CD Pipeline - November 29, 2024
- Dependency-track Jenkins Integration - November 27, 2024