Skip to content
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

Merged
merged 8 commits into from
May 30, 2020
Merged

Conversation

PrachieNaik
Copy link
Contributor

@PrachieNaik PrachieNaik commented Apr 4, 2020

Fixes #2551

Checklist:

  • 4 space indentation.
  • Coding conventions are followed.
  • Input is taken dynamically.
  • Sample Input / Output is added at the end of file.
  • Logic Documentation (Comments).
  • File names are correct.

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

Languages Used:

Kotlin

We're happy to help you get this ready -- don't be afraid to ask for help.

Thanks!

@@ -0,0 +1,50 @@
import java.util.*
Copy link
Collaborator

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")
Copy link
Collaborator

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]))
}
Copy link
Collaborator

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

Comment on lines 28 to 33
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]
Copy link
Collaborator

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()
}
Copy link
Collaborator

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

@PrachieNaik
Copy link
Contributor Author

@asha15 Can you please review now?

Copy link
Collaborator

@asha15 asha15 left a 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)
Copy link
Collaborator

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

Copy link
Contributor Author

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

@PrachieNaik
Copy link
Contributor Author

Can someone review and merge it? @asha15 @jainaman224

Copy link
Collaborator

@asha15 asha15 left a 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

@PrachieNaik
Copy link
Contributor Author

@asha15 Please check now

Comment on lines 33 to 44
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()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct the indentation

@asha15
Copy link
Collaborator

asha15 commented May 20, 2020

please squash your commits before push it

@PrachieNaik
Copy link
Contributor Author

@asha15 Please review

@somya-kapoor
Copy link
Collaborator

please squash your commits

@PrachieNaik
Copy link
Contributor Author

can you guys please use squash and merge option? Thank you

@asha15 asha15 merged commit 65529ae into jainaman224:master May 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tree Postorder Traversal
3 participants