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>

 int binary_search(int [],int,int);


 main( )
    {
       clrscr( );

       const int array_size=10;
       int array[array_size]={0,6,9,12,20,23,29,32,47,79};

       cout<<\" ******************************************************************************\"<<endl;
       cout<<\" *******************************  Binary Search  ******************************\"<<endl;
       cout<<\" ******************************************************************************\"<<endl;

       gotoxy(1,24);
       cout<<\" ******************************************************************************\"<<endl;
       cout<<\" ******************************************************************************\";

       gotoxy(1,5);
       cout<<\"\\n The contents of the array are : \"<<endl;

       cout<<\"\\n     Elements :\"<<\"\\t\\t     Value:\"<<endl;

       for(int count=0;count<array_size;count++)
      {
         cout<<\"\\t\"<<\" array [\"<<count<<\"]\"<<\"\\t\\t\";
         cout<<array[count]<<endl;
      }

       int searching_element=0;
       int flag=0;

       cout<<\"\\n Enter the element you want to find  =  \";
       cin>>searching_element;

       flag=binary_search(array,array_size,searching_element);

       if(flag!=-1)
      cout<<\"\\n The given element is found at the position  array[\"<<
                                   flag<<\"]\";

       else
      cout<<\"\\n The given element is not found. \";

       getch( );
       return 0;
    }


 /***********************  binary_search(int [],int,int)  *****************/


 int binary_search(int array[],int array_size,int element)
    {
       int start=0;
       int end=array_size-1;
       int middle;
       int position=-1;

       middle=(start+end)/2;

       do
      {
         if(element<array[middle])
        end=middle-1;

         else if(element>array[middle])
        start=middle+1;

         middle=(start+end)/2;
      }
       while(start<=end && array[middle]!=element);

       if(array[middle]==element)
      position=middle;

       return position;
    }

    Related Post:
  1. Program that computes the n_th term of the fibonacci series and also print the series upto the n_th term using recursion

  2. Nested Structure Database Program

  3. Program to interchange the values of two int , float and char using function templates

  4. PROGRAM FOR ACCEPTING MEASUREMENTS IN METERS AND FEETS AND SUMMING THEM UP IN THE FORMAT THAT THE USER WISHES

  5. Program to print a string char by char using constant pointers to non-constant data

  6. Program to illustrate unary operator(decrement operator) overloading without return type

  7. Implement a Matrix class representing 2-dimensional matrix with the following functionalities i.e. operators + , - , * , == , += &lt;&lt; , &gt;&gt; etc

  8. Problem you will be analyzing a property of an algorithm whose classification is not known for all possible inputs

  9. Program to print an array using funtion definition

  10. Program to fill a Circle using Scan-Line Circle Fill Algorithm using Polar Coordinates

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

  12. Program to perform array operations like append, insert, delete, edit, display and search and element

  13. Program that reads 10 students marks and displays average, lowest and highest marks

  14. Program to create a stack using dynamic memory allocation

  15. Stacks code in C++

  16. Program of scaling about reference point

  17. Program to input matrix table

  18. Write a Program to create Numeric Triangle

  19. Program that prints first 20 integers in reverse order (using while loop )

  20. Program to create a queue using dynamic memory allocation

 
 
Didn't find what you were looking for? Find more on Program to search an element in an array using Binary search