From 797204f911a79aa6ce74dbe844afc2e8f3fb5574 Mon Sep 17 00:00:00 2001 From: mlsulekhiya <44512130+mlsulekhiya@users.noreply.github.com> Date: Sat, 12 Oct 2019 22:50:27 +0530 Subject: [PATCH] removed bugs --- Chapter 4/4.3.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Chapter 4/4.3.cpp b/Chapter 4/4.3.cpp index bd97885..c7b79f7 100644 --- a/Chapter 4/4.3.cpp +++ b/Chapter 4/4.3.cpp @@ -8,8 +8,9 @@ struct Node{ }; Node *arrayToBST(int a[], int start, int end){ - if (start > end) - return NULL; + if (start > end){ + return NULL; + } int mid = (start + end)/2; Node *bst = new Node(); bst -> data = a[mid]; @@ -18,7 +19,7 @@ Node *arrayToBST(int a[], int start, int end){ return bst; } -void preorder(Node *tree){ +void preorder(Node *tree) { if (tree == NULL) return; cout << tree -> data << " "; @@ -26,10 +27,10 @@ void preorder(Node *tree){ preorder(tree -> right); } int main() { - int t; + int t=0; cin >> t; while (t--){ - int n; + int n=0; cin >> n; int a[n]; for (int i = 0; i < n; i++){ @@ -39,6 +40,6 @@ int main() { preorder(ans); cout << endl; } - //code + return 0; }