Posts

Showing posts with the label Data Structures

Evaluating A Postfix Expression Using Stack DataStructures

#include"stdafx.h" #include<math.h> #include<iostream> # define MAX_STACK 150  using namespace std; class stacks {    int value,item,top;    int stack[MAX_STACK];    public:       stacks()       {   top=(-1);       }       void push(float);       float pop(); }; void stacks::push(float value) {    if(top==MAX_STACK)    {       cout<<"Stack is full!\nOverflow!";          exit(0);    }    else    top++;    stack[top]=value; } float stacks::pop() {    if(top<0)    {       cout<<"Stack is empty!\nUnderflow!";       exit(0);    }    else    item=sta...

Tree Data Structure

// Mairaj.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <iostream> using namespace std; class node {           private :           int val;           node *right;           node *left; public :           void setvalue( int x)           {                    val=x;           }           int getvalue()           {                    return val;  ...