Skip to content

Commit 3312e18

Browse files
committed
explanation about the recursive Euclid algo to find GCD
1 parent 1d7dd1e commit 3312e18

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

Data Structures/Stacks/InfixToPostfix.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ string InfixToPostfix(string exp)
3535
//pop all with higher precedence
3636
// push low precedence into stack
3737
else if(isOperator(exp[i])) {
38-
while(!S.empty() && S.top()!='(' && checkHighPrecedence(S.top(),exp[i])) {
38+
while(!S.empty() && S.top()!='(' && checkHighPrecedence(S.top(),exp[i]) ) {
3939
postfix += S.top(); //add higher precedence opt to postfix expression
4040
S.pop(); //pop higher precedence opt from stack
4141
}

General Programs/GCD.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ long int GCDRecur(long long int a ,long long int b)
4343

4444
}
4545

46-
cout<<"NUmber of operations to find GCD are "<< count<<endl;
46+
cout<<"NUmber of operations to find GCD are "<< count<<endl;
4747

4848
return a;
4949

@@ -83,7 +83,7 @@ long long int EuclidGCDRecursive(long long int a,long long int b)
8383
if(a!=b)
8484
{
8585

86-
86+
//replace the larger of 2 no(s) by the dfference between it and the smaller number
8787
if(a > b)
8888
return EuclidGCDRecursive(a-b,b);
8989

0 commit comments

Comments
 (0)