What's New-Given Below
technicalsymposium
technicalsymposium
technicalsymposium

College Lab Codings/Project Codings-Download

DataStructure-Program to maintain a heap.

#include <stdio.h>
#include <conio.h>
void restoreup ( int, int * ) ;
void restoredown ( int, int *, int ) ;
void makeheap ( int *, int ) ;
void add ( int, int *, int * ) ;
int replace ( int, int *, int ) ;
int del ( int *, int * ) ;
void main( )
{
int arr [20] = { 1000, 7, 10, 25, 17, 23, 27, 16, 19, 37, 42, 4, 33, 1, 5, 11 } ;
int i, n = 15 ;
clrscr( ) ;
makeheap ( arr, n ) ;
printf ( "Heap:\n" ) ;
for ( i = 1 ; i <= n ; i++ )
printf ( "%d\t", arr [i] ) ;
i = 24 ;
add ( i, arr, &n ) ;
printf ( "\n\nElement added %d.\n", i ) ;
printf ( "\nHeap after addition of an element:\n" ) ;
for ( i = 1 ; i <= n ; i++ )
printf ( "%d\t", arr [i] ) ;
i = replace ( 2, arr, n ) ;
printf ( "\n\nElement replaced %d.\n", i ) ;
printf ( "\nHeap after replacement of an element:\n" ) ;
for ( i = 1 ; i <= n ; i++ )
printf ( "%d\t", arr [i] ) ;
i = del ( arr, &n ) ;
printf ( "\n\nElement deleted %d.\n", i ) ;
printf ( "\nHeap after deletion of an element:\n" ) ;
for ( i = 1 ; i <= n ; i++ )
printf ( "%d\t", arr [i] ) ;
getch( ) ;
}
void restoreup ( int i, int *arr )
{
int val ;
val = arr [i] ;
while ( arr [i / 2] <= val )
{
arr [i] = arr [i / 2] ;
i = i / 2 ;
}
arr [i] = val ;
}
void restoredown ( int pos, int *arr, int n )
{
int i, val ;
val = arr [pos] ;
while ( pos <= n / 2 )
{
i = 2 * pos ;
if ( ( i < n ) && ( arr [i] < arr [i + 1] ) )
i++ ;
if ( val >= arr [i] )
break ;
arr [pos] = arr [i] ;
pos = i ;
}
arr [pos] = val ;
}
void makeheap ( int *arr, int n )
{
int i ;
for ( i = n / 2 ; i >= 1 ; i-- )
restoredown ( i, arr, n ) ;
}
void add ( int val, int *arr, int *n )
{
( *n ) ++ ;
arr [*n] = val ;
restoreup ( *n, arr ) ;
}
int replace ( int i, int *arr, int n )
{
int r = arr [1] ;
arr [1] = i ;
for ( i = n / 2 ; i >= 1 ; i-- )
restoredown ( i, arr, n ) ;
return r ;
}
int del ( int *arr, int *n )
{
int val ;
val = arr [1] ;
arr [1] = arr [*n] ;
( *n ) -- ;
restoredown ( 1, arr, *n ) ;
return val ;
}

technicalsymposium

Technicalsymposium.com-A Complete Website for Engineering Students & Engineering Faculties.All Useful Links & Contents Given Below

technicalsymposium

Free Email Alerts
Get free email alerts-Fresher’s Jobs/Conference/Symposium/Exams Alerts-Click here to Subscribe.

Free Event Publishing
Publish your college technical symposium/free events in our website & Attract more targeted audience- Click here to Get

Conference/Symposium
All engineering colleges /Premier Institutions (IIT,IISC,NIT,etc.,) Conferences/Workshop details-Click here to Get

Fresher’s Jobs/Scholarships Details
Freshers Software Jobs/Government Jobs and Student Internships/Scholarships Details- Click here to Get

Placement Papers
All Software Companies previous placement papers/Govt Competitive exam previous papers/Tech Materials free download-Click her to get.

Lab Programs/Lab Manuals
All Branches of Lab Programs/Lab Manuals for all branches of Engineering-Click here to Get

University Previous Question Papers
Anna university/All leading universities previous question papers year wise and Semester wise- Click here to Get

GATE Question Papers
GATE Previous Question Papers –All Branches by year wise-Click here to Get

Indian Engineering Services (IES) Question Papers
IES Previous Question Papers –All Branches by year wise-Click here to Get

Anna University Syllabus
Anna University all branches syllabues free download for all B.E(All Branches)/B.Tech(All Branches)/M.E/M.Tech/MCA/MBA- Click here to Get

GATE/ All Entrance Exam Syllabus
GATE/ All Leading Entrance Exam Syllabus free download-Click here to Get

Competitive Exam Syllabuses
Bank/Railway/SSC,all kind of Competitive Exam syllabuses free Download-Click here to get

Civil Engineering Lecture Notes
Civil engineering lecture notes by semester wise and Lab Programs/Manuals-Click here to get

Electronics & Communication Engineering (ECE) Lecture Notes
Electronics & Communication Engineering (ECE) by semester wise and Lab Programs/Manuals-Click here to get

Electronics & Electronics Engineering (EEE) Lecture Notes
Electronics & Electronics Engineering (EEE) lecture notes by semester wise and Lab Programs/Manuals-Click here to get

Mechanical Engineering (MECH) Lecture Notes
Mechanical Engineering (MECH) lecture notes by semester wise and Lab Programs/Manuals-Click here to get

Computer Science Engineering (CSE) Lecture Notes
Computer Science Engineering (CSE) lecture notes by semester wise and Lab Programs/Manuals-Click here to get

Information Technology Lecture Notes
Information Technology lecture notes by semester wise and Lab Programs/Manuals-Click here to get

MCA Lecture Notes
MCA lecture notes by semester wise and Lab Programs/Manuals-Click here to get

Automobile Engineering Lecture Notes
Automobile Engineering lecture notes by semester wise and Lab Programs/Manuals-Click here to get

Aeronautical Engineering Lecture Notes
Aeronautical Engineering lecture notes by semester wise and Lab Programs/Manuals-Click here to get

Bio-Medical Engineering Lecture Notes
Bio-Medical Engineering lecture notes by semester wise and Lab Programs/Manuals-Click here to get

Bio-Technology Lecture Notes
Bio-Technology lecture notes by semester wise and Lab Programs/Manuals-Click here to get

MBA Lecture Notes
MBA lecture notes by semester wise and Lab Programs/Manuals-Click here to get

Hosting by Yahoo!

About-Us    Contact-Us    Site-map

©copyright 2009 All rights are reserved to technicalsymposium.com