This file contains 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
0x9f24ff18549A8B41C06a5fC732a2b90d459C249c |
This file contains 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
0x60d8734a039616163d84749ba10c9492f876928e |
This file contains 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
0xfb671a57270318f595eb2844aeb6ca82599eb76d |
This file contains 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
pragma solidity ^0.4.0; | |
contract WolframPocV1 { | |
address private owner; | |
struct Work { | |
bytes32 title; | |
address validator; | |
uint baselineUsers; | |
uint validatedUsers; |
This file contains 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
class Node { | |
constructor(data) { | |
this.data = data; | |
this.next = null; | |
} | |
} | |
class LinkedList { | |
constructor() { | |
this.head = null; |
This file contains 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
//Space Complexity: O(V + E) | |
class Graph { | |
constructor() { | |
this.vertices = new Map(); | |
} | |
//O(V) time complexity of Map.prototype.set | |
addVertex(v) { | |
this.vertices.set(v, []) | |
} |
This file contains 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
//Storage: O(V^2) | |
class Graph { | |
//O(V^2) | |
constructor(size){ | |
this.vertices = []; | |
for(let i = 0; i < size; i++){ | |
this.vertices.push([]); | |
for(let j = 0; j < size; j++){ | |
this.vertices[i].push(false); |
This file contains 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
let a = [3,1,2,15,4,3,8,8,0]; | |
let c = 0; | |
//Time Complexity: O(N^2) | |
//Space Complexity: O(1) because auxiliary space required (above original data set) is 0. | |
const insertionSort = (arr) => { | |
for(let i=0; i < arr.length; i++){ | |
let j = i; | |
while(j > 0 && arr[j] < arr[j-1]) { |
This file contains 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
//converting an array to a heap is performed with two functions, heapify and siftDown. | |
//The result is an array representation of a max heap. | |
//A max heap is required to perform a heap sort. | |
//Time Complexity: O(N). Although siftDown is O(log n), the overall runtime is O(N). | |
//Good info here on time complexity: https://www.growingwiththeweb.com/data-structures/binary-heap/build-heap-proof/ | |
//Space Complexity: O(1) auxiliary space is 0 since the array is converted to a heap in place. | |
const heapify = (arr) => { | |
//end is the last element of the array |
This file contains 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
//Create a sorted array (ascending) from a max heap | |
//Time Complexity: O(N log N) | |
//Space Complexity: O(1) because array is sorted in place | |
const heapSort = (arr, end) => { | |
while(end > 0){ | |
let tmp = arr[end]; | |
arr[end] = arr[0]; | |
arr[0] = tmp; | |
end -= 1; | |
OlderNewer