p*****2 发帖数: 21240 | 1 稍微用了用node,写一点感受吧。本来想优点,缺点单独列出来,但是感觉还是混起来
写吧。
1. 自己想做点什么东西都不可避免要接触到前端,而前端则是JS的天下,因此前几天
看了看JS。这个时候就产生了一个问题了。既然前端必须要用JS,那么为什么不用node
,从而前后端统一语言呢?我当时的回答是不会用node,因为JS这个语言是挺灵活有趣
的,但是写起来实在是太boring了,前端用是没得其他选择,后端再用可就太痛苦了。
但是很快我发现了coffeescript这门语言,它吸收了python, ruby的优点,又解决了JS
的很多缺陷,因此我眼前一亮,一下子就喜欢上了这门语言了。当时学Ruby的时候就觉
得do end太boring了,要是能吸收Python的indentation代码就好看了,结果现在成为
现实了,就是coffeescript。有了coffeescript之后,我没有什么理由不考虑使用node
了。
优点1: 前后端统一语言。
2. 我在用Play的时候发现了一个问题就是我需要把Scala里的数据手工的转到Json,这
个工作比较boring,而node本身就是JS的... 阅读全帖 |
|
b******g 发帖数: 77 | 2 struct Node
{
Value value;
Node * left;
Node * right;
}
void printBT(Node * root);
void printBT(vector & v1);
void printBT(Node * root)
{
vector v1;
v1.push_back(root);
printBT(v1);
}
// recursively printBT Date structure: using two vectors -- v1 holds nodes
of current level, v2 hold nodes of next level;
void printBT(vector & v1)
{
if ( v1.empty() )
return;
vector v2;
Node * node;
for (int i = 0; i < v1.size(); i++... 阅读全帖 |
|
S*******C 发帖数: 822 | 3 import java.util.Stack;
/*
* Given Tree and Node n and int k, print all node which are at physical
distance <=k from n
* @Amazon intern
*/
public class Solution {
public static void main(String args[]){
Solution solution = new Solution();
TreeNode a = new TreeNode(8);
TreeNode b = new TreeNode(6);
TreeNode c = new TreeNode(10);
TreeNode d = new TreeNode(9);
TreeNode e = new TreeNode(12);
TreeNode f = new TreeNode(4);
TreeNode ... 阅读全帖 |
|
w**z 发帖数: 8232 | 4 In development for nearly two years, the 0.12 release of Node.js is about to
become available. Whether the release can mend the now-fractured community
that has been built around the popular server-side JavaScript platform
remains to be seen.
Officials at Node.js steward Joyent and at Strongloop, which is involved in
Node.js development, provided InfoWorld details about the upcoming release,
for which the download should become available today.
Version 0.12 will feature round-robin clustering, p... 阅读全帖 |
|
w**z 发帖数: 8232 | 5 http://www.javaworld.com/article/2104441/enterprise-application
"JavaScript everywhere, and everything ported to JavaScript" -- it's either
a running joke in IT these days or a stone-cold truth. Evidence is tending
toward the latter, what with Node.js becoming a jack-of-all-trades framework
for many workloads and environments.
With Nodyn, Node.js gains yet another place it can run: the Java Virtual
Machine.
Nodyn, a project sponsored by Red Hat via its Project:Odd team, works by
leveraging two o... 阅读全帖 |
|
w**z 发帖数: 8232 | 6 Third-party Node.js Foundation takes over jurisdiction of
Node.js, the popular server-side JavaScript platform that has seen
dissension in the ranks over its recent direction, is about to get a new
governance model.
Cloud software vendor Joyent had been in charge, but a new plan announced
today will turn Node.js over to an independent third party known as the Node
.js Foundation, said Joyent CEO Scott Hammond in an interview. The
Foundation, which the Linux Foundation has helped set up, will hav... 阅读全帖 |
|
d****n 发帖数: 1637 | 7 suppose binary tree root node is "root"
and all nodes pointers are in the array of
nodes[N];
// copied from leetcode.com
Node *lca2(Node *root, Node *p, Node *q) {
if (!root) return NULL;
if (root == p || root == q) return root;
Node *L = lca2(root->left, p, q);
Node *R = lca2(root->right, p, q);
if (L && R) return root;
return L ? L : R;
}
Node *lca_aux(root, left, right )
{
if (left==right)
return lca2(left,right);
return lca2(root,lca2(root,left,right), lca_aux(... 阅读全帖 |
|
z****e 发帖数: 54598 | 8 http://www.centurylinklabs.com/could-server-side-dart-replace-n
Could Server-Side Dart Replace Node.js?
Dart is a Google-produced programming language that has slowly been gaining
traction, particularly since its 1.0 release last year. While Dart has thus
far been seen as a promising alternative to JavaScript in the browser, I’d
like to argue that like Node.js, the true promise of Dart is actually on the
server side.
I too am skeptical of Dart as a client-side language, but if you cross over
to ... 阅读全帖 |
|
c*********e 发帖数: 16335 | 9 3个问题
1。 getTree function的 callback function cb怎么写的?
2。 nodes从哪来的,怎么赋值的?你的gettree() function里面并没有写nodes怎么赋
值啊。
3。 next(err);是async.each item执行后的call back,应该只需要call一次。你如果
放到递归recursion里,最后递归退出是通过
if (err)
return cb(err);
那 next(err)就没有被call到。
async.each(results, function(x, next) {
getTree(x.cid, function(err, nodes) {
node[x.name] = nodes;
next(err); //next(err);放这对吗?
... 阅读全帖 |
|
r******r 发帖数: 700 | 10 这个运行了一下,好像不对。 the path to the deepest node 就是树的 height. 如
果计算 height:
int height(BSTNode node) {
if (node == null)
return 0;
else
return Math.max(height(node.left), height(node.right)) + 1;
}
这就可以吧。height 的定义:
“The height of a tree is the length of the path from the root to the deepest node in the tree. A (rooted) tree with only one node (the root) has a height of zero.”
不过原问题好像是要找到 nodes, 那应该是 a list of nodes that have
the same biggest depth (tree'... 阅读全帖 |
|
i***0 发帖数: 8469 | 11 You are given a binary tree:
struct node
{
int n;
//
value of node
struct node *left;
//
left subtree
struct node *right;
//
right subtree
struct node *level;
//
level pointer (node “to the right”)
}
Initially, the level field is set to NULL.
1. Write a function that will link all the nodes at the same level in a
given tree.
void linkSameLevel(struct node *t);
2. Please explain what the running time and memory usage of your function
are for a tree of depth d
containing n nodes.
For instance, if |
|
m********g 发帖数: 272 | 12 public static Node successorInBST(Node root, int key)
{
Node pos = findInBST(root, key);
if(pos == null)
{
throw new IllegalArgumentException("Cannot find the key in the
BST");
}
if(pos.getRight() != null)
{
return findSmallest(pos.getRight());
}
Node successor = null;
while(root != null)
{
if(key < root.getKey())
{
su... 阅读全帖 |
|
g*********e 发帖数: 14401 | 13 这题I是binary tree,不知bst有什么可以利用的性质?我觉得i ii都一样啊
我的code
class Solution {
public:
void connect(TreeLinkNode *root) {
// Start typing your C/C++ solution below
// DO NOT write int main() function
queue q;
if(!root)
return;
q.push(root);
q.push(NULL);
TreeLinkNode* prev=NULL;
while(!q.empty()){
TreeLinkNode* node=q.front();
q.pop();
if(!node){
if(q.empty())
... 阅读全帖 |
|
d****n 发帖数: 1637 | 14 Notable changes
This list of changes is relative to the last io.js v3.x branch release, v3.3
.0. Please see the list of notable changes in the v3.x, v2.x and v1.x
releases compiled in unified CHANGELOG for a more complete list of changes
from 0.12.x. Note, that some changes in the v3.x series as well as major
breaking changes in this release constitute changes required for full
convergence of the Node.js and io.js projects.
child_process: ChildProcess.prototype.send() and process.send() operate
... 阅读全帖 |
|
b********e 发帖数: 215 | 15 for example;
tempalte
class Node
{
public:
T data;
Node *next;
Node(const T &item,Node *n):data(item),next(n)
}
还是:
tempalte
class Node
{
private:
T data;
Node *next;
public:
getData;
setData;
getNext;
setNext;
Node(const T &item,Node *n):data(item),next(n)
}
一般来说成员变量应写成私有的,但像这种简单的类,面试时有必要写成私有的吗? |
|
r******r 发帖数: 700 | 16 如果计算 deepest node 的整数值,那就是树的高度吧:
“The height of a tree is the length of the path from the root to the
deepest node in the tree. A (rooted) tree with only one node (the root) has
a height of zero.”
这个整值只有一个,就是树的高度。但这个问题的本意好像不是计算树的高度。
但如果要找出具体的 nodes,可能有多个。
看了网上一些相关话题,好像 depth 和 height 的概念有些混淆。比如有计算 最大深
度 的讨论,
public int maxDepth(BSTNode node) {
if (node == null) return 0;
int left = maxDepth(node.left);
int right = maxDepth(node.right);
return 1 + Math.max(left... 阅读全帖 |
|
r******r 发帖数: 700 | 17 root
node_k
node_n
我理解的是从 root -> node_k 的距离,是 node_k 的 depth;
从 node_k -> node_n 的距离,是 node_k 的 height
root's height = depth of node_n
root's depth = 0
node_n's height =0;
node_k's height = node_n - node_k
到 root 的最大相等路径的 leaf node 可能有多个,所以 deepest nodes 可能有多个。
from wiki:
# The depth of a node n is the length of the path from the root to the node.
The set of all nodes at a given depth is sometimes called a level of the
tree. The root node is at depth zero.
# The height of a tree is th... 阅读全帖 |
|
l*****a 发帖数: 14598 | 18 1)u want to use this pointer to delete this node
2) u need to adjust its previous node and next node to make sure that
they have no relationship with this node
then u can delete this node
3) after u delete this node use this pointer, how can u let it point to the
others?
now u can't use its pre/next node to delete this node as well.
so what u said is a paradox
we |
|
c*****g 发帖数: 33 | 19 Given a linked list and a value, delete all the nodes having the value equal
to that value. (Use C++)
class Node
{
public:
int data;
Node* next;
};
void f(int a, Node* head)
{
while(head != NULL)
{
if(head->data == a) // if match, delete the node
{
Node* temp = head;
head->next = head->next->next;
delete temp;
}
head = head->next;
}
}
请问if条件下的作法对吗? 一般来说需要delete那个node吗? (若用java好像就不用)
如果把Node* temp = head;在whil... 阅读全帖 |
|
j*****y 发帖数: 1071 | 20 int numberNodes(TreeNode * root)
{
int result = 0;
int nodes = 1;
TreeNode *tmp = root;
int rightLayer = 0;
while(tmp)
{
result += nodes;
++rightLayer;
nodes *= 2;
tmp = tmp->right;
}
int leftLayer = 0;
tmp = root;
while(tmp)
{
++leftLayer;
tmp = tmp->left;
}
if(leftLayer == rightLayer)
{
return result;
}
tmp = root;
while(tmp)
{
--rightLayer;
int layer ... 阅读全帖 |
|
a***e 发帖数: 413 | 21 Update:
终于写出来了。。。。。去掉prev2 = p->next;就对了。
还是欢迎大牛们指点,讨论哈!哎,不知哪年哪月才能练到能去面试的。。。。。。
独自刷题非常郁闷。
Reverse Nodes in k-Group
https://oj.leetcode.com/problems/reverse-nodes-in-k-group/
Given a linked list, reverse the nodes of a linked list k at a time and
return its modified list.
If the number of nodes is not a multiple of k then left-out nodes in the end
should remain as it is.
You may not alter the values in the nodes, only nodes itself may be changed.
Only constant memory is allowed.
For example,
Give... 阅读全帖 |
|
z****e 发帖数: 54598 | 22 node吹嘘的性能提升,其实并没有得到真正的提升
这个你看各个web server的benchmark对比就知道
node从来也没有排在前面过,基本上都是中靠下的位置
https://www.techempower.com/benchmarks/#section=data-r10&hw=peak&test=json
排在top几的基本上java居多,但是go也经常出现
其中go, netty, vert.x, undertow几个都曾出现在top5以内,甚至top3
当然这个ranking随时在变,因为各个web server也在不停滴更新和开发
其实node本身只是一个prototype
只是用来elaborate event是如何对比thread能有一定效率上的提升的
如何通过不block的方式,使得程序能够快速地执行
但是因为node本身的单线程的限制,使得node在event上获取的效率优势
很快又都赔掉了,综合看并不划算,但是这个node的榜样意义在于
你可以从node这种模式中学习如何制造一个异步的web server
然后获取效率上的提升
你看ranking中排第一个那个... 阅读全帖 |
|
e***l 发帖数: 710 | 23 直接用一个额外的数组(或者node对象的一个分量)记录颜色,颜色标记的顺序应该和
递归的方法相同:
所有node标白色;
root标灰色并入栈;
while(栈非空){
取得栈顶元素,//必为灰色
找到它第一个白色的邻接node,将其标灰并入栈, //注1
如果没有找到白色邻接node,将栈顶元素标黑并出栈。//所有邻接node已发现
}
注1:可以对每个node记录“已经访问到了第几个邻接node”,避免每次从头搜索 |
|
l****c 发帖数: 782 | 24 新手我试一下哈
typedef struct Node{
int value;
int level;
struct Node *left;
struct Node *right;
} node;
void_print(int LEVEL)
{
node *root;
if (LEVEL==0) return;
node *tmp = root;
queue.push(tmp);
stack.push(tmp);
while (queue.front()->level < LEVEL) {
int tmp_level = queue.front()->level;
while(queue.front()->level==tmp_level) {
node *tmp = queue.pop_front();
queue.push_back(tmp->left);
queue.push_back(tmp->right);
stack.push_back(tmp->left);
stack.push_back(tmp->right);
}
}
while(!stack.is... 阅读全帖 |
|
y***n 发帖数: 1594 | 25 Node *curr: pointer to a node.
Node *&curr: reference to pointer to a node.
Node ** curr : pointer to pointer to a node.
每个都写一下,就会加深理解。。
还有这些问题去StackOverflow, 很多牛人会来回答,还可以得分 |
|
N*n 发帖数: 456 | 26 在读一些关于node.js 的介绍。
看到下面的一段话。Node.js 在server 端运行javascript..
这样推论对不对?node.js主要可能是适于small-phone类低运算能力的client.
如果面向client的是PC,尤其在server 端也是普通PC 级的小网站,其实不适合用node
.js
http://radar.oreilly.com/2011/07/what-is-node.html
"Dig a little deeper, and you’ll hear that Node.js (or, as it’s more
briefly called by many, simply “Node”) is a server-side solution for
JavaScript, and in particular, for receiving and responding to HTTP requests
. If that doesn’t completely boggle your mind, by the time the conversat... 阅读全帖 |
|
x****d 发帖数: 1766 | 27 楼主可能混淆了两种情况
只讲单纯http request,不说websocket xmlhttp/ajax,
1,request进来如果不做什么复杂的事情马上就回去了
2,request进来等比如数据库返回结果,假设等一分钟,
第二种情况不管你用node还是用tomcat/java都不关web server的事,
node只是一个web server,
weblogic/websphere 对第二种情况有专利的处理办法
如果自己做可以用jms连两个servlet,
处理request的servlet
把进来的request排队,
有结果了第二个response servlet按顺序返回结果回去
这个跟node没关系,和通常说的web server没关系
用node也可以这样处理长时间等数据库的请求
第一种情况,理论上请求多了也回堵车,
但实际上是不可能的,sync还是async其实都很快,
如果request多到要堵车,现实中这样的应用,
前面会有loadbalancer,
有reverse proxy,根本不用web server操心,
前面路由器都先死掉了,不会堵在node或者to... 阅读全帖 |
|
w*s 发帖数: 7227 | 28 讨论一下啊,不一定说得清。
目前我的整个path这样,很普通
angular route -> controller, http get method
-> node.js route, multiple middleware,
-> node.js last middleware calls python script
-> angular controller
-> angular partial view
现在有不同层次的error handling,
1. node server is down
2. python script in node.js fails
3. node route middleware 1 stops at "not logged in"
should redirect to login page
4. node route middleware 2 stops at "not enough resource",
node ret... 阅读全帖 |
|
t***o 发帖数: 4265 | 29 正在做个有关无线传感器网络的工作。想量一下一个node的在不同工作状态下的电流。
觉得应该很简单:在电源和node之间串一个小电阻,测量电阻两端的电压,就可以算出
电流。可是实际上发现很大的误差。请各位看看测量方法有什么不妥之处。
node 采样速度是1Hz。每半小时用GPRS把采集到的数据上传。
测量时,node没有用电池;用了一个外部恒压电源供电(3.7V)。电源带有电流指示,
但精度比较低。一个1欧姆的电阻。数据采样用NI USB-6221。
测量1:直接把电源接node,电源指示电流最大可达120mA。
测量2:电源接1欧姆电阻,再接到node。电阻两端连到NI。电源指示电流与NI的指示差
不多,但值是46mA。
相差如此之大,我不能相信测量2,但又不能直接从电源自动记录电流变化的过程。我
想测量2中,加入的电阻和NI改变了原来的node电路结构,但没闹懂影响怎么会那么大
,影响是如何具体发生的。
这个测量实际上无关无线传感器网络;应该是个电路测量方面关于干扰的知识。请来本
版的xdjm们看看问题会出在哪儿。谢谢。 |
|
s**x 发帖数: 7506 | 30 刚刚整理了一下这道题, 这是我搜集到的思路, 自己写的 code.
//Solution 1: using in order traversal.
// Time is O(n).
Node *getKth1(Node *root, int &k)
{
if (root == NULL)
return NULL;
Node *res =
getKth(root->left, k);
if (res != NULL)
return res;
if (k == 1)
return root;
k--;
return getKth(root->right, k);
}
// Solution 2: If each node has its
// left sub-tree size info, we can do
// time O(logn).
Node *getKth(Node *root, int k)
{
if (root == NULL)
... 阅读全帖 |
|
c***d 发帖数: 26 | 31 我的一点心得,最近工作中刚用到。刚懂点皮毛,不见得全对。
单线程不见得所有的requests都是一个线程/进程处理的,要不然多核cpu不浪费死了
(现在还有单核的吗?:))。
首先node natively支持cluster http://nodejs.org/api/cluster.html。利用这个功能一个多核的机器上有多个node进程听同一个端口,OS 自动 load balance到多个进程,每个进程之间依然独立。
其次,一般要scale的时候不会直接让node做frontdoor,至少会放在nginx(或类似的)之
后。一个nginx后面可以挂很多node app servers。其实到了production,就算不考虑
scale,一般也会至少一个nginx带俩node,这样deploy时可以无down time.
node异步的好处是它以单线程的资源消耗在等待后面数据的时候(db or file),它还可
以接受并处理别的请求。而其他的framework如rails(早期版本,最新的也许可以)是
做不到这点的。
events
on |
|
i****n 发帖数: 42 | 32 请教一个 C++ linked list/Tree related 的小问题:
struct Node
{
int data;
Node *next;
}
Compared against Node *curr, what does Node *&curr or Node **curr exactly
mean? Thanks a lot. |
|
S*******C 发帖数: 822 | 33 Given Tree and Node n and int k, print all node which are at physical
distance <=k from n
这道题怎么做?
我可以打印离root距离 <= k的node
但不能打印离任何node距离 <= k的node |
|
m****l 发帖数: 71 | 34 【 以下文字转载自 Programming 讨论区 】
发信人: mussel (海中生), 信区: Programming
标 题: 请教Node.js 应用的安全问题
发信站: BBS 未名空间站 (Tue Aug 11 23:37:51 2015, 美东)
兄弟在做这方面的开发,现接近完成上线,想和大家请教一下node.js安全上的问题。
我现在考虑的node.js 安全,主要是input validation, rate limitation什么的。
Input validation, 我找到了 node.js 有关的 validator 和它的两个sisiter npm,
express-validator 与 mongoose-validator.
StrongLoop 有相关的rate limitation, 包括基于ip 和API流量的,但它这部分好像不
是open source, 我在package 中没有找到。Google 了一下,也有几个,node-rate-
limiter等.
想和大牛请教一下,大家工作中常用的node.js express 安全module... 阅读全帖 |
|
m****l 发帖数: 71 | 35 【 以下文字转载自 Programming 讨论区 】
发信人: mussel (海中生), 信区: Programming
标 题: 请教Node.js 应用的安全问题
发信站: BBS 未名空间站 (Tue Aug 11 23:37:51 2015, 美东)
兄弟在做这方面的开发,现接近完成上线,想和大家请教一下node.js安全上的问题。
我现在考虑的node.js 安全,主要是input validation, rate limitation什么的。
Input validation, 我找到了 node.js 有关的 validator 和它的两个sisiter npm,
express-validator 与 mongoose-validator.
StrongLoop 有相关的rate limitation, 包括基于ip 和API流量的,但它这部分好像不
是open source, 我在package 中没有找到。Google 了一下,也有几个,node-rate-
limiter等.
想和大牛请教一下,大家工作中常用的node.js express 安全module... 阅读全帖 |
|
s*********e 发帖数: 17 | 36 I give you a singly linked Linked List. Write a function to swap every second
node. [ie - 1->2->3->4->5->| becomes 2->1->4->3->5->|]
大家有没有更好的办法?
BOOL SwapList(node** pphead)
{
if(*pphead == NULL)
return FALSE;
// two pointers
node* pNode1 = *pphead;
node* pNode2 = (*pphead)->pNext;
*pphead = pNode2;
while(pNode2->pNext != NULL)
{
// two temporay pointers
node* pTmp1 = pNode1->pNext->pNext;
node* pTmp2 = pNode2->pNext->pNext;
|
|
s*i 发帖数: 31 | 37 In c or c++, if given a node in a linked list, and you want to delete the
node after it. You can just:
obsolete_node = node->next
node->next=node->next->next
free(obsolete-node) //or "delete obsolete_node"
But java has garbage collection, and no such keyword as free or delete. So
in java, can i simply skip the last statement, and it'll be correct? Because
obsolete_node no longer has any references to it, so the garbage collector
will free up its memory ? |
|
p*****2 发帖数: 21240 | 38 http://queue.acm.org/detail.cfm?id=2567673
信息量太大了。
We did some prototyping with Ruby and Python using the evented frameworks
EventMachine and Twisted. The bottom line was that Node proved to be 2-5
times faster than both of those in terms of raw throughput. What was even
more exciting and really sold us on Node was that it took only two or three
hours to write the Node prototype while it took us more on the order of a
day or two to write the EventMachine and Twisted ones, just because we had
to ... 阅读全帖 |
|
f*******w 发帖数: 407 | 39 想了解一下node.js,按照指令把node.js下载安装了,安装的目录是:C:Program
Filesnodejs。想重复网上的例子(http://nodeguide.com/beginner.html#a-hello-world-http-server),比如把下面的code存成server.js:
var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200);
res.end('Hello Http');
});
server.listen(8080);
教程说:
Now lets run this program from the terminal by typing:
$ node hello_http.js
请问:
一、server.js要存到那个目录下啊?
二、这里的terminal 是指双击node.exe打开的那个window吗?如果是的话,我这样做
了,可是我把“$ node hello_http.js”copy + pa... 阅读全帖 |
|
c*********e 发帖数: 16335 | 40 你这个function的结果,node["老王"] 里面只会包含一个儿子: “子一”或者“子二
”,不可能同时包含2个或者多个儿子。
你运行了这个function吗?结果正确吗?
// model is the mongoose collection Model
function getTree(parent_cid, cb) {
var node = {};
model.find({
parent_cid : parent_cid || 0,
}).exec(function(err, results) {
if (err)
return cb(err);
async.each(results, function(x, next) {
getTree(x.cid, function(err, nodes) {
... 阅读全帖 |
|
C*Y 发帖数: 736 | 41 Interview questions for front-end web developer.
1. Given a node of a non-binary tree, find all nodes on the same level. Choose any
language and data structure you prefer to implement this.
2. Given a node of a DOM tree, find all nodes on the same level. Use javascript and jquery library to implement this, write as less code as possible. |
|
P**********c 发帖数: 3417 | 42 这个有很多算法,但是大部分都是assume 这两个node都在tree里,是么?
比如最简单的BST, 如果发现当前node在要找的两个node之间,就返回当前node, 但是
如果要找的两个node根本不在tree里,其实应该返回NULL? |
|
d***d 发帖数: 99 | 43 一道大公司诡异的complete binary tree max sum of 2 nodes 题
当场 40min white board 给出了O(N2) 的解法,对方表示赞许,但是没时间optimize
了。直觉告诉我应该有NlogN的解法。大牛指点下。
具体如下:
given one complete binary tree, with positive and identical values in all
nodes.
Find 2 nodes, such that:
sum of their path nodes to root (identical nodes will count only once) are maximum. |
|
x*********n 发帖数: 46 | 44 node->prev->next = node->next;
node->next->prev = node->prev;
free(node); |
|
c*****a 发帖数: 808 | 45 那个貌似多余的
我照着你想法写的
static int i=0;
public void findKth(BSTNode node, int k){
if(node == null) return;
findKth(node.right, k );
i++;
if(i==k) System.out.println(node.getData());
findKth(node.left, k );
} |
|
c*****g 发帖数: 33 | 46 Thanks for correction. 我改了一些 先假设a数值不发生在第一个node, 想请问这样
的delete node方式是不是正确的
void f(int a, Node* head)
{
while(head->next != NULL)
{
if(head->next->data == a) // if match, delete the node
{
Node* temp = head->next;
head->next = head->next->next;
delete temp;
}
head = head->next;
}
} |
|
m*********a 发帖数: 3299 | 47 node dummy(0);
node *ptr
node * &curr=ptr;
其实是node *是个数据类型(ptr的数据类型),curr是ptr的另一个名字(&curr=ptr),
ptr和curr的内存地址一样。
这和
int x;
int &y=x;是一样的,y是int这个数据类型(x的数据类型),y是x的另一个名字(&y=x)
,地址一样。 |
|
x****d 发帖数: 1766 | 48 first, java has NIO, would beat node.js to death if they want.
second, have a look at opa, if you like node.js. if the market is there,
somebody in Java community can easily do something similar to opa, then use
node.js.
So, node.js is picking up, but on fire? have a look at how much martket
share java has, and redefine "on fire". If node.js is fire, must be ligher's
fire, and java is neclear fire. LOL. |
|
z****e 发帖数: 54598 | 49 基本上评论是一边倒地吐槽原作者的无知
Peter Gwiazda replied on Fri, 2013/10/25 - 2:14am
I don't belive you've actually tested anything.
First of all I think that "raw" Node.js should be way faster than JavaEE
server returning responses under heavy load. It's like motorcycle vs. train.
They have very different model and functionality. In simple servlet there
is still much more under the hood than in Node.js.
You should rather compare Node.js to Vert.x which is a JVM equivalent to
Node.js with very similar programmi... 阅读全帖 |
|
g*****g 发帖数: 34805 | 50 大神爱上了Python,想结婚了。没有了以前每年换一次最爱的冲动。看到Node上来了,
五味杂陈。
话说Python这种语言,在纯后端肯定是竞争不过JVM系的。GIL是天生的劣势,生态系统
也差太多。如果前端Node一统天下。以后应用轻量级的必然是node成为full stack首选
。重量级的必然是node+JVM系。对于Python是噩耗。
Node/
Clojure |
|