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 <conio.h>
#define MAX_NODE 50

struct node{
    int vertex;
    node *next;
};

node *adj[MAX_NODE]; //For storing Adjacency list of nodes.
int totNodes; //No. of Nodes in Graph.
const int ready=1,wait=2,processed=3; //status of node.
int status[MAX_NODE];//status arr for maintaing status.
node *sngllist=NULL; //Singly Link List


void createGraph(){
    node *newl,*last;
    int neighbours,neighbour_value;
    cout<<\"\\n\\n---Graph Creation---\\n\\n\";
    cout<<\"Enter total nodes in graph : \";
    cin>>totNodes;
    for(int i=1;i<=totNodes;i++){
        last=NULL;
        cout<<\"\\nEnter no. of nodes in the adjacency list of node \"<<i<<\"\\n\";
        cout<<\"--> That is Total Neighbours of \"<<i<<\" : \";
        cin>>neighbours;
        for(int j=1;j<=neighbours;j++){
            cout<<\"Enter neighbour #\"<<j<<\" : \";
            cin>>neighbour_value;
            newl=new node;
            newl->vertex=neighbour_value;
            newl->next=NULL;
            if(adj[i]==NULL)
                adj[i]=last=newl;
            else{
                last->next = newl;
                last = newl;
            }
        }
    }
}


void dfsVisit(int i)
{
    node *tmp,*newl;
    int v;

    tmp=adj[i];
    while(tmp != NULL)
    {
        v=tmp->vertex;
        if(status[v]==ready)
            dfsVisit(v);
        tmp=tmp->next;
    }

    newl=new node;
    newl->vertex=i;
    newl->next=sngllist;
    sngllist=newl;
    status[i]=processed;
}



void topologicalSort(){
    int i;

    for(i=1;i<=totNodes;i++)
        status[i]=ready;

    for(i=1;i<=totNodes;i++){
        if(status[i]==ready)
            dfsVisit(i);
    }

    //print list
    while(sngllist!=NULL){
        cout<<\"   \"<<sngllist->vertex;
        sngllist=sngllist->next;
    }

}


void main(){
    clrscr();
    cout<<\"*****Topological Sort*****\\n\";
    createGraph();
    cout<<\"\\n===Topological Sort is as under===\\n\";
    topologicalSort();
    getch();
}

    Related Post:
  1. 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

  2. Program to illustrate the overloading of constructors in classes

  3. Program to show the implementation of Liang-Barsky Line Clipping Algorithm

  4. Program to display bill receipt based on customer information and create telephone directory

  5. Program to estimate the Integral value of the function at the given points from the given data using Trapezoidal Rule

  6. PROGRAM OF OPERATOR PRECEDENCE MATRIX

  7. Program that performs addition operation of 2 polar objects by + operator overloading.

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

  9. Program to illustrate the implementation of array as a Circular Queue

  10. Program to implement the Prims Algorithm to solve Minimum Spanning Tree Problem (MST)

  11. Program to fill a Rectangle using Scan-Line Rectangle Fill Algorithm

  12. Program to illustrate the 2D array of int using pointers

  13. Program to perform merge sort

  14. Program to computes the n_th term of the fibonacci series using Toplogical Odering and Dynamic Programming Technique

  15. Program to implement Lexical Analyzer

  16. Unary Operator ++ Operator Overloading

  17. Program to perform stack operations using array

  18. Program to illustrate supplying of values to pointer variables

  19. Program of virtual inheritance that takes input of staff members and performs an operation on it

  20. Program that performs selection search

 
 
Didn't find what you were looking for? Find more on Program that sorts numbers using topological sort method