cvte软件测试笔试题,CVTE前端笔试20190302

选择题主要不会的是Promise和一些Web安全的知识。

编程题:

考察bfs

代码:

function bfs(node) {

var arr = [];

if(node != null) {

var queue = [];

queue.unshift(node);

while(queue.length != 0) {

var item = queue.shift();

arr.push(item);

var children = item.children;

for(var i=0; i

queue.push(children[i]);

}

}

}

return arr;

}

考察建树、dfs、递归

输入:

[ { id:1, value:'1', parentId:3 }, { id:2, value:'2', parentId:0 }, { id:3, value:'3', parentId:0 }, { id:4, value:'4', parentId:2 }, { id:5, value:'5', parentId:2 } ]

输出:

{

children: [

{

children: [

{

children:[],

id: 4,

value: '4'

},

{

children:[],

id: 5,

value: '5'

}

],

id: 2,

value: '2'

},

{

children: [

{

children:[],

id: 1,

value: '1'

}

],

id: 3,

value: '3',

}

],

id: 0,

value: '0'

}

代码:

function bfs(node) {

var arr = [];

if(node != null) {

var queue = [];

queue.unshift(node);

while(queue.length != 0) {

var item = queue.shift();

arr.push(item);

var children = item.children;

for(var i=0; i

queue.push(children[i]);

}

}

}

return arr;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值