Answer the question
In order to leave comments, you need to log in
How to write visualization of sorting algorithm in delphi?
It is necessary to visualize the sorting algorithm by the method of simple insertions
Answer the question
In order to leave comments, you need to log in
longclaps wrote how the whole thing should look externally.
Internally this is easy to do.
1. In the OnPaint of some component (PaintBox, say), under certain conditions, we display the visualization.
2. We block the entire user interface (except for some "Stop" button).
3. Every time we need to see something, we do paintBox.Repaint, Application.ProcessMessages and a short delay.
4. When you click the "Stop" button, set some variable to true. The sort reacts to this variable and stops the loop, either with a simple Exit, or with an Abort crash and a subsequent reaction to EAbort.
If you want to compare several sorting algorithms, you should make a function like DoSwap(i, j : integer) that swaps elements, sets everything that is needed for rendering, initiates a redraw and makes a delay.
In the Demos\Threads folder there is an example of rendering three sorts in parallel.
This is a speed comparison.
Or do you need more visibility? Here are examples of dances.
https://forany.xyz/a-370
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question