Category : stack

So, the goal is to have the queue and stack check if the string is a palindrome. I believe the problem occurs in the while loop. void isPalindrome(stack<char> &myStack, queue<char>& myQueue, string word) { bool palindrome=true; while(palindrome == true &&(!myStack.empty()) && (!myQueue.empty())) { if(myStack.top() != myQueue.front()) { cout << myStack.top() << ", " << myQueue.front()<<endl; ..

Read more

I wrote a programme to convert infix expression into postfix but with this lines of code my programme exit without showing any output. while((precedence(infix[i])<=precedence(s.top())) && (!s.empty())) { postfix+=s.top(); s.pop(); } About code—> here s is the object of stack and precendence is a function which return 3 for ^ 2 for * and / 1 ..

Read more

i just want help in InfixToPostfix function and in prcd function. and i’m way too cloose from changing my department thank you int InfixToPostfix() { int i=0; char topSymb; stack s1; top(&s1); char string[100]; cout<<"enter a function"; cin>>string; int size=0; while (string[i]!=0) { size+=1; i++; } char Result[100]; for (i=0;i<size;i++) { if ( string[i] >=’a’ ..

Read more

I getting a (sigsegv) error, even I used long long int, can anyone tell me, what I am missing here? Definition – Find Next greater number Link of my code Code :- #include<bits/stdc++.h> using namespace std; int main() { int T; cin>>T; while(T–) { ios_base::sync_with_stdio(false); cin.tie(NULL); long long int n; int c,d,e,i; cin>>n; long long ..

Read more