Skip to content

Commit 4212fb4

Browse files
Merge pull request #1 from wakidurrahman/feat/section-big-o
sample 001 and note file created.
2 parents f6ca244 + e62df58 commit 4212fb4

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

section-big-o/note.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/** importance links and note **/
2+
3+
/***
4+
* note
5+
***/
6+
1. Big O and Scalability.
7+
we see that as our input grew, our function Find `Nemo` became slower and slower and slower.
8+
Our runtime, how long it takes to run a certain problem through a function, increased.

section-big-o/sample-001.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// #1 -- For loop in Javascript
2+
const fish = ['dory', 'bruce', 'marlin', 'nemo'];
3+
const nemo = ['nemo'];
4+
const everyone = ['dory', 'bruce', 'marlin', 'nemo', 'gill', 'bloat', 'nigel', 'squirt', 'darla', 'hank'];
5+
const large = new Array(10).fill('nemo');
6+
7+
8+
function findNemo(array) {
9+
let startTime = performance.now();
10+
for (let index = 0; index < array.length; index++) {
11+
const element = array[index];
12+
if (element === 'nemo') {
13+
console.log('Found NEMO');
14+
}
15+
}
16+
let endTime = performance.now();
17+
console.log(`Call to find Nemo took ${endTime - startTime} milliseconds.`)
18+
19+
}
20+
21+
findNemo(nemo)

0 commit comments

Comments
 (0)