Luna's Blog

「恰似天地一蜉蝣」

Javascript Generator Functions

A generator is a function that generates a sequence of values, but not all at once, on a per request basis instead. We ask a generator for value, and the generator will return value or notify there...

Javascript Closure

This is the reading notes for ‘Secrets of the Javascript Ninja, 2nd Edition’, an amazing book explaining the Javascript basic ideas. Basic understanding of closure Simply put, closure allows a fun...

CPSC 340 Course Summary

This is the summary for CPSC340 courses. Mainly there are 5 parts in this course. supervised learning - based on countings and distances unsupervised learning - based on countings and distanc...

Dynamic Programming Problems

Fibonaci Liked House Robber Delete and Earn 740. Delete and Earn Jump Game

Javascript

Loops while do/while for for/of work with iterable objects Introduced in ES6. For/of with arrays, strings, sets 1 2 3 4 let data = [1, 2, 3, 4, 5], sum = 0; for (let el...

Promise Notes

At the very beginning, we use callback to handle asynchronous. Then in ES6, promise is introduced. The async and await were introduced in ES2017 and provide new syntax that simplifies asynchronou...

Trees

Graph DFS 200. Number of Islands Given an m x n 2D binary grid grid which represents a map of ‘1’s (land) and ‘0’s (water), return the number of islands. We can use dfs to solve this problem: ...

Binary Search

Find minimum in sorted array 153. Find Minimum in Rotated Sorted Array Leetcode 153 Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, th...

CPSC 340 18,19 Linear Classification

We can use linear regression to do the classification. Binary Classification - classify into {-1, 1} Loss function we cannot use least square, because it will penalize the too-right prediction ...

CPSC 340 Regularization

L2-Regularization Standard regularization strategy is L2-regularization. Also called ridge regression $f(w) = \frac{1}{2}   Xw-y   ^2 + \frac{\lambda}{2} ...