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>
# include <malloc.h>
# include <process.h>

int display_menu();

struct link_list
{
 int no;
 struct link_list *next;
 struct link_list *prev;
};
class dqueue
{
 link_list *list,*head;
 public:
    dqueue()
    {
     head=NULL;
    }
    void insert_first();
    void insert_last();
    void delete_first();
    void delete_last();
    void display();
};
void dqueue :: insert_first()
{
  link_list *newnode;
  newnode = new link_list;
  cout<<\"Enter Number :\";
  cin>>newnode->no;
  list=head;
  if(list==NULL)
  {
   head=newnode;
   newnode->next=NULL;
   newnode->prev=NULL;
   return;
  }
  newnode->next=list;
  newnode->prev=NULL;
  list->prev=newnode;
  head=newnode;
}

void dqueue :: insert_last()
{
 link_list *newnode;
 newnode= new link_list;
 cout<<\"Enter Number :\";
 cin>>newnode->no;





 list=head;
 if(list==NULL)
 {
  head=newnode;
  newnode->next=NULL;
  newnode->prev=NULL;
  return;
 }
 while(list->next!=NULL)
 {
  list=list->next;
 }
 list->next=newnode;
 newnode->prev=list;
 newnode->next=NULL;
}

void dqueue :: display()
{
 cout<<endl;
 link_list *tail;
 list=head;
 if(head==NULL)
 {
  cout<<\"Empty Queue !!!\";
  return;
 }
 cout<<endl;
 cout<<\"Forward Display ...\"<<endl;
 while(list!=NULL)
 {
  cout<<list->no<<\"\\t\";
  if(list->next==NULL)
  {
    tail=list;
  }
    list=list->next;
 }
 list=tail;
 cout<<endl<<\"Backward Display ...\"<<endl;
 while(list!=NULL)
 {
  cout<<list->no<<\"\\t\";
  list=list->prev;
 }
}

void dqueue :: delete_first()
{
  list=head;
  list->next->prev=NULL;
  head=list->next;
}

void dqueue :: delete_last()
{
  list=head;
  while(list->next->next!=NULL)
  {
   list=list->next;
  }
  list->next=NULL;
}







void main()
{
 dqueue dq1;
 clrscr();
 while(1)
 {
  switch(display_menu())
  {
   case 1 : dq1.insert_first();
        dq1.display();
        getch();
        break;
   case 2 : dq1.insert_last();
        dq1.display();
        getch();
        break;
   case 3 : dq1.delete_first();
        dq1.display();
        getch();
        break;
   case 4 : dq1.delete_last();
        dq1.display();
        getch();
        break;
   case 5 : dq1.display();
        getch();
        break;
   case 6 : exit(0);
  }
 }
}

int display_menu()
{
 int ch;
 clrscr();
 cout<<\"[ 1 ] : Insert at First\"<<endl;
 cout<<\"[ 2 ] : Insert at Last\"<<endl;
 cout<<\"[ 3 ] : Delete From First\"<<endl;
 cout<<\"[ 4 ] : Delete From Last\"<<endl;
 cout<<\"[ 5 ] : Display\"<<endl;
 cout<<\"[ 6 ] : Exit\"<<endl;
 cout<<\"Enter your choice :\";
 cin>>ch;
 return(ch);
}

    Related Post:
  1. Program to illustrate printing data on the printer

  2. Program to estimate value of First Derivative of the function at the given points from the given data using Backward Difference Formula , Forward diff

  3. Program to illustrate the use of friend classes

  4. Program to illustrate unary operator(decrement operator) overloading with return type

  5. Program to multiply 2 polynomial functions

  6. Program to illustrate the operations that can be performed on pointers

  7. Program to convert an Infix Expression into a Postfix / Suffix Expression without parenthesize

  8. Program to draw a K-Curve of nth order

  9. Program to capitalize the first charcter of every word in a string

  10. Program to illustrate the implementation of Translation Transformation

  11. Program that reads an expression consisting of two non-negative integer and an operator. Determine if either integer or the result of the expres......

  12. Program of displaying product inventory by converting one class to another class

  13. 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 2

  14. Program that reads a number ,coumputes and displays its factorial ( using for loop )

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

  16. Program for Operator Overloading

  17. Program to illustrate passing structures to function

  18. Program of that provides an example of function overloading

  19. Program to draw an ellipse using Trigonometric Method

  20. Program that displays graphical representation of tower of hanoi

 
 
Didn't find what you were looking for? Find more on program to create a doubly link list