Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link

#Avoid using recursive function calls in c (or similar languages)

Avoid using recursive function calls in c (or similar languages)

#Fix your indentation and always use a clear scope

Fix your indentation and always use a clear scope

#Avoid using recursive function calls in c (or similar languages)

#Fix your indentation and always use a clear scope

Avoid using recursive function calls in c (or similar languages)

Fix your indentation and always use a clear scope

added 15 characters in body
Source Link
Tree BuildTreeFromArray(int *arr, int size)
{
 // ...
 if (size == 1)
 {
 // ...
 }
 else
 {
 halfSize = size / 2;
 resTree.root->data = arr[halfSize]; // !!! Should be indented according the enclosing scope block
 // ...
 if (arr[halfSize/2] != -1)
 {//we check if there's a valid array data we can input to the tree
 // ...
 }
 else // !!! Missing scope block
 resTree.root->left = NULL; 
 if (arr[halfSize + (halfSize / 2) + 1] != -1)
 {
 // ...
 }
 else // !!! Missing scope block
 resTree.root->right = NULL;
 }
 return resTree;
}
Tree BuildTreeFromArray(int *arr, int size)
{
 // ...
 if (size == 1)
 {
 // ...
 }
 else
 {
 halfSize = size / 2;
 resTree.root->data = arr[halfSize]; // !!! Should be indented according the enclosing scope block
 if (arr[halfSize/2] != -1)
 {//we check if there's a valid array data we can input to the tree
 // ...
 }
 else // !!! Missing scope block
 resTree.root->left = NULL; 
 if (arr[halfSize + (halfSize / 2) + 1] != -1)
 {
 // ...
 }
 else // !!! Missing scope block
 resTree.root->right = NULL;
 }
 return resTree;
}
Tree BuildTreeFromArray(int *arr, int size)
{
 // ...
 if (size == 1)
 {
 // ...
 }
 else
 {
 halfSize = size / 2;
 resTree.root->data = arr[halfSize]; // !!! Should be indented according the enclosing scope block
 // ...
 if (arr[halfSize/2] != -1)
 {//we check if there's a valid array data we can input to the tree
 // ...
 }
 else // !!! Missing scope block
 resTree.root->left = NULL; 
 if (arr[halfSize + (halfSize / 2) + 1] != -1)
 {
 // ...
 }
 else // !!! Missing scope block
 resTree.root->right = NULL;
 }
 return resTree;
}
added 1 character in body
Source Link

Here's the fully fixed version (I'm not sure that will provide exactly the same logic as you currently havhave it):

Here's the fully fixed version (I'm not sure that will provide exactly the same logic as you currently hav it):

Here's the fully fixed version (I'm not sure that will provide exactly the same logic as you currently have it):

added 1344 characters in body
Source Link
Loading
added 25 characters in body
Source Link
Loading
added 25 characters in body
Source Link
Loading
Source Link
Loading
lang-c

AltStyle によって変換されたページ (->オリジナル) /