C Programming Tutorial

 
 
 
 
#include <stdio.h>
#include <conio.h>
#include <alloc.h>

struct node
{
    struct node *left ;
    char data ;
    struct node *right ;
} ;

struct node * buildtree ( int ) ;
void inorder ( struct node * ) ;

char arr[ ] = { \'A\', \'B\', \'C\', \'D\', \'E\', \'F\', \'G\', \'\\0\', \'\\0\', \'H\' } ;
int   lc[ ] = {  1,   3,   5,   -1,   9,  -1,  -1,   -1,   -1,  -1 } ;
int   rc[ ] = {  2,   4,   6,   -1,  -1,  -1,  -1,   -1,   -1,  -1 } ;

void main( )
{
    struct node *root ;

    clrscr( ) ;

    root = buildtree ( 0 ) ;
    printf ( “In-order Traversal:\\n” ) ;
    inorder ( root ) ;

    getch( ) ;
}

struct node * buildtree ( int index )
{
    struct node *temp = NULL ;
    if ( index != -1 )
    {
        temp = ( struct node * ) malloc ( sizeof ( struct node ) ) ;
        temp -> left = buildtree ( lc[index] ) ;
        temp -> data = arr[index] ;
        temp -> right = buildtree ( rc[index] ) ;
    }
    return temp ;
}

void inorder ( struct node *root )
{
    if ( root != NULL )
    {
        inorder ( root -> left ) ;
        printf ( \"%c\\t\", root -> data ) ;
        inorder ( root -> right ) ;
    }
}

    Related Post:
  1. PROGRAM TO FIND ANSWER OF THE FOLLOWING SERIES.INPUT STEPS FROM KEYBORD.SUM=e1+e2+e3+...(TAKE EXP FUNCTION FROM MATH.H)

  2. Program of histogram using self-scheduling and locking the whole bin

  3. Program to create processes using fork() and check orphan state

  4. Program to print pyramid of * (stars) in reverse pattern

  5. Program that converts hexadecimal value in decimal, octal and binary.

  6. Program to compare one string s2 to another string s1 and also first unmatched characters without using strcmp function from string.h

  7. Sum of numbers from 1 to 10, by dividing the job into two processes

  8. Program to find area of cube

  9. Program to display progress bar as displayed in windows system

  10. Program to print the address of a variable along with its value

  11. Program to do sum of the elements of the array by loop splitting and each process adds its partial sum to the final sum

  12. Program that counts number of line, number of words and number characters in specified string

  13. Program that illustrates the function of %[ ] specification

  14. Program to interchange the Small and Captial Letters on the screen after every 5th second and Unload the TSR on a Delete Key Press

  15. Program to receive marks in 2 subjects and output whether the student has passed, failed or is allowed to reappear in any subject

  16. Program to find the sum of numbers from 1 to n using thread

  17. Program to add 4 integer values using 2 processes

  18. Singly Linked list with following operations INSERT AT STARTING, INSERT AT MIDDLE, INSERT AT END, DELETE FIRST NODE, DELETE LAST NODE, DELETE MIDDLE

  19. PROGRAM USNG WHILE LOOP FOR THE FIBONANSI SERIES SERIES :: 1 1 2 3 5 8 13...

  20. Example 7 of using function

 
 
Didn't find what you were looking for? Find more on Program to build a binary search tree from arrays