Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 如何降低后续算法中图形绘制的复杂性? 我正在绘制一个不断刷新的图形 阿尔戈 Pmin=绘制图形线的起点 pmax=绘制图形线的终点 THpixel=总水平像素; TVpixel=总垂直像素; 伪码 循环hpixel_Algorithm_Data Structures - Fatal编程技术网

Algorithm 如何降低后续算法中图形绘制的复杂性? 我正在绘制一个不断刷新的图形 阿尔戈 Pmin=绘制图形线的起点 pmax=绘制图形线的终点 THpixel=总水平像素; TVpixel=总垂直像素; 伪码 循环hpixel

Algorithm 如何降低后续算法中图形绘制的复杂性? 我正在绘制一个不断刷新的图形 阿尔戈 Pmin=绘制图形线的起点 pmax=绘制图形线的终点 THpixel=总水平像素; TVpixel=总垂直像素; 伪码 循环hpixel,algorithm,data-structures,Algorithm,Data Structures,您可以从此算法中删除2个循环 阿尔戈 伪码 Pmin = starting point of drawing graph line pmax = ending point of drawing graph line THpixel = Total Horizontal pixel; TVpixel = Total Vertical pixel; loop hpixel在您的算法中,您希望重置整个图形(包括线条和背景)的颜色,这会导致O(n*m) 相反,在绘制新线(或通常的图形)之前,只需将属

您可以从此算法中删除2个循环

阿尔戈

伪码

Pmin = starting point of drawing graph line
pmax = ending point of drawing graph line

THpixel = Total Horizontal pixel;
TVpixel = Total Vertical pixel;

loop hpixel在您的算法中,您希望重置整个图形(包括线条和背景)的颜色,这会导致O(n*m)

相反,在绘制新线(或通常的图形)之前,只需将属于上一个图形的像素设置为背景色
将整个窗口重置为背景色
接下来,你只需要在上面画我们的新图表。
现在,您的复杂性取决于图形上的像素数。
示例:如果您只需要刷新一行:一行需要最大THpixel+TVpixel(对角线)
=>复杂性是O(THpixel+TVpixel),而不是O(THpixel*TVpixel)

是的,您是对的,但在最坏的情况下,即pmin=0 pmax=TVpixel,现在当前图形点也相同。然后我们拖了两次。
Pmin = starting point of drawing graph line
pmax = ending point of drawing graph line

THpixel = Total Horizontal pixel;
TVpixel = Total Vertical pixel;
loop hpixel <= THpixel
{
    // use this method if there is a way to draw this without walking through Box pixels
    // the walking will bring complexity of algorithm again to O(n)
    drawBox(THpixel,TVpixel,backgroungColor);// this is drawing box with background color
    // if there is no way to draw Box, you can remember the last data of graph and when
    //you want to refresh just redraw last graph with background color and draw new one with graph color, so the first step(when 1st time drawing) will took O(mxn) time and the following steps will took O(n) time

    //drawing min to max line
    loop min < Vpixel < pmax
    {
        draw Vpixel  with graph color
        Vpixel = Vpixel  + 1;
    }

    hpixel = hpixel + 1;

}
Instead, before drawing new line (or graph in general), you just need to set the pixel belonging to previous graph to background-color 
<=> reset whole window into background-color

Next, you just need to draw our new graph on. 
Now your complexity depends on the number of pixel lying on your graph.