Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
|
Infix to Postfix converter implementation More...
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <stdint.h>
#include <assert.h>
Data Structures | |
struct | Stack |
for printf() and scanf() More... | |
Functions | |
void | push (char opd) |
Function to push on the stack. More... | |
char | pop () |
Function to pop from the stack. More... | |
uint16_t | isEmpty () |
Function to check whether the stack is empty or not. More... | |
char | Top () |
Function to get top of the stack. More... | |
int16_t | priority (char opr) |
Function to check priority of operators. More... | |
char * | convert (char inf[]) |
Function to convert infix expression to postfix expression. More... | |
static void | test () |
Self-test implementations. More... | |
int | main () |
Main function. More... | |
Variables | |
struct Stack | st |
global declaration of stack st | |
Infix to Postfix converter implementation
The input infix expression is of type string upto 24 characters. Supported operations- '+', '-', '/', '*', ''
char * convert | ( | char | inf[] | ) |
Function to convert infix expression to postfix expression.
inf | the input infix expression |
< to store the postfix expression
< loop iterator
< keeps track of end of postfix string
int isEmpty | ( | ) |
Function to check whether the stack is empty or not.
Returns 1 if stack is empty, returns 0 if not empty.
int main | ( | void | ) |
Main function.
initialize
run self-test implementations
< to store input infix expression
void pop | ( | void | ) |
Function to pop from the stack.
Pop data from the stack.
< to store the popped value to be returned
int16_t priority | ( | char | opr | ) |
Function to check priority of operators.
opr | operator whose priority is to be checked |
void push | ( | char | opd | ) |
|
static |
Self-test implementations.
this ensures that the algorithm works as expected
this ensures that the algorithm works as expected