Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Inorder Traversal Recursive
package com.interviewbytes.trees;
import java.util.ArrayList;
import java.util.List;
public class InorderTraversalRecursive {
public List<Integer> inorderTraversal(TreeNode root) {
List<Integer> list = new ArrayList<>();
helper(list, root);
return list;
private void helper(List<Integer> list, TreeNode node) {
if (node == null) return;
helper(list, node.left);
helper(list, node.right);
package com.interviewbytes.trees;
public class TreeNode {
int val;
TreeNode left;
TreeNode right;
TreeNode(int x) {
val = x;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.