const N = 10000;
class Node {
constructor(val) {
this.val = val;
this.next = null;
this.prev = null;
}
}
function buildDoublyList(n) {
let head = new Node(0);
let curr = head;
for (let i = 1; i < n; i++) {
const node = new Node(i);
curr.next = node;
node.prev = curr;
curr = node;
}
return {
head,
tail: curr
};
}
// init list
let { head: list, tail } = buildDoublyList(N);
// array để so sánh
let arr = [];
for (let i = 0; i < N; i++) arr.push(i);Initializing...
| Test Case | Ops/sec | |
|---|---|---|
| array | | ready |
| Llist | | ready |
You can edit these tests or add more tests to this page by appending /edit to the URL.