11. Write a program to evaluate a mathematical expression in postfix notation (e.g., 5 1 2 + 4 * + 3 -).
Required Input:
Expression: "5 1 2 + 4 * + 3 -"
Expected Output:
Result: 14
Code In C#
using System;
using System.Collections.Generic;
class PostfixEvaluation
{
static void Main()
{
// Evaluate a postfix expression
}
}
Run Code?
Click Run Button to view compiled output
12. Create a program to solve the Tower of Hanoi problem for a hardcoded number of disks.
Required Input:
Number of Disks: 3
Expected Output:
Move disk 1 from A to C
Move disk 2 from A to B
Move disk 1 from C to B
Move disk 3 from A to C
Move disk 1 from B to A
Move disk 2 from B to C
Move disk 1 from A to C
Code In C#
using System;
class TowerOfHanoi
{
static void Main()
{
// Solve the Tower of Hanoi problem
}
}
Run Code?
Click Run Button to view compiled output
13. Write a program to implement a binary search tree with methods for insertion, deletion, and in-order traversal.
Required Input:
Operations: Insert(50), Insert(30), Insert(70), Delete(30), InOrder()
Expected Output:
In-Order Traversal: 50 70
Code In C#
using System;
class BinarySearchTree
{
static void Main()
{
// Implement a binary search tree with insertion, deletion, and traversal
}
}
Run Code?
Click Run Button to view compiled output
14. Create a program to implement a sliding window algorithm to find the maximum sum of a subarray of fixed size.
Required Input:
Array: [1, 3, 2, 5, 1, 1, 2, 3], Window Size: 3
Expected Output:
Maximum Sum: 10
Code In C#
using System;
class SlidingWindow
{
static void Main()
{
// Implement a sliding window algorithm to find the maximum sum
}
}
Run Code?
Click Run Button to view compiled output
15. Write a program to perform matrix multiplication for two hardcoded matrices.
Required Input:
Matrices: A = [[1, 2], [3, 4]], B = [[5, 6], [7, 8]]
Expected Output:
Result:
19 22
43 50
Code In C#
using System;
class MatrixMultiplication
{
static void Main()
{
// Perform matrix multiplication for the given matrices
}
}
Run Code?
Click Run Button to view compiled output
16. Create a program to implement a circular queue using an array.
Required Input:
Operations: Enqueue(10), Enqueue(20), Enqueue(30), Dequeue(), Enqueue(40)
Expected Output:
Queue: 20 30 40
Code In C#
using System;
class CircularQueue
{
static void Main()
{
// Implement a circular queue with enqueue and dequeue operations
}
}
Run Code?
Click Run Button to view compiled output
17. Write a program to find the strongly connected components in a directed graph using Tarjan's algorithm.
Required Input:
Graph: Provided in the problem description.
Expected Output:
Strongly Connected Components:
2 1 0
5 4 3
Code In C#
using System;
class StronglyConnectedComponents
{
static void Main()
{
// Find strongly connected components in a directed graph
}
}
Run Code?
Click Run Button to view compiled output
18. Create a program to implement merge intervals for a hardcoded list of intervals.
Required Input:
Intervals: [[1, 3], [2, 6], [8, 10], [15, 18]]
Expected Output:
Merged Intervals:
[1, 6]
[8, 10]
[15, 18]
Code In C#
using System;
using System.Collections.Generic;
class MergeIntervals
{
static void Main()
{
// Merge overlapping intervals
}
}
Run Code?
Click Run Button to view compiled output
19. Perform depth-first and breadth-first searches on a graph.
Required Input:
Graph: 0 -> 1, 2; 1 -> 2; 2 -> 0, 3; 3 -> 3. Start Node: 2
Expected Output:
DFS: 2, 0, 1, 3
BFS: 2, 0, 3, 1
Code In C#
using System;
using System.Collections.Generic;
class GraphSearch
{
static void Main()
{
// Perform DFS and BFS on the graph
}
}
Run Code?
Click Run Button to view compiled output
20. Solve the knapsack problem using dynamic programming.
Required Input:
Weights: [1, 3, 4, 5]; Values: [1, 4, 5, 7]; Capacity: 7
Expected Output:
Maximum Value: 9
Code In C#
using System;
class Knapsack
{
static void Main()
{
// Solve the knapsack problem using dynamic programming
}
}
Run Code?
Click Run Button to view compiled output