formatting source-code for 153fb7b8a5

This commit is contained in:
github-actions
2020-05-30 04:02:09 +00:00
parent 92fe9495ec
commit 8a2de9842b
175 changed files with 1671 additions and 3460 deletions

View File

@@ -2,17 +2,14 @@
#include <list>
using namespace std;
struct node
{
struct node {
int val;
node *left;
node *right;
};
void CreateTree(node *curr, node *n, int x, char pos)
{
if (n != NULL)
{
void CreateTree(node *curr, node *n, int x, char pos) {
if (n != NULL) {
char ch;
cout << "\nLeft or Right of " << n->val << " : ";
cin >> ch;
@@ -20,32 +17,25 @@ void CreateTree(node *curr, node *n, int x, char pos)
CreateTree(n, n->left, x, ch);
else if (ch == 'r')
CreateTree(n, n->right, x, ch);
}
else
{
} else {
node *t = new node;
t->val = x;
t->left = NULL;
t->right = NULL;
if (pos == 'l')
{
if (pos == 'l') {
curr->left = t;
}
else if (pos == 'r')
{
} else if (pos == 'r') {
curr->right = t;
}
}
}
void BFT(node *n)
{
void BFT(node *n) {
list<node *> queue;
queue.push_back(n);
while (!queue.empty())
{
while (!queue.empty()) {
n = queue.front();
cout << n->val << " ";
queue.pop_front();
@@ -57,38 +47,31 @@ void BFT(node *n)
}
}
void Pre(node *n)
{
if (n != NULL)
{
void Pre(node *n) {
if (n != NULL) {
cout << n->val << " ";
Pre(n->left);
Pre(n->right);
}
}
void In(node *n)
{
if (n != NULL)
{
void In(node *n) {
if (n != NULL) {
In(n->left);
cout << n->val << " ";
In(n->right);
}
}
void Post(node *n)
{
if (n != NULL)
{
void Post(node *n) {
if (n != NULL) {
Post(n->left);
Post(n->right);
cout << n->val << " ";
}
}
int main()
{
int main() {
int value;
int ch;
node *root = new node;
@@ -97,8 +80,7 @@ int main()
root->val = value;
root->left = NULL;
root->right = NULL;
do
{
do {
cout << "\n1. Insert";
cout << "\n2. Breadth First";
cout << "\n3. Preorder Depth First";
@@ -107,8 +89,7 @@ int main()
cout << "\nEnter Your Choice : ";
cin >> ch;
switch (ch)
{
switch (ch) {
case 1:
int x;
char pos;