Applications of Stack

  Рет қаралды 78

Right Click - Programming Made Easy

Right Click - Programming Made Easy

Күн бұрын

Пікірлер: 4
@ruqayamir9100
@ruqayamir9100 Ай бұрын
Explained beautifully
@Themathjester
@Themathjester Ай бұрын
Mic 😢
@aijazmir6034
@aijazmir6034 Ай бұрын
Are you a teacher in gdc pattan
@rightclick80
@rightclick80 Ай бұрын
// Header file save it as infpos.h file #include #include #define MAX 100 char stack[MAX],postf[MAX]; int top = -1; void push(char x) { stack[++top] = x; } char pop() { if(top == -1) return -1; else return stack[top--]; } int priority(char x) { if(x == '(') return 0; if(x == '+' || x == '-') return 1; if(x == '*' || x == '/') return 2; if(x == '^' || x == '$') return 3; return 0; } void inf2post(char exp[MAX]) { int i=0,j=0; char x; while(exp[i] != '\0') { if(isalnum(exp[i])) //Operand postf[j++]=exp[i]; else if(exp[i] == '(') push(exp[i]); else if(exp[i] == ')') { while((x = pop()) != '(') postf[j++]=x; } else { while(priority(stack[top]) >= priority(exp[i])) postf[j++]=pop(); push(exp[i]); } i++; } while(top!= -1) { postf[j++]=pop(); } } //Program to Convert infix expression to prefix expression #include #include #include"infpos.h" #define Max 100 char inf[Max]; int main() { int i=0; //clrscr(); printf(" Enter non-numerical expression = "); scanf("%s",inf); strrev(inf); //Reverse the infix expression while(inf[i]!='\0') { if(inf[i]=='(') //change ( to ) and vice versa the infix expression inf[i]=')'; else if (inf[i]==')') inf[i]='('; i++; } inf2post(inf); // Convert the expression to postfix expression printf(" Prefix = %s",strrev(postf)); // Reverse the converted expression return 0; } //Program to Convert infix expression to postfix expression #include #include #define MAX 100 #include"infpos.h" int main() { char exp[100]; char x; int i=0; printf("Enter infix expression "); scanf("%s",&exp); printf(" "); inf2post(exp); printf("%s",postf); return 0; }
linked list implementation of stack
41:32
Right Click - Programming Made Easy
Рет қаралды 19
Linked List Implementation of a QUEUE
40:20
Right Click - Programming Made Easy
Рет қаралды 30
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН
Quando eu quero Sushi (sem desperdiçar) 🍣
00:26
Los Wagners
Рет қаралды 15 МЛН
Types of queues in data structure
24:07
Right Click - Programming Made Easy
Рет қаралды 48
Why Microcontrollers are a good AI companion
20:29
Andreas Spiess
Рет қаралды 11 М.
Sparse Matrix representation in Data Structure
31:52
Right Click - Programming Made Easy
Рет қаралды 21
7 Outside The Box Puzzles
12:16
MindYourDecisions
Рет қаралды 184 М.
Merge Sort in Data Structure | C
30:08
Right Click - Programming Made Easy
Рет қаралды 55
Insertion Sort C/ C++/ Datastructures
11:21
Right Click - Programming Made Easy
Рет қаралды 24
Selection Sort in C
9:08
Right Click - Programming Made Easy
Рет қаралды 27
Bubble Sort in C
10:54
Right Click - Programming Made Easy
Рет қаралды 27
Function Call and Declaration | C Programming
5:12
Learniverse
Рет қаралды 10
The Best Band 😅 #toshleh #viralshort
00:11
Toshleh
Рет қаралды 22 МЛН