dsa5
dsa5
Code
#include <iostream>
#include <stack>
#include <string>
// Node definition
struct Node {
char val;
Node* left;
Node* right;
};
bool isOperator(char c) {
stack<Node*> st;
if (isOperator(c)) {
st.push(node);
if (!root) return;
s1.push(root);
while (!s1.empty()) {
s2.push(node);
if (node->left) s1.push(node->left);
if (node->right) s1.push(node->right);
while (!s2.empty()) {
s2.pop();
}
if (!root) return;
stack<Node*> st;
st.push(root);
while (!st.empty()) {
if (node->left) st.push(node->left);
if (node->right) st.push(node->right);
delete node;
// Main function
int main() {
postOrderNonRecursive(root);
deleteTree(root);
return 0;