To the Top
File:  root - text - article - 2020 - 01 - level-order-traversal-of-binary-tree.txt
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Category: Computing | 194 Views, 20936 Search Bots | 73 Words

Subscribe to Feed Burner | Browse | Archive
Hi, here's your problem today. This problem was recently asked by Microsoft:

Given the root of a binary tree, print its level-order traversal. For example:


1
/ \
2 3
/ \
4 5


The following tree should output 1, 2, 3, 4, 5.


class Node:
def __init__(self, val, left=None, right=None):
self.val = val
self.left = left
self.right = right

def print_level_order(root):
# Fill this in.

root = Node(1, Node(2), Node(3, Node(4), Node(5)))
print_level_order(root)
# 1 2 3 4 5
Tags: 每日算法题, 算法, 数据结构, 面试题, Daily Interview Problem, Data Structures and Algorithms, Computer Programming, Python, | English | Home Page | Cateogry: Computing | 194 Views, 20936 Search Bots | 73 Words Subscribe to Feed Burner

Related Articles

  1. Number of Ways to Climb Stairs
  2. Daily Interview Problem: Tree Serialization
  3. Algorithm Interview: Permutations of numbers
  4. Algorithm Interview: Level Order Traversal of Binary Tree
  5. Daily Interview Problem: Running Median
  6. Fix Brackets
  7. [Daily Problem] Add two numbers as a linked list
  8. Daily Interview Problem: Arithmetic Binary Tree
  9. Print a tree level-by-level, with line-breaks
  10. Progess made

Comments (0)

Your Email (Domain Part Not Exposed):

Your Comments:

Privately By Mail Colors More Smileys S x y @

Verification (Click Image 2 Refresh):

    Be the first one to comment this page !


Page Edited: October 30 2020 14:21:09 | RSS Subscription
How to Cook a Perfect Steak? | <meta name="robots" content="noindex, follow" />