C++ Programming Tutorial

 
 
 

Data File Structure Programs

Array

Insert, edit, delete, append, display, Srch. Insert, delete, merge, delete multiple occurrences Arrays as a Stack in graphics

Stack

Stack operations using array Stack using static memory allocation Stack using dynamic memory allocation Double ended link list as a stack Lnked list as a Stack Infix expr. to Postfix expr. Postfix expr. into an Infix expr. Arrays as a Stack in graphics Stack as an Arithmetic expr. Evaluater Graphical Rep. of Stack Stack to traverse - inodr, postodr, preodr

Queue

Queue using static memory allocation Queue using dynamic memory allocation Circular queue Linked list as a Queue Double Ended linked list as a Queue Graphical Rep. of Queue Arrays as a Linear Queue Array as a Circular Queue Arrays as a Linear Queue ( in graphics ) Arrays as a Circular Queue ( in graphics )

Linked List

Singly link list Circular linked list Doubly link list Linked list as a Queue Linked list as a Stack Double Ended linked list as a Queue Double Ended linked list as a Stack Infix to Postfix - Linked List as Stack Circular doubly link list Single Ended Linked List - Sorting in both odr Hashing - double ended Linked List Sort of link list

Tree

Linked List as a Binary Srch. Tree Set Class using Binary Srch. Tree Maximum depth of Binary Srch. Tree Minimum Spaning Tree Prims algo - minimum spanning tree Traverse binary tree - inodr, preodr, post Find number in binary Srch. tree display levell

Sorting

Bubble Sort Selection Sort Insertion Sort Radix Sort Merge Sort Quick Sort Heap Sort Linear Sort Shell Sort Topological Sort

Searching

Linear Srch. or Sequential Srch. Binary Search Breadth First Search Traversal Depth First Search Traversal Shortest Path-Given Source-Destination-Dijkstras

Hashing

Simple implementation of Hashing Hashing using double-ended Linked List Hashing using Mid-Square Method Example of Hashing n term of the fibonacci series using recursion

Recursion

Factorial of the given number using recursion Mystery of Towers of Hanoi using recursion
 
 

Image

 # include <iostream.h>
 # include   <string.h>
 # include   <stdlib.h>
 # include    <conio.h>

 struct node
 {
    char data;

    node *next;
 };

 node *top=NULL;
 node *bottom=NULL;
 node *entry;
 node *last_entry;
 node *second_last_entry;

 void push(const char);
 const char pop( );

 void infix_to_postfix(const char *);

 int main( )
    {
       clrscr( );

       char Infix_expression[100]={NULL};

       cout<<\"\\n\\n Enter the Infix Expression : \";
       cin>>Infix_expression;

       infix_to_postfix(Infix_expression);

       getch( );
       return 0;
    }


 //-----------------------------  push(const char)  ----------------------//


 void push(const char Symbol)
    {
       entry=new node;

       if(bottom==NULL)
      {
         entry->data=Symbol;
         entry->next=NULL;
         bottom=entry;
         top=entry;
      }

       else
      {
         entry->data=Symbol;
         entry->next=NULL;
         top->next=entry;
         top=entry;
      }
    }


 //--------------------------------  pop( )  -----------------------------//


 const char pop( )
    {
       char Symbol=NULL;

       if(bottom==NULL)
      cout<<\"\\n\\n\\n\\t ***  Error : Stack is empty. \\n\"<<endl;

       else
      {
         for(last_entry=bottom;last_entry->next!=NULL;
                         last_entry=last_entry->next)
        second_last_entry=last_entry;

         if(top==bottom)
        bottom=NULL;

         Symbol=top->data;

         delete top;

         top=second_last_entry;
         top->next=NULL;
      }

       return Symbol;
    }


 //---------------------  infix_to_postfix(const char *)  ----------------//


 void infix_to_postfix(const char *Infix)
    {
       char Infix_expression[100]={NULL};
       char Postfix_expression[100]={NULL};

       strcpy(Infix_expression,\"(\");
       strcat(Infix_expression,Infix);
       strcat(Infix_expression,\")\");

       char Symbol[5]={NULL};
       char Temp[5]={NULL};

       for(int count=0;count<strlen(Infix_expression);count++)
      {
         Symbol[0]=Infix_expression[count];

         if(Symbol[0]==\'(\')
        push(Symbol[0]);

         else if(Symbol[0]==\')\')
        {
           Symbol[0]=pop( );

           while(Symbol[0]!=\'(\')
              {
             strcat(Postfix_expression,Symbol);

             Symbol[0]=pop( );
              }
        }

         else if(Symbol[0]==\'^\' || Symbol[0]==\'*\' || Symbol[0]==\'/\'
                    || Symbol[0]==\'+\' || Symbol[0]==\'-\')
        {
           if(Symbol[0]==\'*\' || Symbol[0]==\'/\')
              {
             Temp[0]=pop( );

             while(Temp[0]==\'^\' || Temp[0]==\'*\' || Temp[0]==\'/\')
                {
                   strcat(Postfix_expression,Temp);

                   Temp[0]=pop( );
                }

             push(Temp[0]);
              }

           else if(Symbol[0]==\'+\' || Symbol[0]==\'-\')
              {
             Temp[0]=pop( );

             while(Temp[0]!=\'(\')
                {
                   strcat(Postfix_expression,Temp);

                   Temp[0]=pop( );
                }

             push(Temp[0]);
              }

           push(Symbol[0]);
        }

         else
        strcat(Postfix_expression,Symbol);
      }

       cout<<\"\\n\\n Postfix Expression : \"<<Postfix_expression;
    }

    Related Post:
  1. Program to generate a triangular wave form according to a specified pair of Amplitude and Frequency

  2. Program to estimate the Integral value of a given function using Gussian Quadrature Rule

  3. Program to illustrate the implementation of arrays as a Linear Queue

  4. Program to show the use of Bitwise Operator XOR ( ^ )

  5. Program that displays the size, address of the variables of type int , float and char.

  6. Employee database management system

  7. Program to add, subtract and multiply matrix

  8. Program of vector class that perform different operations on vector

  9. Program to illustrate the use of call-by-value method in functions

  10. Program that reads a number and prints even if the number is even and prints odd if the number is odd.

  11. Program to illustrate the implementation of Reflection Transformation about the line y=x and y=-x

  12. Program to read a Non-Linear equation in one variable, then evaluate it using Simple Itrative Method and display its kD accurate root

  13. Program to estimate the value of First Derivative of the function at the given points from the given data using Central Difference Formula of order 4

  14. Program pf parser 1

  15. Program that prints all the even numbers b/w 0 to 50 ( using while, do-while and for loop )

  16. Program for Operator Overloading and Friend Function concept

  17. Program to illusrate data conversion user defined data types using constructor

  18. Program that creates triangle based on user input

  19. Program to read a Non-Linear equation in one variable, then evaluate it using False-Position Method and display its kD accurate root

  20. Program for Banking Application