Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitef46369

Browse files
committed
Adjust to the updated Randomize functions in tracers.js
1 parentf310721 commitef46369

File tree

38 files changed

+63
-55
lines changed

38 files changed

+63
-55
lines changed

‎Branch and Bound/Binary Search Tree/search.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const T = [ // mapping to G as a binary tree , [i][0] indicates left child, [i][
2828
[9,-1],
2929
];
3030

31-
constkey=newRandomize.Integer(0,G.length-1).create();// item to be searched
31+
constkey=Randomize.Integer({min:0,max:G.length-1});// item to be searched
3232
consttracer=newGraphTracer(' Binary Search Tree ');
3333
constlogger=newLogTracer(' Log ');
3434
Layout.setRoot(newVerticalLayout([tracer,logger]));

‎Branch and Bound/Binary Search/iterative.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const chart = new ChartTracer();
44
consttracer=newArray1DTracer();
55
constlogger=newLogTracer();
66
Layout.setRoot(newVerticalLayout([chart,tracer,logger]));
7-
constD=newRandomize.Array1D(15,newRandomize.Integer(0,50)).sorted().create();
7+
constD=Randomize.Array1D({N:15,value:()=>Randomize.Integer({min:0,max:50}),sorted:true});
88
tracer.set(D);
99
tracer.chart(chart);
1010
Tracer.delay();
@@ -44,7 +44,7 @@ function BinarySearch(array, element) { // array = sorted array, element = eleme
4444
return-1;
4545
}
4646

47-
constelement=D[newRandomize.Integer(0,D.length-1).create()];
47+
constelement=D[Randomize.Integer({min:0,max:D.length-1})];
4848

4949
logger.println(`Using iterative binary search to find${element}`);
5050
BinarySearch(D,element);

‎Branch and Bound/Binary Search/recursive.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const chart = new ChartTracer();
44
consttracer=newArray1DTracer();
55
constlogger=newLogTracer();
66
Layout.setRoot(newVerticalLayout([chart,tracer,logger]));
7-
constD=newRandomize.Array1D(15,newRandomize.Integer(0,50)).sorted().create();
7+
constD=Randomize.Array1D({N:15,value:()=>Randomize.Integer({min:0,max:50}),sorted:true});
88
tracer.set(D);
99
tracer.chart(chart);
1010
Tracer.delay();
@@ -46,7 +46,7 @@ function BinarySearch(array, element, minIndex, maxIndex) { // array = sorted ar
4646
return-1;
4747
}
4848

49-
constelement=D[newRandomize.Integer(0,D.length-1).create()];
49+
constelement=D[Randomize.Integer({min:0,max:D.length-1})];
5050

5151
logger.println(`Using binary search to find${element}`);
5252
BinarySearch(D,element,0,D.length-1);

‎Branch and Bound/Depth-Limited Search/code.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ function DLSCount(limit, node, parent) { // node = current node, parent = previo
3737
}
3838
returnchild;
3939
}
40+
4041
logger.println(`Number of descendant is${DLSCount(2,0)}`);

‎Brute Force/Breadth-First Search/shortestPath.js‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const tracer = new GraphTracer().directed(false).weighted();
44
constlogger=newLogTracer();
55
Layout.setRoot(newVerticalLayout([tracer,logger]));
66
tracer.log(logger);
7-
constG=newRandomize.Graph(5,1).directed(false).weighted().create();
7+
constG=Randomize.Graph({N:5,ratio:1,directed:false,weighted:true});
88
tracer.set(G);
99
Tracer.delay();
1010

@@ -36,10 +36,10 @@ function BFS() {
3636
returnW[e];
3737
}
3838

39-
lets=newRandomize.Integer(0,G.length-1).create();// s = start node
39+
lets=Randomize.Integer({min:0,max:G.length-1});// s = start node
4040
lete;// e = start node
4141
do{
42-
e=newRandomize.Integer(0,G.length-1).create();
42+
e=Randomize.Integer({min:0,max:G.length-1});
4343
}while(s===e);
4444
letMAX_VALUE=0x7fffffff;
4545
logger.println(`finding the shortest path from${s} to${e}`);

‎Brute Force/Breadth-First Search/tree.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ function BFS(s) { // s = start node
3737
}
3838
}
3939
}
40+
4041
BFS(0);

‎Brute Force/Bubble Sort/code.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const chart = new ChartTracer();
44
consttracer=newArray1DTracer();
55
constlogger=newLogTracer();
66
Layout.setRoot(newVerticalLayout([chart,tracer,logger]));
7-
constD=newRandomize.Array1D(15).create();
7+
constD=Randomize.Array1D({N:15});
88
tracer.set(D);
99
tracer.chart(chart);
1010
Tracer.delay();

‎Brute Force/Comb Sort/code.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const chart = new ChartTracer();
44
consttracer=newArray1DTracer();
55
constlogger=newLogTracer();
66
Layout.setRoot(newVerticalLayout([chart,tracer,logger]));
7-
constD=newRandomize.Array1D(15).create();
7+
constD=Randomize.Array1D({N:15});
88
tracer.set(D);
99
tracer.chart(chart);
1010
Tracer.delay();

‎Brute Force/Cycle Sort/code.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const chart = new ChartTracer();
44
consttracer=newArray1DTracer();
55
constlogger=newLogTracer();
66
Layout.setRoot(newVerticalLayout([chart,tracer,logger]));
7-
constD=newRandomize.Array1D(15).create();
7+
constD=Randomize.Array1D({N:15});
88
tracer.set(D);
99
tracer.chart(chart);
1010
Tracer.delay();

‎Brute Force/Depth-First Search/graph.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const visitedTracer = new Array1DTracer('visited');
55
constlogger=newLogTracer();
66
Layout.setRoot(newVerticalLayout([graphTracer,visitedTracer,logger]));
77
graphTracer.log(logger);
8-
constG=newRandomize.Graph(8,.3).directed(false).create();
8+
constG=Randomize.Graph({N:8,ratio:.3,directed:false});
99
graphTracer.set(G);
1010
Tracer.delay();
1111

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp