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, 20720 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, 20720 Search Bots | 73 Words Subscribe to Feed Burner

Related Articles

  1. Top K Frequent words
  2. Kaprekar
  3. Daily Interview Problem: Longest Substring With K Distinct Characters
  4. Daily Interview Question: Create a Simple Calculator
  5. [Daily Problem] Witness of The Tall People
  6. First and Last Indices of an Element in a Sorted Array
  7. Daily Interview Problem: Min Stack
  8. Floor and Ceiling of a Binary Search Tree
  9. Daily Interview Problem: Get all Values at a Certain Height in a Binary Tree
  10. Daily Interview Problem: Validate Binary Search Tree

Comments (0)

    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="index, follow">