| New Reply |
merge sort help |
Share Thread | Thread Tools |
| Sep11-12, 01:11 PM | #1 |
|
|
merge sort help
please help me with a c code for the merge sort...... and i am getting a segmentation fault in running this selection sort,,, please help......
#include <stdio.h> int main( ) { int arr[10]; int i,j,temp; for ( i = 0 ; i<10 ; i++ ) { printf("enter the numbers: \n"); scanf("%d \n", arr[i]); } for ( i = 0 ; i <8 ; i++ ) { for ( j = i + 1 ; j <9 ; j++ ) { if ( arr[i] > arr[j] ) { temp = arr[i] ; arr[i] = arr[j] ; arr[j] = temp ; } } } for ( i = 0 ; i <10 ; i++ ) printf("the sorted array is: %d \n", &arr[i]); return 0; } |
| PhysOrg.com |
science news on PhysOrg.com >> Hong Kong launches first electric taxis >> Morocco to harness the wind in energy hunt >> Galaxy's Ring of Fire |
| Sep11-12, 01:41 PM | #2 |
|
Recognitions:
|
|
| Sep11-12, 11:58 PM | #3 |
|
Recognitions:
|
You probably wanted those loops to be ... ; i < 9; ... and ... ; j < 10; .... Also this algorithm is not a merge sort, it's a bubble (down) sort.
|
| New Reply |
| Thread Tools | |
Similar Threads for: merge sort help
|
||||
| Thread | Forum | Replies | ||
| Merge sort | Programming & Comp Sci | 1 | ||
| merge sort | Engineering, Comp Sci, & Technology Homework | 1 | ||
| K-way merge sort | Engineering, Comp Sci, & Technology Homework | 0 | ||
| Merge sort with array of structs | Engineering, Comp Sci, & Technology Homework | 6 | ||