@@ -22,16 +22,59 @@ public abstract class AlgorithmBase
2222 public abstract int elementCount { get ; set ; }
2323 public abstract void BeginAlgorithm ( int [ ] elements ) ;
2424
25- protected void ShowCompletedDisplay ( Graphics graphics , int maxWidth , int maxHeight , int [ ] elements , int threadDelay )
25+ public void ShowCompletedDisplay ( int [ ] elements )
2626 {
27- FormattingDisplay formatDisplay = new FormattingDisplay ( ) ;
27+ ShowAllGreen ( elements ) ;
28+ }
29+
30+ private void ShowAllGreen ( int [ ] elements )
31+ {
32+ if ( threadDelay == 200 )
33+ {
34+ threadDelay = 80 ;
35+ }
36+ else if ( threadDelay == 0 )
37+ {
38+ threadDelay = 1 ;
39+ }
40+
41+ for ( int i = 0 ; i < elements . Length ; i ++ )
42+ {
43+ graphics . FillRectangle ( new SolidBrush ( Color . FromArgb ( 83 , 153 , 182 ) ) , i * maxWidth , maxHeight - elements [ i ] , maxWidth , elements [ i ] ) ;
44+ Thread . Sleep ( threadDelay ) ;
45+ }
46+ }
2847
29- formatDisplay . ShowAllGreen ( graphics , maxWidth , maxHeight , elements , threadDelay ) ;
48+ public void SetComplexity ( int complexityRangeValue )
49+ {
50+ switch ( complexityRangeValue )
51+ {
52+ case 0 :
53+ timeComplexity = "O(nLog(n))" ;
54+ spaceComplexity = "O(1)" ;
55+ break ;
56+ case 1 :
57+ timeComplexity = "O(nLog(n))" ;
58+ spaceComplexity = "O(Log(n))" ;
59+ break ;
60+ case 2 :
61+ timeComplexity = "O(nLog(n))" ;
62+ spaceComplexity = "O(n)" ;
63+ break ;
64+ case 3 :
65+ timeComplexity = "O(nk)" ;
66+ spaceComplexity = "O(n+k)" ;
67+ break ;
68+ case 4 :
69+ timeComplexity = "O(n²)" ;
70+ spaceComplexity = "O(1)" ;
71+ break ;
72+ }
3073 }
3174
3275 protected void SwapElements ( int index1 , int index2 , int [ ] elements , int sortType )
3376 {
34- switch ( sortType )
77+ switch ( sortType )
3578 {
3679 case 0 :
3780 graphics . FillRectangle ( new SolidBrush ( Color . DarkRed ) , index1 * maxWidth , maxHeight - elements [ index1 ] , maxWidth , elements [ index1 ] ) ;
@@ -58,7 +101,7 @@ protected void SwapElements(int index1, int index2, int[] elements, int sortType
58101 elements [ index1 ] = elements [ index2 ] ;
59102 elements [ index2 ] = tempValue ;
60103
61- switch ( sortType )
104+ switch ( sortType )
62105 {
63106 default :
64107 graphics . FillRectangle ( new SolidBrush ( Color . Black ) , index1 * maxWidth , maxHeight - elements [ index1 ] , maxWidth , elements [ index1 ] ) ;
@@ -68,11 +111,11 @@ protected void SwapElements(int index1, int index2, int[] elements, int sortType
68111 graphics . FillRectangle ( new SolidBrush ( Color . DarkRed ) , index1 * maxWidth , maxHeight - elements [ index1 ] , maxWidth , elements [ index1 ] ) ;
69112 graphics . FillRectangle ( new SolidBrush ( Color . Black ) , index2 * maxWidth , maxHeight - elements [ index2 ] , maxWidth , elements [ index2 ] ) ;
70113
71- if ( GetType ( ) . Name . Contains ( "Selection" ) )
114+ if ( GetType ( ) . Name . Contains ( "Selection" ) )
72115 {
73116 Thread . Sleep ( threadDelay ) ;
74117 }
75-
118+
76119 graphics . FillRectangle ( new SolidBrush ( Color . Black ) , index1 * maxWidth , maxHeight - elements [ index1 ] , maxWidth , elements [ index1 ] ) ;
77120 break ;
78121 case 2 :
0 commit comments