Print nodes in a given range of BST
来源:互联网 发布:英雄联盟录制软件 编辑:程序博客网 时间:2024/05/30 23:01
I am stupid..... this is a MS interview question.
Pseudo code
void printNode(root) { if(!root) return; stack<Node*> nodes; Node* pCurrent; while(!pCurrent || !nodes.empty()) { if(pCurrent) { nodes.push(pCurrent); Node* tmp = nodes.top(); if(tmp->val < small) {root = NULL;} else { pCurrent = pCurrent->left; } } else { Node* top = stack.top(); stack.pop(); if(top->val >= small && top->val <= big) cout << top->val << endl; if(top->val > big) pCurrent = NULL; else pCurrent = top->right; } }}
0 0
- Print nodes in a given range of BST
- [Google]Find numbers of nodes in a BST in the range [low,high]
- solution Of Pat 1115. Counting Nodes in a BST (30)
- Counting Nodes in a BST
- CareerCup Find the ceiling value present in the BST of a given ke
- A1115. Counting Nodes in a BST (30)
- PAT--1115. Counting Nodes in a BST
- 1115. Counting Nodes in a BST (30)
- 1115. Counting Nodes in a BST (30)
- 1115. Counting Nodes in a BST (30)
- 1115. Counting Nodes in a BST
- 1115. Counting Nodes in a BST (30)
- 1115. Counting Nodes in a BST (30)
- 1115. Counting Nodes in a BST (30)
- 1115. Counting Nodes in a BST
- PAT 1115 Counting Nodes in a BST
- 1115. Counting Nodes in a BST (30)
- 【PAT】1115. Counting Nodes in a BST
- One-to-Many|Many-to-One(双向+自身)
- C#之四十八 俄罗斯方块设计
- shell 脚本的学习与使用(一)
- C#之四十九 游戏编程周每日总结
- C#之五十 扫雷
- Print nodes in a given range of BST
- DCOS之docker各式文件系统简介
- Shell函数:Shell函数返回值、删除函数、在终端调用函数
- Shell函数参数
- Shell输入输出重定向:Shell Here Document,/dev/null文件
- Shell文件包含
- 记录下在部署exchange中的经验
- 什么是编程语言
- 为什么首选C语言