-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create Tree_Postorder_Traversal.kt #2699
Conversation
@@ -0,0 +1,50 @@ | |||
import java.util.* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep a line space after this
val arrSize = read.nextLine().toInt() | ||
var arr = IntArray(arrSize) | ||
val nodes = mutableListOf<Node<Int>>() | ||
println("Enter the array respresentaion of binary tree") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep a line space after this
{ | ||
arr[i] = read.nextLine().toInt() | ||
nodes.add(Node(arr[i])) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep a line space after this
for(i in 0..arrSize-2) | ||
{ | ||
if((i*2)+1<arrSize && arr[(i*2)+1]!=-1) | ||
nodes[i].left = nodes[(i*2)+1] | ||
if((i*2)+2<arrSize && arr[(i*2)+2]!=-1) | ||
nodes[i].right = nodes[(i*2)+2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep space around operators
} | ||
print("Post Order traversal of tree is ") | ||
nodes[0].postorderTraversal() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
keep a line space after this
@asha15 Can you please review now? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do this small change and squash your commits before push it
nodes.add(Node(arr[i])) | ||
} | ||
|
||
for(i in 0..arrSize-2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please keep space around operator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please check now? I will squash it from next time
Can someone review and merge it? @asha15 @jainaman224 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still your code has indentation issues :( please correct it
@asha15 Please check now |
if ((i * 2) + 1 < arrSize && arr[(i * 2) + 1] != -1) | ||
{ | ||
nodes[i].left = nodes[(i * 2) + 1] | ||
} | ||
|
||
if ((i * 2) + 2 < arrSize && arr[(i * 2) + 2] != -1) | ||
{ | ||
nodes[i].right = nodes[(i * 2) + 2] | ||
} | ||
} | ||
print("Post Order traversal of tree is ") | ||
nodes[0].postorderTraversal() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
correct the indentation
please squash your commits before push it |
@asha15 Please review |
please squash your commits |
can you guys please use squash and merge option? Thank you |
Fixes #2551
Checklist:
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
Languages Used:
Kotlin
Thanks!