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
 
 
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
struct btree
{
    struct btree *left;
    struct btree *right;
    int no;
};
void postorder(struct btree *trav);
void inorder(struct btree *trav);
void preorder(struct btree *trav);
struct btree * create(struct btree *trav);
main()
{
    struct btree *root=NULL;
    char c;
    clrscr();
    while(1)
    {
        root=create(root);
        cout<<\"Do you want to continue : \";
        cin>>c;
        if(c==\'n\' ||c==\'N\')
            break;
    }
    cout<<endl<<\"Inoder is    : \";inorder(root);
    cout<<endl<<\"Preorder is  : \";preorder(root);
    cout<<endl<<\"Postorder is : \";postorder(root);
    getch();
}
struct btree * create(struct btree *trav)
{
    if(trav==NULL)
    {
        trav=new btree;
        trav->right=NULL;
        trav->left=NULL;
        cout<<\"Enter the no : \";
        cin>>trav->no;
        return(trav);
    }
    char choice;
    cout<<\"Enter the left or right child : \";
    cin>>choice;
    if(choice == \'r\' || choice == \'R\')
    {
        trav->right=create(trav->right);
    }
    if(choice==\'l\' || choice==\'L\')
    {
        trav->left=create(trav->left);
    }
    return(trav);
}
void inorder(struct btree *trav)
{
    if(trav==NULL)
        return ;
    inorder(trav->left);
    cout<<\" \"<<trav->no;
    inorder(trav->right);
}
void preorder(struct btree *trav)
{
    if(trav==NULL)
        return;
    cout<<\" \"<<trav->no;
    preorder(trav->left);
    preorder(trav->right);
}
void postorder(struct btree *trav)
{
    if(trav==NULL)
        return;
    postorder(trav->left);
    postorder(trav->right);
    cout<<\" \"<<trav->no;
}

    Related Post:
  1. Program of inheritance using shape class and area calculation

  2. Program to illustrate the use of reference variables

  3. Code for finding a no in a binary search tree and displaying its level where it is found (root is at zero level)

  4. Program to show the implementation of Sutherland-Hodgeman Polygon Clipping Algorithm

  5. Program to illustrate friend function

  6. Scanner of valide variable name in c

  7. Program to show the Urdu Alphabets using Stroke Method

  8. Perform insert, delete, merge and delete multiple occurrences of a number from an array

  9. Program of Midpoint Circle Drawing

  10. Program that provides an example of This pointer

  11. Program to help Umar in this task. Represent each city by one lowercase character. Thus, you can have at most 26 different cities to visit....

  12. Program to estimate the value of Third Derivative of the function at the given points from the given data using Central Difference Formula of Order 4

  13. Program to show the projection of 3D objects using Cavalier Oblique Parallel Projection onto xy-plane (i.e. angle=45 deg)

  14. Program to illustrate an example of structures

  15. Mini Project School Management Application

  16. Program of scaling about reference point

  17. Program to calculate distance summation, subtraction, multiplication and comparison using overloading operators also make it friend functions

  18. Program of time conversion using conversion functions

  19. Program to illustrate the declaration , initialization and printing a constant variable

  20. Program that computes the n_th term of the fibonacci series and also print the series upto the n_th term using recursion

 
 
Didn't find what you were looking for? Find more on Program of traversing a binary tree in inorder, preorder and postorder fashion