Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Wie funktioniert das Sortierverfahren Bubble-sort und Quick-Sort? Wie kann man es in einem Programm darstellen. Habe zwar schon hier einige Beispiele gelesen und auch im Internet nachgeschaut, habe jedoch noch nicht so das passende gefunden. Die Quellcodes sahen immer sehr kompliziert aus. Hoffe, mir kann jemand die Verfahren an einem einfachen Quellcode zeigen oder sonst irgendwie erklären

Hallo,

zu beiden Algorithmen findet man mehr als genug Beispiele mit ausführlichen Erklärungen im Netz:

Bubble-Sort:

http://www.metalshell.com/view/source/105/

http://www.cs.princeton.edu/~ah/alg_anim/gawain-4.0/BubbleSort.html (<--- schönes Beispiel mit Visualisierung als Applet)

http://www.dei.isep.ipp.pt/~lpinho/disciplinas/prog_c/c4.html

Quick-Sort:

http://www.geocities.com/ResearchTriangle/Facility/3634/cp_wf.htm

http://www.cs.princeton.edu/~ah/alg_anim/gawain-4.0/QuickSort.html (s.o.)

Quicksort ist auch im K&R erklärt.

Nic

Vielen Dank für deine Links. Zu Bubble-Sort habe ich etwas gefunden. Nur das mit Quicksort verstehe ich nicht, habe da auch nichts auf deinen Seiten gefunden, da die nicht funktionierten.

Wäre dir dankbar, wenn du mir quicksort näher erklären könntest. Was ist denn das K&R?

Das mit dem Bubblesort hat funktioniert, aber das mit Quicksort bekomme ich gar nicht hin. Habe mal den Quellcode mitgeschickt. Dort ist das Bubblesort-Verfahren programmiert, wie kann ich dort Quicksort mit einbinden und wie lautet da der Quellcode. Komme da nicht weiter.

Teil von Quellcode für Bubblesort:

for (x=0; x < MAX-1; x=x+1)

for (y=0; y < MAX-x-1; y=y+1)

if (a[y] > a[y+1])

{

t=a[y];

a[y]=a[y+1];

a[y+1]=t;

}

printf("\n\nHier sind die Zahlen in sortierter Reihenfolge!\n");

printf("\n\n");

for (i=0; i < MAX; i=i+1)

printf("%d\n",a);

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.