GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - imzero9/algorithm: a repository to study data structures and algorithms

BranchesTags
Open more actions menu

Latest commit

 

History

55 Commits
55 Commits

Folders and files

NameName
Last commit message
Last commit date
Arrays
Arrays
 
 
Big O
Big O
 
 
Dynamic Programming
Dynamic Programming
 
 
Graphs
Graphs
 
 
Hash Tables
Hash Tables
 
 
LeetCode
LeetCode
 
 
Linked Lists
Linked Lists
 
 
Searching
Searching
 
 
Sorting
Sorting
 
 
Stacks+Queues
Stacks+Queues
 
 
Trees
Trees
 
 
recursion
recursion
 
 
README.md
README.md
 
 

Repository files navigation

Algorithms and Data Structures

Big O Rule

1. Worst Case

ex. assume that the element we're finding is at the very last in the array

2. Remove Constants

function printFirstItemThenFirstHalfThenSayHi100Times(items) {
    console.log(items[0]);

    let middleIndex = Math.floor(items.length / 2);
    let index = 0;

    while (index < middleIndex) {
        console.log(items[index]);
        index++;
    }

    for (let i = 0; i < 100; i++) {
        console.log("hi");
    }
}

// X: O(1 + n/2 + 100)
// O: O(n)

function compressBoxesTwice(boxes) {
    boxes.forEach((box) => {
        console.log(box);
    });

    boxes.forEach((box) => {
        console.log(box);
    });
}

// X: O(2n)
// O: O(n)

3. Different terms for inputs

function compressBoxesTwice(boxes, boxes2) {
    boxes.forEach(function (boxes) {
        console.log(boxes);
    });

    boxes2.forEach(function (boxes) {
        console.log(boxes);
    });
}

// X: O(n)
// O: O(a + b), O(n + m) -> you can name it whatever you want

4. Drop Non Dominants

function printAllNumbersAndPairSums(numbers) {
    console.log("these are the numbers: ");
    numbers.forEach((number) => {
        console.log(number);
    });

    console.log("and these are their sums: ");
    numbers.forEach((firstNumber) => {
        numbers.forEach((secondNumber) => {
            console.log(firstNumber + secondNumber);
        });
    });
}

printAllNumbersAndPairSums([1, 2, 3, 4, 5]);

// X: O(n + n^2)
// O: O(n^2)  -> only leave the most significant part

About

a repository to study data structures and algorithms

Resources

Readme
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.