Você está na página 1de 2

8/31/13

Share 1

Merge sort program in c


More Next Blog

C programming questions and answers

C language tricky good pointers questions answers and explanation operators data types arrays structures questions functio recursion preprocessors, looping, file handling, strings questions switch case if else printf advance c linux objective types mc faq interview questions and answers with explanation and solution for freshers or beginners. Placement online written test pr numbers Armstrong Fibonacci series factorial palindrome code programs examples on c c++ tutorials and pdf
C tutorial C Programming Questions C Interview Questions C Programs C Test C programming pdf Program of c++ Create projects Sql Server

Search
C QUESTIONS AND ANSWERS

C program examples C interview questions and answers Data type questions Variable naming rule questions Operators questions Control flow questions Switch case questions Looping questions Pointer questions String questions Printf,Scanf questions Preprocessor questions Structure questions Commad line argument C questions in Linux C online test C mixed practice sets C tricky questions Example of recursion in c C programming forums

Merge sort program in c

S o u r c ec o d eo fs i m p l em e r g es o r ti m p l e m e n t a t i o nu s i n ga r r a yi na s c e n d i o r d e ri ncp r o g r a m m i n gl a n g u a g e # i n c l u d e < s t d i o . h > # d e f i n eM A X5 0 v o i dm e r g e S o r t ( i n ta r r [ ] , i n tl o w , i n tm i d , i n th i g h ) ; v o i dp a r t i t i o n ( i n ta r r [ ] , i n tl o w , i n th i g h ) ; i n tm a i n ( ) { i n tm e r g e [ M A X ] , i , n ; p r i n t f ( " E n t e rt h et o t a ln u m b e ro fe l e m e n t s :" ) ; s c a n f ( " % d " , & n ) ; p r i n t f ( " E n t e rt h ee l e m e n t sw h i c ht ob es o r t :" ) ; f o r ( i = 0 ; i < n ; i + + ) { s c a n f ( " % d " , & m e r g e [ i ] ) ; } p a r t i t i o n ( m e r g e , 0 , n 1 ) ; p r i n t f ( " A f t e rm e r g es o r t i n ge l e m e n t sa r e :" ) ; f o r ( i = 0 ; i < n ; i + + ) { p r i n t f ( " % d" , m e r g e [ i ] ) ; } } r e t u r n0 ;

C TUTORIAL

Memory mapping tutorial in c Variables tutorial in c Data types tutorial in c Storage classes tutorial in c Looping tutorial in c Pointers tutorial in c Function tutorial in c Array tutorial in c Preprocessor tutorial in c

v o i dp a r t i t i o n ( i n ta r r [ ] , i n tl o w , i n th i g h ) { i n tm i d ; i f ( l o w < h i g h ) { m i d = ( l o w + h i g h ) / 2 ; p a r t i t i o n ( a r r , l o w , m i d ) ; p a r t i t i o n ( a r r , m i d + 1 , h i g h ) ; m e r g e S o r t ( a r r , l o w , m i d , h i g h ) ; }
1/4

www.cquestions.com/2011/07/merge-sort-program-in-c.html

8/31/13
Advanced c tutorial

Merge sort program in c

} v o i dm e r g e S o r t ( i n ta r r [ ] , i n tl o w , i n tm i d , i n th i g h ) { i n ti , m , k , l , t e m p [ M A X ] ; l = l o w ; i = l o w ; m = m i d + 1 ; w h i l e ( ( l < = m i d ) & & ( m < = h i g h ) ) { i f ( a r r [ l ] < = a r r [ m ] ) { t e m p [ i ] = a r r [ l ] ; l + + ; } e l s e { t e m p [ i ] = a r r [ m ] ; m + + ; } i + + ;

POPULAR POSTS

C program examples Check given number is prime number or not using c program QUICK SORT USING C PROGRAM C interview questions and answers Program to convert decimal to binary in c TO FIND FIBONACCI SERIES USING C PROGRAM Merge sort program in c Write a c program to reverse a string Write a c program to find out sum of digit of given number Find out the perfect number using c program

SUBSCRIBE VIA EMAIL

Enter your email address:

Subscribe

Delivered by FeedBurner

i f ( l > m i d ) { f o r ( k = m ; k < = h i g h ; k + + ) { t e m p [ i ] = a r r [ k ] ; i + + ; } } e l s e { f o r ( k = l ; k < = m i d ; k + + ) { t e m p [ i ] = a r r [ k ] ; i + + ; } } f o r ( k = l o w ; k < = h i g h ; k + + ) { a r r [ k ] = t e m p [ k ] ; }

C PROGRAMMING QUESTIONS AND ANSWER

C questions and answers Debugging questions in c with answers Aptitude questions and answers in c C basic questions Multiple choice questions in c
STANDARD OF QUESTIONS ? Excellent Good Avg Worst Vote Show results

S a m p l eo u t p u t : E n t e rt h et o t a ln u m b e ro fe l e m e n t s :5 E n t e rt h ee l e m e n t sw h i c ht ob es o r t :25091 A f t e rm e r g es o r t i n ge l e m e n t sa r e :01259

Votes so far: 5625 Days left to vote: 834

SUBSCRIBE TO

Posts Comments

1. 2. 3. 4. 5. 6. 7. 8.

Write a c program for bubble sort. Write a c program for insertion sort. Write a c program for selection sort. Write a c program for quick sort. Write a c program for heap sort. Write a c program for merge sort. Write a c program for shell sort. Big list of c program examples
+1 Recommend this on Google

MY HEADLINES

C programming questions and answer C questions and answers Debugging questions in c with answers Aptitude questions and answers in c

7 comments:
Anonymous 1/16/13, 8:36 PM plz give me its algorithm..

www.cquestions.com/2011/07/merge-sort-program-in-c.html

2/4

Você também pode gostar