Ds Assignment 7
Ds Assignment 7
Aim: To understand the concept of a stack and implement it using a linked list data structure in C
programming.
Experiment Tasks:
1. Implement a function isBalanced to check if a given expression with parentheses (e.g., "({[()]})")
is balanced using the stack data structure.
2. Implement a function evaluatePostfix to evaluate a given postfix expression (e.g., "23*5+")
using the stack.
3. Test both functions with various input expressions.
Solution:
#include <stdio.h>
#include <stdlib.h>
int main() {
struct Stack stack;
initializeStack(&stack);
displayStack(&stack);
return 0;
}
TASK -3:
#include <stdio.h>
#include <stdlib.h>
struct Node {
int data;
struct Node* next;
};
struct Stack {
struct Node* top;
};
int main() {
char balancedExp[] = "({[()]})";
char unbalancedExp[] = "([)]";
char postfixExp[] = "23*5+";
return 0;
}