Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rohittcodes/data-structures
https://github.com/rohittcodes/data-structures
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/rohittcodes/data-structures
- Owner: rohittcodes
- Created: 2024-02-03T12:44:58.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-03T12:46:14.000Z (about 1 year ago)
- Last Synced: 2025-01-28T20:15:10.695Z (13 days ago)
- Language: C++
- Size: 78.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
*+-/*326414
1. Iterate through the end of string
2. Check if the string char is a number or an operator. Make the char a number by using ascii and then push.
If it's an operator pop top two numbers from stack and perform the operation using switch cases and push the result.
3. If the string ends then just display the result you got.1. Iterate through the end of string
2. Check if the string1. If operand print it
2. If '(' then push on to stack
3. If operator, check precedence and if the precedence is higher than the top, push it else pop out the1. If operand print it
2. If '(' then push onto stack
3. If operator, check precendence and if the precedence is higher than the top, push it else pop until the stack becomes empty ir the top element gas kess precedence.
4. If ')' then check the top od the stack and keep poppinf it unless you don't encounter '('. pop out the ( and repeat the process.
Once you reach at the end of the string pop out everything from the stack.
Examples:
Infix: (a+b)/((c*d)-e) || postfix: ab+cd*e-/
Infix: (a-b)/(c+d)-e || postfix: ab-cd+\*e-
Infix: (a/b)/(c+d)-(e+f) || postfix: ab/cd+ef+-/Example: (a-b/c)\*(a/k-l)
1. Reverse the string
2. Convert the ')' to '('and vice versa (l-k/a)\*(c/b-a)
3. Repeat the algo for postfix
4. Reverse the answer.Use two stacks
1. Empty all elements from s1 to s2
2. Push the new element to s1
3. Pop each element from s2 and push it into s1
4. To print or dequeue, pop out every element from s1Use two empty stacks
1. Pop all the elements from s1 and push it in s2
2. Pop all the elements from s2