This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const connections = new Map(); | |
// create objects in the array | |
const uf = (n) => { | |
for (const x of Array(n).keys()) { | |
connections.set({ id: x, name: x}, x); | |
} | |
} | |
// root |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const connections = []; | |
// create objects in the array | |
const uf = (n) => { | |
for (const x of Array(n).keys()) { | |
connections.push({ id: x, name: x}); | |
} | |
} | |
// root |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const connections = [ // O(1) | |
{ | |
id: 1, | |
name: 1 | |
}, | |
{ | |
id: 2, | |
name: 2 | |
}, | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const connections = [ | |
{ | |
id: 0, | |
name: 0 | |
}, | |
{ | |
id: 1, | |
name: 1 | |
}, | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const connections = [ | |
{ | |
id: 0, | |
name: 0 | |
}, | |
{ | |
id: 1, | |
name: 1 | |
}, | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const connections = []; | |
// create objects in the array | |
const uf = (n) => { | |
for (const x of Array(n).keys()) { | |
connections.push({ id: x, name: x}); | |
} | |
} | |
// union |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const connections = [ | |
{ | |
id: 1, | |
name: 1 | |
}, | |
{ | |
id: 2, | |
name: 2 | |
}, | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Represents an algorithm that runs in proportionally to the logarithm of the input size | |
const f = (n) => { | |
for (let i = 1; i < n.length; i = i * 2) { // | |
console.log(array[n]); // O(log(n)) | |
} // | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Represents an algorithm whose performance is directly proportional to the squared size of the input data set | |
for (const x of Array(n).keys()) { // O(n) | |
for (const y of Array(n).keys()) { // | |
console.log(x, y); // O(n) | |
} // | |
} | |
// O(n) * O(n) * O(1) = O(n * n) = O(n^2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Represents an algorithm who’s complexity will grow in direct proportion to the size of the input data | |
// 1. | |
for (const x of Array(n).keys()) { // n | |
console.log(x); // O(1) | |
} | |
// n * O(1) = O(n) |
NewerOlder