Problem in MergeSort i need it in 1 Hour :-(
Hallo,
im trying to implement a Mergesort with test methode but the problem i can not start the code, i need help to solve this problem, that would be perfekt if i get that in 1 hour, i have to give the Answer to my Teacher!
hier ist my code:
public class MergeS
static void msort (int[] array, int le, int ri)
int i, j, k;
int [] b = new int [array.length];
if (ri > le) {
// zu sortierendes Feld teilen
int mitte = (ri + le) / 2;
// teilfelder sortieren
msort (array, le, mitte);
msort (array, mitte + 1, ri);
//Hilfsfeld aufbauen
for (k = le; k <= mitte; k++)
b[k] = array[k];
for (k = mitte; k < ri; k++)
b[ri + mitte - k] = array[k+1];
// Ergebnisse mischen ?ber Hilfsfeld b
i = le;
j = ri;
for (k = le; k <= ri; k++)
if(b[i] < b[j])
array[k] = b[i++];
else
array[k] = b[i--];
static void mergeSort (int[] array) {
msort(array, 0, array.length - 1);
public static void main(String[] args)
int i;
int [] a;
int idx = AdvancedIO.readInt();
System.out.println("the Number of the Elements in the Array: " +idx);
a = new int[idx];
for (i = 0; i <= idx - 1; i++){
a = AdvancedIO.readInt();
System.out.println("Element with Index" + i + "Enter: " + a [i]);
SortierenA sArray = new SortierenA();
sArray.mergeSort(a);
System.out.print ("the Sorted Array is: " );
for (i=0; i <= idx -1; i++){
System.out.print (a[i]);
thank u very much!
the problem is solved, and about the merge part its was incorrect, thank u very much, owith out ur help, i could never find my mistake, hier ist the correct code:
public class MergeS
static void msort (int[] array, int le, int ri)
int i, j, k;
int [] b = new int [array.length];
if (ri > le) {
// zu sortierendes Feld teilen
int mitte = (ri + le) / 2;
// teilfelder sortieren
msort (array, le, mitte);
msort (array, mitte + 1, ri);
//Hilfsfeld aufbauen
for (k = le; k <= mitte; k++)
b[k] = array[k];
for (k = mitte; k < ri; k++)
b[ri + mitte - k] = array[k+1];
// Ergebnisse mischen ?ber Hilfsfeld b
i = le;
j = ri;
for (k = le; k <= ri; k++)
if(b[i] < b[j])
array[k] = b[i++];
else
array[k] = b[j--];
static void mergeSort (int[] array) {
msort(array, 0, array.length - 1);
public static void main(String[] args)
int i;
int [] a;
System.out.println("the Number of the Elements in the Array: " );
int idx = AdvancedIO.readInt();
//System.out.println(idx);
a = new int[idx];
for (i = 0; i <= idx - 1; i++){
System.out.println("the Element with Index - " + i + " should be ");
a = AdvancedIO.readInt();
//System.out.println(a[i]);
MergeS sArray = new MergeS();
sArray.mergeSort(a);
System.out.print ("the Sorted Array is: " );
for (i=0; i <= idx -1; i++){
System.out.print (a[i]);
Similar Messages
-
I've had MS Office:mac 2011 on my imac for around 18 months now. Outlook has just disappeared and when I find the file and open it it tells me that there is a problem and I may need to re-install it. I've just done this using the installation disc which, then said the installation had been successful.
Outlook is still not working. Can anyone please advise me on what to do next.Remove MS Office 2011 completely (here are instructions) and reinstall it.
It's not a simple or fast process but it is important to follow all of the steps in order to get all the files that Office scatters around. This will not affect your data files, only MS Office and its preferences. -
My daughter has spitefully changed my password and has refused to tell me. I have so much medical information that I can not lose. Is there anyway to get around this problem. Please I need Help fast.
Connect the iPod to your syncing computer and restore it via iTunes. However, if iTunes asks for the unknown passcode you need to place the iPod in recovery mode and then restore the iPod from backup. For recovey mode see:
iPhone and iPod touch: Unable to update or restore
"If you cannot remember the passcode, you will need to restore your device using the computer with which you last synced it. This allows you to reset your passcode and resync the data from the device (or restore from a backup). If you restore on a different computer that was never synced with the device, you will be able to unlock the device for use and remove the passcode, but your data will not be present. Refer to Updating and restoring iPhone and iPod touch software."
Above is from:
http://support.apple.com/kb/ht1212 -
Hi,
A few songs from my old purchase is not available for download. It shows as purchased but I can't download it. Please help me resolve this problem, what do I need to do to enable download for all my purchased songs/movies etc.
- AvinashThe purchases are probably hidden:
http://support.apple.com/kb/ht4919 -
i dont remember the first apple id that link with my clash of clans apps. the problem now is i need to link my COC village and it keep saying "please log in with correct game center" is there anyway that i can retrieve my old apple id? please help me i dont want to lose my village, i have spent my money on that game to much. hmmm
thanks mate, but the problem is im using different apple id now, and after about 1 year play coc and today i want to link the village , suddenly coc said that
thats mean im playing this village with different apple id and it not saved. and the problem is i dont remember the first apple id and password that i use first time to download this game. hmmm it was so confusing, why coc and game center just make this thing saved with a new game center account. -
my ipad mini is stil in warranty, but my software has some problem, if format it need to pay?
Restoring the iPad can be done by the owner and doesn't involve or affect the device's warranty. It's free.
(107649) -
My iPad2 went blank. Troubleshooter says driver software MTP USB problem, what do I need to do?
iOS: Resolving update and restore alert messages
For error -50: See error 13 and 14:
Error 13 and 14: These errors are typically resolved by performing one or more of the steps listed below:
Perform USB isolation troubleshooting, including trying a different USB port directly on the computer. See the advanced steps below for USB troubleshooting.
Put a USB 2.0 hub between the device and the computer.
Try a different USB 30-pin dock-connector cable.
Eliminate third-party security software conflicts.
There may be third-party software installed that modifies your default packet size in Windows by inserting one or more TcpWindowSize entries into your registry. Your default packet size being set incorrectly can cause this error. Contact the manufacturer of the software that installed the packet-size modification for assistance. Or, follow this article by Microsoft: How to reset Internet Protocol (TCP/IP) to reset the packet size back to the default for Windows.
Connect your computer directly to your Internet source, bypassing any routers, hubs, or switches. You may need to restart your computer and modem to get online.
Try to restore from another known-good computer and network. -
TS1702 hello, i have problem to open the need for speed2
hello, i have problem to open the need for speed2
There is no "Add-on" that I'm aware that will allow you to EDIT .pdf files for FREE. Editing .pdf is using a Paid Feature in pdf programs (Adobe Acrobat ProX & FoxIT PDF.)
[http:// https://addons.mozilla.org/en-US/firefox/addon/pdfescape-extension/ PDFEscape] is "Add-on" in a sense, but it actually just opens the .pdf file on PDFEscape.com -
I want to perform bidirectional i/o using a pci-6534.The problem is that i need to use the same lines for i/p and o/p. is that possible? And if it is how an i doing this?
Hi I Pant,
The idea that crossed my mind was to tie each of the lines coming from/going to "your device" to two of the DIO lines. Configure one these two ports as input, the other as output.
When you want to read the state of the line, read from the line configured as input. Similarly, use the other port when it is time to write.
Provided "your device" uses tri-state drivers/receivers, or can be used in a "wired-OR" configuration, this may work.
What is "your device"?
Ben
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction -
Any advice on Airport solving our second and third floor WIFI connectivity problems welcomed, do we need sattelite stations, ?? do not mind buying the system if it works?
......will the Apple Airport solve the problem?
The broadcast power of all wireless routers is controlled by law, so as you might imagine, devices from varying manufactureres tend to perform about the same. It is very unlikely that an Apple AirPort router would perform significantly better...or worse...than the Linksys device that you have now.
do we need satttelite stations?
Yes, probably at least one per floor and possibly more, depending on the thickness of the walls in the areas where a wireless signal will be needed. Since you already have a Linksys router, and it is always best to use products from the same manufacturer on a wireless network, it would probably make sense to check with Linksys to see what they suggest as additions to your current router.
It would be a excellent idea to have an IT professional come out and survey the house and take some measurements with test equipment to propose a system that is right for your needs. That will likely save a lot of headaches (and money) down the road. -
My mac has started displaying a message stating "You need to restart your computer". Web says it's kind of kernel panic! Is this a hardware problem? Do i need to contact my distributor? please help..it annoys me very much..
Hello welcome to the ASC user to user forums
please see these support documents
http://support.apple.com/kb/TS2570
http://support.apple.com/kb/TS1440
http://support.apple.com/kb/HT1455
http://support.apple.com/kb/ht3964
http://support.apple.com/kb/HT1379
http://support.apple.com/kb/ht1379
http://support.apple.com/kb/HT1509 -
burner not working, 8.98 GB free, can this 2003/2004 imac model be cleaned for better use or will I continue to have problems? Do I need to just buy a new one? I remember with a PC being able to defrag.
You could buy an external dvd/cd drive.
Suggest other world computing.
You need to delete some files. Many posters to these forums state that you need much more free space: 5 gig to 10 gig or 10 percent of you hd size.
(0)
Be careful when deleting files. A lot of people have trashed their system when deleting things. Place things in trash. Reboot & run your applications. Empty trash.
Go after large files that you have created & know what they are. Do not delete small files that are in a folder you do not know what the folder is for. Anything that is less than a megabyte is a small file these days.
(1)
Run
OmniDiskSweeper
"The simple, fast way to save disk space"
OmniDiskSweeper is now free!
http://www.omnigroup.com/applications/omnidisksweeper/download/
This will give you a list of files and folders sorted by size. Go after things you know that are big.
(2)
This will save you a gig of space.
Monolingual is a program for removing unnecessary language resources from Mac OS X,in order to reclaim several hundred megabytes of disk space. It requires at least Mac OS X 10.3.9 (Panther) and also works on Mac OS X 10.4 (Tiger). It worked for me on 10.4
http://monolingual.sourceforge.net/
A detailed write-up on how to use Monolingual:
http://www.jklstudios.com/misc/monolingual.html
(3)
These pages have some hints on freeing up space:
http://thexlab.com/faqs/freeingspace.html
http://www.macmaps.com/diskfull.html
(4)
Buy an external firewire harddrive.
(5)
Buy a flash card. -
I am having same problem with apple tv need 4.4 version and can not find solution this a brand new product out of box yesterday why would it not already have updated version. I am getting frustrated that I can not get this mirroring icon to work. I have tried all suggestions in this thread and nothing works. I also hooked up to laptop through iTunes with micro USB nothing!!!
The new appletv software came out 2 or 3 days ago, how would Apple get it on the device in the box in a store?
Why don't ou update the appletv software? -
I still am having problems with Aperture not loading, It just refuses to work, and I get the message saying it has encountered a problem, and I may need to re-install which I have done dozens of times. The fix mentioned on an earlier post doesn't work as it is for Ver 10.6.6 and I am running 10.6.7
Do you have Final Cut installed on your machine?
If so, you may want to look at this article: http://support.apple.com/kb/TS3528
Let us know if that helps. -
i've just downloaded facetime and every tie I attempt to open it I get the message"there was a problem with facetime you need to quit and reopen facetime" I've tried this but I just get the same message again and again
Hello tadom,
Thanks for the question. The following article outlines the exact error message you described, and a potential resolution:
OS X: "An internal FaceTime error occurred" alert after clicking Facetime icon in the Dock
http://support.apple.com/kb/TS4457
Thanks,
Matt M
Maybe you are looking for
-
Very odd and very large file found in system library: maremoted
Hello, Using a single 1.25 G4 with 10.3.9. It's been acting up and running out of space. We located a file called maremoted, (which we're guessing is some kind of Remote Daemon), fil, which is upwards of 30 GB. It's run by the root user and trying to
-
HELP....AVCHD / MPEG files not playing correctly!
I have been trying to download video that was shot with the new Sony FS100 camera that I'm told are AVCHD or MPEG files to my older Adobe Premiere Pro 1.5 timeline, but they are not playing correctly. When I reverse the field dominance, the image pla
-
Order By clause problem with ENAME and Rownum?
From Scott/Tiger user I run this query from EMP table. select rownum,EMPNO,ENAME,JOB from emp order by Ename; Output is like this ROWNUM EMPNO ENAME JOB 11 11 ADAMS CLERK 2 2 ALLEN SALESMAN 6 6 BLAKE MANAGER 7 7
-
Problem with rotate (Win 10)
For some reason, my Yoga 2 Pro refuses to get back into the 'normal' rotation (NOT upside-down or sideways). I've tried disabling ymg in services (no effect), I've tried with the ctrl-alt combo (all of them work perfectly, EXCEPT for the ctrl-alt-UP
-
Using native Logic OSC support with 3rd party plug-ins & new touchOSC maps
Hi All. Now that logic from 9.1.2 has native OSC support, I wandered if anyone has used it succesfully with their own customised touchOSC maps? I'm not so interested in using touchsc as a transport/mixer for logic - which is what the default logic ma