Click here to Skip to main content
15,887,267 members
Home / Discussions / Algorithms
   

Algorithms

 
QuestionTriangulation inside a contour Pin
Member 1505866510-Mar-22 1:44
Member 1505866510-Mar-22 1:44 
AnswerRe: Triangulation inside a contour Pin
Gerry Schmitz10-Mar-22 16:27
mveGerry Schmitz10-Mar-22 16:27 
GeneralRe: Triangulation inside a contour Pin
Member 1505866510-Mar-22 20:43
Member 1505866510-Mar-22 20:43 
GeneralRe: Triangulation inside a contour Pin
Gerry Schmitz11-Mar-22 4:05
mveGerry Schmitz11-Mar-22 4:05 
GeneralRe: Triangulation inside a contour Pin
Member 1505866511-Mar-22 19:56
Member 1505866511-Mar-22 19:56 
QuestionWriting a Sorting Algorithm Total points 4 1. Question 1 Assignment overview This assignment is an opportunity for you to develop an algorithm of your own and have someone else execute it to give you feedback on its correctness and specificity. Yo Pin
Ahmed Ehab 20225-Mar-22 3:20
Ahmed Ehab 20225-Mar-22 3:20 
AnswerRe: Writing a Sorting Algorithm Total points 4 1. Question 1 Assignment overview This assignment is an opportunity for you to develop an algorithm of your own and have someone else execute it to give you feedback on its correctness and specificity. Pin
Dave Kreskowiak10-Mar-22 2:59
mveDave Kreskowiak10-Mar-22 2:59 
Questionconcern to shaker sort arlgorithm Pin
Member 1523340925-Jan-22 3:38
Member 1523340925-Jan-22 3:38 
I am currently taking a exercise is the shaker sort algorithm.Instead of separating two for loops, I have included a for-j loop inside a for-i loop. Please check my code.


public static void shakerSort(int array[], int n) 
{
    boolean swapped = true;
    while (swapped) 
    {
         swapped = false;
         for (int i = 0; i < n - 1; i++) 
         {
             if (array[i] > array[i + 1]) 
             {
                    int temp = array[i];
                    array[i] = array[i + 1];
                    array[i + 1] = temp;
                    swapped = true;
             }
                
             if (i == n - 2) 
             {
                 if (!swappped)
                 {
                    break;
                 }
                 else
                 {
                     swapped = false;
                     for (int j = n - 1; j > 0; j--) 
                     {
                          if (array[j - 1] > array[j]) 
                          {
                               int temp = array[j];
                               array[j] = array[j - 1];
                               array[j - 1] = temp;
                               swapped = true;
                          }
                     }
                     if (!swapped) 
                     {
                       break;
                     }
                 }     
             }
        }
    }



Output:

   -5
   -3
    5 
    9 
   11 
   12
   15
   18 


I hope you can rate my code .Thank you very much 

AnswerRe: concern to shaker sort arlgorithm Pin
Richard Andrew x6410-Feb-22 9:27
professionalRichard Andrew x6410-Feb-22 9:27 
QuestionVerification Algorithm that mortals can use to verify chain of discussion making. Pin
XxKeldecknightxX7-Jan-22 1:45
XxKeldecknightxX7-Jan-22 1:45 
AnswerRe: Verification Algorithm that mortals can use to verify chain of discussion making. Pin
Eddy Vluggen9-Feb-22 1:56
professionalEddy Vluggen9-Feb-22 1:56 
AnswerRe: Verification Algorithm that mortals can use to verify chain of discussion making. Pin
Eddy Vluggen9-Feb-22 12:06
professionalEddy Vluggen9-Feb-22 12:06 
QuestionWildcard Matching Routine Pin
Richard Andrew x6424-Dec-21 9:17
professionalRichard Andrew x6424-Dec-21 9:17 
AnswerRe: Wildcard Matching Routine Pin
Gerry Schmitz25-Dec-21 5:24
mveGerry Schmitz25-Dec-21 5:24 
GeneralRe: Wildcard Matching Routine Pin
Richard Andrew x6425-Dec-21 6:09
professionalRichard Andrew x6425-Dec-21 6:09 
GeneralRe: Wildcard Matching Routine Pin
Gerry Schmitz25-Dec-21 8:25
mveGerry Schmitz25-Dec-21 8:25 
AnswerRe: Wildcard Matching Routine Pin
k505425-Dec-21 7:16
mvek505425-Dec-21 7:16 
GeneralRe: Wildcard Matching Routine Pin
Richard Andrew x6426-Dec-21 1:32
professionalRichard Andrew x6426-Dec-21 1:32 
AnswerRe: Wildcard Matching Routine Pin
englebart8-Feb-22 16:36
professionalenglebart8-Feb-22 16:36 
GeneralRe: Wildcard Matching Routine Pin
trønderen9-Feb-22 6:35
trønderen9-Feb-22 6:35 
GeneralRe: Wildcard Matching Routine Pin
englebart9-Feb-22 15:37
professionalenglebart9-Feb-22 15:37 
GeneralRe: Wildcard Matching Routine Pin
Eddy Vluggen9-Feb-22 16:10
professionalEddy Vluggen9-Feb-22 16:10 
GeneralRe: Wildcard Matching Routine Pin
trønderen10-Feb-22 6:03
trønderen10-Feb-22 6:03 
GeneralRe: Wildcard Matching Routine Pin
englebart10-Feb-22 9:14
professionalenglebart10-Feb-22 9:14 
QuestionTime Complexity of following method? Pin
Member 1269110623-Nov-21 4:09
Member 1269110623-Nov-21 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.