| | |
Merge sort or an alternative..
![]() |
•
•
Join Date: Nov 2009
Posts: 4
Reputation:
Solved Threads: 0
Hi there guys,
So I have two arrays, and each arrays got 5 elements (integers). My goal is to to arrange the elements of each of those arrays in a descending order and save them in a new array.
I started off with bubble sorting each of those arrays and rearranging the elements in a descending sequence. It just seemed reasonable to start with that.
However now, I have to merge those two arrays. I thought it'd be wise to create a new empty array with a size big enough to contain all the elements, but I can't figure out for the life me how to arrange them in a descending order while merging them.
I know I could just transfer all the elements to the new array and then bubble sort it but that seems tedious. Any ideas?
Thanks in advance.
So I have two arrays, and each arrays got 5 elements (integers). My goal is to to arrange the elements of each of those arrays in a descending order and save them in a new array.
I started off with bubble sorting each of those arrays and rearranging the elements in a descending sequence. It just seemed reasonable to start with that.
However now, I have to merge those two arrays. I thought it'd be wise to create a new empty array with a size big enough to contain all the elements, but I can't figure out for the life me how to arrange them in a descending order while merging them.
I know I could just transfer all the elements to the new array and then bubble sort it but that seems tedious. Any ideas?
Thanks in advance.
0
#2 21 Days Ago
In my opinion, creating merging the arrays and then sorting the merged array isn't a bad idea because it's simple. But that depends on what you seek - performance or simplicity. Everything is possible to code but depends on your experience and the amount of time to spend doing it.
By the way, I doubt sorting and merging at the same time would be a lot faster than merging and then sorting.
That's just my opinion - accept it or not.
edit: Separated merging could save you some lines of code when implementing other sorting algorithms.
By the way, I doubt sorting and merging at the same time would be a lot faster than merging and then sorting.
That's just my opinion - accept it or not.
edit: Separated merging could save you some lines of code when implementing other sorting algorithms.
Last edited by venomxxl; 21 Days Ago at 1:47 pm.
![]() |
Similar Threads
- Merge and sort 2 linked lists (Pascal and Delphi)
- merge sort (C++)
- Merge Sort on a Array-Based List (C++)
- Merge sort not working (C++)
- Merge Sort (C)
- hw assignment help on selection & merge sort (C)
- Merge sort (C++)
Other Threads in the C Forum
- Previous Thread: Reading from the Command line
- Next Thread: Message Queue Error
| Thread Tools | Search this Thread |
#include * ansi array arrays asterisks binarysearch calculate centimeter changingto char character convert copyanyfile copyimagefile copypdffile creafecopyofanytypeoffileinc createprocess() database dynamic execv fflush fgets file floatingpointvalidation fork forloop function getlogicaldrivestrin givemetehcodez grade gtkwinlinux histogram homework i/o ide inches include infiniteloop input interest intmain() iso keyboard km license linked linkedlist linux list looping lowest matrix meter microsoft mysql number oddnumber open opendocumentformat openwebfoundation pdf pointer posix power probleminc process program programming pyramidusingturboccodes radix read recursion recv recvblocked research reversing scheduling segmentationfault send sequential single socket socketprogramming stack standard strchr string suggestions systemcall test threads turboc unix urboc user variable whythiscodecausesegmentationfault win32api windowsapi





