原文:算法爱好者
(点击上方蓝字,快速关注我们)
作者:伯乐在线 - iPytLab
如有好文章投稿,请点击 → 这里了解详情
前言
原文:算法爱好者
(点击上方蓝字,快速关注我们)
作者:伯乐在线 - iPytLab
如有好文章投稿,请点击 → 这里了解详情
前言
| /* Binary Tree Traversal - Preorder, Inorder, Postorder */ | |
| #include<iostream> | |
| using namespace std; | |
| struct Node { | |
| char data; | |
| struct Node *left; | |
| struct Node *right; | |
| }; |
| /* Binary tree - Level Order Traversal */ | |
| #include<iostream> | |
| #include<queue> | |
| using namespace std; | |
| struct Node { | |
| char data; | |
| Node *left; | |
| Node *right; | |
| }; |
| /* | |
| Evaluation Of postfix Expression in C++ | |
| Input Postfix expression must be in a desired format. | |
| Operands must be integers and there should be space in between two operands. | |
| Only '+' , '-' , '*' and '/' operators are expected. | |
| */ | |
| #include<iostream> | |
| #include<stack> | |
| #include<string> |
| /* Queue - Circular Array implementation in C++*/ | |
| #include<iostream> | |
| using namespace std; | |
| #define MAX_SIZE 101 //maximum size of the array that will store Queue. | |
| // Creating a class named Queue. | |
| class Queue | |
| { | |
| private: | |
| int A[MAX_SIZE]; |
| // Stack - Array based implementation. | |
| // Creating a stack of integers. | |
| #include<stdio.h> | |
| #define MAX_SIZE 101 | |
| int A[MAX_SIZE]; // integer array to store the stack | |
| int top = -1; // variable to mark top of stack in array | |
| // Push operation to insert an element on top of stack. |