简体   繁体   English

使用C ++中的图形对排序算法进行可视化跟踪?

[英]Visual trace of sorting algorithms using a graph in C++?

I am in an Intro to data structures class and we are currently going over sorting algorithms. 我正在介绍数据结构课程,目前正在研究排序算法。 Is there any way in C++ to use a graph to trace the exchanging and sorting of sorting algorithms? C ++中有什么方法可以使用图来跟踪排序算法的交换和排序? There is an image illustrating shell sort if you follow this link and scroll down a bit. 如果您单击此链接并向下滚动一点,则有一个图像说明了外壳排序。 I also linked it down below. 我也将其链接到下面。 (Essentially what I would like to achieve). (基本上是我想要实现的目标)。 Addison Wesley, Algorithms 4th edition: http://algs4.cs.princeton.edu/21elementary/ . Addison Wesley,《算法》第4版: http//algs4.cs.princeton.edu/21elementary/

They spoke about using built in functions in Java to create the graph and spoke about it as if it is rather trivial. 他们谈到使用Java中的内置函数来创建图形,并谈到它似乎微不足道。 I'm assuming if its basic in Java its basic in C++. 我假设它是Java的基础还是C ++的基础。

Question being, how would I implement a function that would correspond numerically to how big the bars are and output the graph pre-sort, mid-sort and post-sort? 问题是,我将如何实现一个与数字大小对应的函数,并输出图形的预排序,中排序和后排序?

Note: I have intermediate level C++ knowledge and no experience with graphics. 注意:我具有中级C ++知识,并且没有图形方面的经验。

在此处输入图片说明

Consider using a graphing package such as gnuplot . 考虑使用诸如gnuplot之类的图形软件包。 You would have to use it to plot, say as bar graphs, the array values your program is trying to sort. 您将不得不使用它来绘制(例如条形图)程序尝试排序的数组值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM