Giter Site home page Giter Site logo

cheatsheet1999 / frontendcollection Goto Github PK

View Code? Open in Web Editor NEW
3.0K 3.0K 417.0 14.22 MB

Notes for Fullstack Software Engineers. Covers common data structure and algorithms, web concepts, Javascript / TypeScript, React, and more!

HTML 30.01% JavaScript 54.31% CSS 13.59% MDX 1.48% TypeScript 0.61%
data-structures front-end-development frontend fullstack interview javascript leetcode nodejs react typescript webdevelopment

frontendcollection's Introduction

Hey there

Yuelin's LinkedIn

I'm Yuelin Zhao,

  • A Full Stack Software Engineer (emphasize on Front-end / UI-UX)
  • BS & MS of Computer Science Degree at Arizona State University
  • Experienced in JavaScript, TypeScript, React, GraphQL Node.js, SQL/NOSQL.

Most software developers dreamed of being a qualified Full Stack developer, me as well.

I love the feeling of how my work connected with users, so I decided to dedicate myself to the Front-end field. Besides, having the necessary backend skills guarantee to perform better interaction with users and cooperation with other developers.

After graduate with my bachelor's degree in computer science, I decided to gain a Master's degree in computer science, because I believe that a master's degree brings more opportunities and makes me a better frontend software developer.

languages and tools:

GIF

cheatsheet1999's github stats

Most started repository ⭐️

FrontEndCollection

Cheatsheet's github activity graph

frontendcollection's People

Contributors

cheatsheet1999 avatar siyuan25 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

frontendcollection's Issues

What has been deprecated, and what is new on HTML5?

What has been deprecated, and what is new on HTML5?

  • HTML is not the subset of SGML (Standard Generalized Markup Language) anymore. Now, HTML5 added more functions about picture, location, and multitask,

    • canvas
    • video, audio
    • localStorage - used for storing data offline, last for a long time, and will not lose data after closing the browser
    • sessionStorage - same to localStorage, but lose data after closing the browser
    • More semantics labels, such as article, footer, header, nav, section
    • Form components, calendar, date, time, email, URL, search
  • Deprecated labels

    • basefont, big, center, font, s, strike, tt, u, frame

3 Sum

Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.

Notice that the solution set must not contain duplicate triplets.
Screen Shot 2021-09-07 at 7 11 43 PM

function threeSum(nums) {
	const results = []

	// obviously irrelevant if we don't have at least 3 numbers to play with!
	if (nums.length < 3) return results

	// having the numbers in ascending order will make this problem much easier.
	// also, knowing the overall problem  will take at least O(N^2) time, we can
	// afford the O(NlogN) sort operation
	nums = nums.sort((a, b) => a - b)

    // if the question asks us for a custom target, we can control it here
	let target = 0

	for (let i = 0; i < nums.length - 2; i++) {
		// `i` represents the "left" most number in our sorted set.
		// once this number hits 0, there's no need to go further since
		// positive numbers cannot sum to a negative number
		if (nums[i] > target) break

		// we don't want repeats, so skip numbers we've already seen
		if (i > 0 && nums[i] === nums[i - 1]) continue

		// `j` represents the "middle" element between `i` and `k`.
		// we will increment this up through the array while `i` and `k`
		// are anchored to their positions. we will decrement `k` for
		// for each pass through the array, and finally increment `i`
		// once `j` and `k` meet.
		let j = i + 1

		// `k` represents the "right" most element
		let k = nums.length - 1
		
		// to summarize our setup, we have `i` that starts at the beginning,
		// `k` that starts at the end, and `j` that races in between the two.
		//
		// note that `i` is controlled by our outer for-loop and will move the slowest.
		// in the meantime, `j` and `k` will take turns inching towards each other depending
		// on some logic we'll set up below. once they collide, `i` will be incremented up
		// and we'll repeat the process.

		while (j < k) {
			let sum = nums[i] + nums[j] + nums[k]

			// if we find the target sum, increment `j` and decrement `k` for
			// other potential combos where `i` is the anchor
			if (sum === target) {
				// store the valid threesum
				results.push([nums[i], nums[j], nums[k]])

				// this is important! we need to continue to increment `j` and decrement `k`
				// as long as those values are duplicated. in other words, we wanna skip values
				// we've already seen. otherwise, an input array of [-2,0,0,2,2] would result in
				// [[-2,0,2], [-2,0,2]].
				//
				// (i'm not a fan of this part because we're doing a while loop as we're
				// already inside of another while loop...)
				while (nums[j] === nums[j + 1]) j++
				while (nums[k] === nums[k - 1]) k--

				// finally, we need to actually move `j` forward and `k` backward to the
				// next unique elements. the previous while loops will not handle this.
				j++
				k--

			// if the sum is too small, increment `j` to get closer to the target
			} else if (sum < target) {
				j++

			// if the sum is too large, decrement `k` to get closer to the target
			} else { // (sum > target)
				k--
			}
		}
	}

	return results
};

Several Ways to call a function

1. Regular function

this is pointing to Window

function fn() {
    console.log('This is a function');
}

function fn() {
    console.log('This is a function' + this);
}

fn();
fn.call();

2. Method on objects

this is pointing to object => o

because o called sayHI method

let o = {
    sayHi: function() {
       console.log('This is a function');
    }
}

o.sayHi();

3. Constructor

this is pointing to rick because rick instantiate the constructor

this in the prototype object is also pointing to rick

function fn() {}
new fn();

let rick = new fn();
fn.prototype.start = function(){};

4. Register Event function

this in register event function is pointing to the attached element, but in this example

let btn = document.querySelector('button');
btn.onclick = function() {
	console.log(this)
}; //click the button to call the function

5. Timer function

this is pointing to Window

setInterval(function() {}, 1000); //execute function in every second

6. IIFE (Immediately Invoked Function Expression)

this is pointing to Window

(function() {
  console.log('This is a function')
})();

Understanding of 'this' keyword

Scenario 1: 'this' in global environment

It is relatively straightforward in this scenario, the browser in the global environment invokes the function. 'this' is pointing to ** Window**. However, 'this' will point to undefined if 'use strict'.

function f1 () {
    console.log(this)
}
function f2 () {
    'use strict'
    console.log(this)
}
f1() // window
f2() // undefined

There is a very similar question (tedious, useless, but interesting)

const foo = {
    bar: 10,
    fn: function() {
       console.log(this)
       console.log(this.bar)
    }
}
var fn1 = foo.fn
fn1()

Output:

window
undefined
  • this is still pointing to the Window. Although function fn is invoked by the object foo (foo.fn), after assignment to fn1, there is a (). That means we execute fn1 in the global environment. Therefore, the code above still outputs window and undefined.

Now, if we change to

const foo = {
    bar: 10,
    fn: function() {
       console.log(this)
       console.log(this.bar)
    }
}
foo.fn() 

Output

{bar: 10, fn: ƒ}
10
  • this is pointing to the object that invokes the function. Whenever a preceding dot calls a function, the object before that dot is this.
  • To be more clear, in foo.fn(), this is pointing to foo. When executing function, if this in the function is invoked by parent scope, then this will point to parent scope environment, otherwise, this point to global environment

Scenario 2: 'this' in the context environment

Let's dive into examples.

const person = {
    name: 'Lucas',
    brother: {
        name: 'Mike',
        fn: function() {
            return this.name
        }
    }
}
console.log(person.brother.fn())
Mike

Why? Because in these nested relationships, this will point to the LAST object that invokes the function. Here is the brother scope, so we choose the name variable that is in brother scope.

Example 2:

const o1 = {
    text: 'o1',
    fn: function() {
        return this.text
    }
}
const o2 = {
    text: 'o2',
    fn: function() {
        return o1.fn()
    }
}
const o3 = {
    text: 'o3',
    fn: function() {
        var fn = o1.fn
        return fn()
    }
}

console.log(o1.fn())
console.log(o2.fn())
console.log(o3.fn())
o1
o1
undefined

WHAT???
Let's dive into it:

  • First, we got o1 because of o1.fn(), o1 called fn() so this.text will print the variable that is inside o1 object.
  • Second, although it is the o2 that invoked fn(), inside the function of o2, it is o1.fn(). Surprisingly, we jump to o1 and get o1 as its input
  • Last, after the var fn is assigned, it is a normal fn() call, so here this points to the Window, and the answer is, of course, undefined.

A follow-up question, if we want o2 as output for
console.log(o2.fn())
without using call, apply, bind
What should we do?

const o1 = {
    text: 'o1',
    fn: function() {
        return this.text
    }
}
const o2 = {
    text: 'o2',
    fn: o1.fn
}

console.log(o2.fn())

We don't execute o1.fn, instead, we only need the this.text inside o1.fn function. So in o2, we put this.text on o2.fn. Then execute it in the console.log(o2.fn())

Scenario 3: bind / call / apply

const foo = {
    name: 'lucas',
    logName: function() {
        console.log(this.name)
    }
}
const bar = {
    name: 'mike'
}
console.log(foo.logName.call(bar))

The above code will output mike

Scenario 4: this and constructor

function Foo() {
    this.bar = "Lucas"
}
const instance = new Foo()
console.log(instance.bar)

The output will be Lucas, but what happens behind the scene after new with constructor Foo?

  • Create a new Object
  • this in constructor will point to the new object
  • Adding attributes, methods for the object
  • return a new object

The above can be shown as code below

let obj  = {}
obj.__proto__ = Foo.prototype
Foo.call(obj)

Here, we only simulate a naive version of new

Note, if return has been mentioned in a constructor, there are two cases needed to be considered

First

function Foo(){
    this.user = "Lucas"
    const o = {}
    return o
}
const instance = new Foo()
console.log(instance.user)

It will output undefined because instance is an empty object o just returned

Second

function Foo(){
    this.user = "Lucas"
    return 1
}
const instance = new Foo()
console.log(instance.user)

It will output Lucas, which means instance is the object instantiating this

Conclusion: If a value is explicitly returned in the constructor and an object is returned, then this points to the returned object; if the returned object is not an object, then this still points to the instance.

1. During function precompilation, `this` points to `window`    
2. In the global scope, `this` points to `window`   
3. call/apply can change `this` pointing    
4. obj.fn() who calls the method `this` points to whom    

Scenario 5: New story, this in the arrow function

this for arrow functions does not apply to the above standard rules, but is determined according to the outer (function or global) context scope.

const foo = {  
    fn: function () {  
        setTimeout(function() {  
            console.log(this)
        })
    }  
}  
console.log(foo.fn())

In this question, this is in an anonymous function of setTimeout(), so this is pointing to window object. However, we can use arrow functions to make this points to object foo

const foo = {  
    fn: function () {  
        setTimeout(() => {  
            console.log(this)
        })
    }  
} 
console.log(foo.fn())

Scenario 6: Prority of this

We often call the binding of this through call, apply, bind, and new as explicit binding; the pointing of this determined according to the call relationship is called implicit binding.
But which one has a higher priority?

function foo (a) {
    console.log(this.a)
}

const obj1 = {
    a: 1,
    foo: foo
}

const obj2 = {
    a: 2,
    foo: foo
}

obj1.foo.call(obj2)
obj2.foo.call(obj1)

Without call function, the output will be 1 and 2.
Now the output is 2 and 1
which means call, apply has a higher priority.

function foo (a) {
    this.a = a
}

const obj1 = {}

var bar = foo.bind(obj1)
bar(2)
console.log(obj1.a)

By using bind, this in bar has been binded on obj1. After executing bar(2), obj1.a = 2. Which is, after bar(2), obj1 is `{a: 2}

Turn to arrow function

function foo() {
    return a => {
        console.log(this.a)
    };
}

const obj1 = {
    a: 2
}

const obj2 = {
    a: 3
}

const bar = foo.call(obj1)
console.log(bar.call(obj2))

The output will be 2. We first bind this in foo() on obj1. The this of bar (reference arrow function) will also be bound to obj1, and the arrow function binding cannot be modified. Note here, foo() is not an arrow function, that's why we can use call function on foo.

If we refactor foo to arrow function completely

var a = 123
const foo = () => a => {
    console.log(this.a)
}

const obj1 = {
    a: 2
}

const obj2 = {
    a: 3
}

var bar = foo.call(obj1)
console.log(bar.call(obj2))

It will output 123.

Reference

https://www.zhihu.com/question/353757734/answer/964557747
https://blog.kevinchisholm.com/javascript/context-object-literals/

Product of Array Except Self

Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]


Example 1:
Input: nums = [1,2,3,4]
Output: [24,12,8,6]

Example 2:
Input: nums = [-1,1,0,-3,3]
Output: [0,0,9,0,0]


It looks like we fliped the array, because we traverse from the back but get the result on the first index

  1. Traverse from right to left and we got...
    [24, 12, 4, 1]
  2. Traverse from the left to right, finally we got...
    [24, 12, 8, 6] leftMult was [1, 1, 2, 6]
var productExceptSelf = function(nums) {
    const res = [];
    let leftMult = 1;
    let rightMult = 1;
    for(let i = nums.length - 1; i >= 0; i--) {
        res[i] = rightMult;
        rightMult *= nums[i];
    }
    for(let i = 0; i < nums.length; i++) {
        res[i] *= leftMult;
        leftMult *= nums[i];
    }
    return res;
};

Move Zeroes

Given an integer array nums, move all 0's to the end of it while maintaining the relative order of the non-zero elements.

Note that you must do this in-place without making a copy of the array.

Screen Shot 2021-09-11 at 11 12 38 PM

var moveZeroes = function(nums) {
    //we do not need to traverse i, just initialize it to 0, and move its index accordingly.
    let i = 0;
    for(let j = 0; j < nums.length; j++) {
        //as long as nums[j] is not 0, we move the num[j] to nums[i], so original num[j] becomes 0. 
        if(nums[j] !== 0) {
            nums[i] = nums[j];
            //since current nums[i] is not 0, we move i
            i++;
        }
    }
    
    //from the position of i, put all 0's until the ned
    for(let k = i; k < nums.length; k++) {
        nums[k] = 0;
    }
}

A brief introduction of Call, Apply, Bind

Call, Apply, Bind

  • Common
    • They all used to redirect 'this' keywords
  • Difference
    • call & apply will invoke the function, and modify 'this'
    • call passes arg1, arg2... apply passes an array [arg]
    • bind does not invoke a function
  • In practice
    • call is used on inheritance, 'this' in the 'father' class will point to 'son' class
    • apply can work with array, such as seeking for max and min
    • bind will not call the function, and is also able to redirect 'this'
  1. call

    It works in two ways, first, it could be used to call a function. Second, we can use it to redirect "this" in a function

    In some cases, call could be used for inheritance

    fun.call(thisArg, arg1, arg2, ...)
    let o = {
      name: 'andy'
    }
    
    //1. "this" in fn function originally point to the window object, but I want it to point to "o" object
    function fn(a, b) {
      console.log(this);
      console.log(a + b);
    }
    
    fn.call(o, 1, 2) //now fn is pointing to o, and pass two parameters
    
    function Father (uname, age, gender) {
      this.uname = uname;
      this.age = age;
      this.gender = gender;
    }
    
    //Call Father, and change this 
    function Son(uname, age, gender) {
      //Now "this" is pointing to to this function(Son).
      //It implicitly copies this.uname = uname age.... gender...;
      Father.call(this, uname, age, gender)
    }
    
    //Thus, we can use
    let son = new Son('Morty', 18, 'male');
    console.log(son);
    /* Above log outputs:
    Son:
    	age: 18
    	gender: male
    	uname: Morty
    */
  2. apply

    it also calls a function, and modify 'this'

    One of the big advantages is we can coordinate apply with some built-in function, such as Math.max()

    fun.apply(thisArg, [argsArray])
    • thisArg: "this" will point to the place where we desired
    • argsArray: the values we want to pass must contain in an array (at least, it looks like an array...)
    let o = {
      name: 'andy'
    }
    
    function fn(arr) {
      console.log(this);
      console.log(arr);
    }
    
    //we want fn point to "o" object, so
    fn.apply(o, ['morty']);
    /*above line outputs
    	Object, 
    	morty
    */
    
    let arr = [1, 66, 3, 99, 4];
    //null means we don't need to modify "this", but probably not working in strict mode, so I used Math to work around.
    let max = Math.max.apply(Math, arr);
  3. bind

    bind will NOT invoke the function, but it can change 'this' direction

    If we want to modify 'this' direction without invoking the function, then bind is the way to go

    fun.bind(thisArg, arg1, arg2, ...);
    let o = {
      name: 'andy'
    }
    
    function fn(a, b) {
      console.log(this);
      console.log(a + b);
    }
    //remember bind wouldn't invoke function
    fn.bind(o);
    //one way to work around
    let f = fn.bind(o, 1, 2);
    f();
    //it returned a new function after "this" has been changed from original function
    

    Example: if we have a button, after clicking it, the button will be disabled. After 3 seconds, the button is enabled. (Send message verification code in web apps)

    1st edition

    let btn = document.querySelector('button');
    btn.onclick = function() {
      //this point to itself => btn
      this.disabled = true;
      setTimeout(function() {
        //'this' point to window, becuase it is a timer function, and window does not have disabled attribute
        this.disabled = false;
      }, 3000)
    }

    2nd edition 🟡

    let btn = document.querySelector('button');
    btn.onclick = function() {
      //this point to itself => btn
      this.disabled = true;
      //works fine
      let that = this;
     
      setTimeout(function() {
        that.disabled = false;
      }, 3000)
    }

    3nd edition ✅

    let btn = document.querySelector('button');
    btn.onclick = function() {
      //this point to itself => btn
      this.disabled = true;
      setTimeout(function() {
        this.disabled = false;
        //the bind is out of timer function, but inside onclick, so it also points to btn, bind to btn, 'this' points to btn not
      }.bind(this), 3000)
    }

Reverse Linked List

Given the head of a singly linked list, reverse the list, and return the reversed list.

Screen Shot 2021-09-08 at 9 07 14 AM

reverseLinkedlist

With the help with ES6, I found this problem can be easy to solve

var reverseList = function(head) {
    let [prev, current] = [null, head];
    while(current) {
        [prev, current.next, current] = [current, prev, current.next]
    }
    return prev;
};

What can we do to improve a website's performance?

In the perspective of content......

  • Minimize HTTP requests, such as CSS sprite, inline image, and files combination.
  • Minimize DOM elements.

In the aspect of server and Cookie......

  • Utilize CDN, config ETag, and compress components using Gzip.
  • Reduce the size of cookie

In terms of CSS......

  • Avoid CSS expressions
  • Put the stylesheet on top of the file
  • Using <link> but not @import

Ok...What can we do on Javascript......

  • Put Javascript on the bottom of the HTML file
  • Import JS file from outside
  • Minimize DOM operation
  • A lot more we can do on Javascript, but that will be another HUGE topic then.

A brief introduction of the differences between "src" and "href"

  • src is used to replace current element, href is used to build connection between two files.

    <script src="script.js"></script>

    When the browser parses this line of code, it will pause any other execution until the browser finishes executing this line and downloading the source.

    That is the reason why we should put Javascript on the end of the file, instead of on the top.

  • href is the abbr of Hypertext Reference, it connected to the target source file

    <link href="style.css" rel="stylesheet"/>

    The browser will recognize the file is a css file, and then download the resource but NOT stop to execute current file

    That is why we should use link to load css, instead of @import

Binary Tree Preorder Traversal

Given the root of a binary tree, return the preorder traversal of its nodes' values.
Screen Shot 2021-09-07 at 7 30 44 PM
Screen Shot 2021-09-07 at 7 31 39 PM

A Very Straightforward Solution

var preorderTraversal = function(root, res = []) {
    if (!root) return [];
    res.push(root.val);
    if(root.left)  preorderTraversal(root.left, res);
    if(root.right) preorderTraversal(root.right, res);
    return res;
};

An O(N) Solution may be interesting

var preorderTraversal = function(root) {
    if(!root) return [];
    //We need to put a root in the stack first, because Pre-order traverse from root => left => right
    let stack = [root];
    let arr = [];
    while(stack.length) {
        let curr = stack.pop();
        arr.push(curr.val);
        // we want to push right subtree is because the left subtree will be visit first then.
        if(curr.right) {
            stack.push(curr.right);
        }
        if(curr.left) {
            stack.push(curr.left);
        }
    }
    return arr;
};

Binary Search

Given an array of integers nums which is sorted in ascending order, and an integer target, write a function to search target in nums. If target exists, then return its index. Otherwise, return -1.

You must write an algorithm with O(log n) runtime complexity.

Screen Shot 2021-09-09 at 1 17 20 PM

/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 */
var search = function(nums, target) {
    let start = 0;
    let end = nums.length - 1;
    while(start <= end) {
        let mid = Math.floor((start + end) / 2);
        if(nums[mid] === target) {
            return mid;
        }
        else if(target > nums[mid]) {
            start = mid + 1;
        }
        else if(target < nums[mid]) {
            end = mid - 1;
        }
    }
    return -1;
};

Intersection of Two Arrays II

Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays and you may return the result in any order.

Screen Shot 2021-09-12 at 8 42 57 PM

var intersect = function(nums1, nums2) {
    const map = new Map();
    for(let i of nums1) {
        if(map.has(i)) {
            map.set(i, map.get(i) + 1);
        } else {
            map.set(i, 1);
        }
    }
    
    let res = [];
    for(let i of nums2) {
        if(map.has(i) && map.get(i) > 0) {
            res.push(i);
            map.set(i, map.get(i) - 1);
        }
    }
    return res;
};
  • What if the given array is already sorted? How would you optimize your algorithm?
    • Using map built-in data structure in Javascript
  • What if nums1's size is small compared to nums2's size? Which algorithm is better?
    • in second for loop, we can check if the map has a frequence larger than 0, if larger than 0 it means first loop has more
      specific number than in the second loop.
  • What if elements of nums2 are stored on disk, and the memory is limited such that you cannot load all elements into the
    memory at once?
    • Split the numeric range into subranges that fits into the memory. Modify code to collect counts only within a given subrange, and call the method multiple times (for each subrange).

What is the difference between display:none and visibility:hidden style?

They all make elements invisible.

But

  • visibility: hidden hides the element, but it still takes up space in the layout. display: none removes the element completely from the document. It does not take up any space, even though the HTML for it is still in the source code.
  • display: none cannot be inherited.
  • display: none will adjust the spaces, thus automatically aligns the text following it to cover the space, but in case of visibility: hidden space remains intact.

Unit 2 Exploring Databases and SQL

Knowledge Check: Relational Algebra 1

  1. Given two tuple sets (A with 10 elements and B with 5 elements), what is the maximum number of tuples in the union of these sets?
  • 10
  • [Correct] 15 (The maximum number of tuples is achieved when there are no common elements between A and B)
  • 5
  • 50
  1. Which mathematical operator must be used in order to display information about students who are majoring in Computer Science but not in Electrical Engineering?
  • [Correct] Difference (The difference operator displays the requested information)
  • Intersection
  • Union
  • Cartesian Product
  1. Which statement about the selection operator is true?
  • [Correct] It filters certain tuples in a relation based on given criteria. (This is the function of the selection operator)
  • It filters certain attributes in a relation based on given criteria.
  • It requires more than one relation as its input.
  • It requires more than one database as its input.

Knowledge Check: Relational Algebra 2

  1. Consider a relation, STUDENT, with the following attributes: Name, ID number, Major, Graduation Year, and GPA. Consider a query using this relation: “List the names and ID numbers of students majoring in Computer Science.” Which operator is absolutely necessary for this query?
  • Intersection
  • Union
  • Difference
  • [Correct] Projection (The projection operator is necessary to display the two attributes, name, and ID number, in the query)
  1. Consider two sets: A with 10 tuples, and B with 5 tuples. What is the maximum number of tuples that the intersection of A and B can have?
  • 15
  • [Correct] 5 (The number of tuples in the intersection must be less than the minimum number of tuples in A and B)
  • 50
  • 10
  1. What is the ϴ-Join operation used for?
  • To join two tuples in the same relation.
  • To join two attributes in the same relation.
  • To join two databases.
  • [Correct] To join two relations in a database.

Screen Shot 2021-10-02 at 10 00 51 PM

  1. Which statement about the selection operator is correct?
  • It displays certain tuples based on given criteria. (This is the output of the selection operator)
  • It displays certain attributes based on given criteria.
  • It requires more than one relation.
  • It requires more than one attribute.

Unit 1 & 2: Graded Quiz

  1. Which of the following is NOT one of the levels of abstraction for databases?
  • Physical Schema
  • Conceptual Schema
  • [Correct] Filesystem Schema
  • Views
  1. Table descriptions are an example of ______ level documentation.
  • Physical Schema
  • Views
  • Filesystem Schema
  • [Correct] Conceptual Schema
  1. A particular query that pulls information from one or more tables is an example of a:
  • [Correct] View
  • Conceptual Schema
  • Physical Schema
  • Relation
  1. Which of the following database types is most oriented toward storing well-structured data?
  • NoSQL Database
  • Hadoop
  • [Correct] Relational Database
  • Spark
  1. What major advantage do NoSQL database systems have?
  • [Correct] NoSQL database systems can deal with unstructured data
  • NoSQL database systems data is highly structured
  • NoSQL database systems bundle massive scale well
  • NoSQL database systems are good for operational data.
  1. In an ER Diagram, a diamond shape indicates what?
  • An attribute
  • [Correct] A relationship
  • A constraint
  • An entity
  1. A participation constraint is indicated how in an ER diagram.
  • A dotted line
  • A dashed line
  • A line
  • [Correct]A bold line
  1. Consider the query: ∏𝑎,𝑏(𝜎𝑐=2(𝑧∪𝑦)) What does the query return?
  • [Correct] Fields a and b of the rows from z and y where c=2.
  • Fields a, b, c or the rows from the intersection of z and y where c=2.
  • Fields a,b, and c of the rows from y and z where c=2.
  • Fields a and b of the rows from the intersection of z and y where c=2.
  1. What does the relational algebra operator ‘x’ indicate?
  • The union of the two tables.
  • [Correct] All possible pairs from the two tables.
  • All pairs from the two tables matched on a specified field.
  • The intersection of the two tables.
  1. Of the three elements in the basic SQL query, which is the only optional one?
  • FROM
  • [Correct] DISTINCT
  • SELECT
  • WHERE
  1. Massive scale analytics merely require which type of database system?
  • [Correct] Hadoop, Spark, or similar
  • MongoDB
  • Oracle
  • NoSQL
  1. The basic formula for an SQL query is:
    [Correct] SELECT, FROM, WHERE
    TARGET, RELATION, DISTINCT
    DISTINCT, FIELD, ID
    DISTINCT FROM QUALIFICATION

Implement curry()

Currying is a useful technique used in JavaScript applications.

Please implement a curry() function, which accepts a function and return a curried one.

Here is an example

const join = (a, b, c) => {
   return `${a}_${b}_${c}`
}

const curriedJoin = curry(join)

curriedJoin(1, 2, 3) // '1_2_3'

curriedJoin(1)(2, 3) // '1_2_3'

curriedJoin(1, 2)(3) // '1_2_3'

Regular function

function curry(fn) {
    return function curried(...args) {
        // 1. if enough args, call func
        // 2. if not enough, bind the args and wait for new one

        if (args.length >= fn.length) {
            // 'this' is pointing to Window, apply is used to call the function fn
            //console.log(this)
            return fn.apply(this, args)
        } else {
            // 'this' is pointing to Window
            //console.log(this)
            return curried.bind(this, ...args)

        }
    }
}

Using arrow function, this is no need to apply or bind, since 'this' in arrow function inherited from the parent scope
Sep-10-2021 22-11-34

function curry(fn) {
  return function curried(...args) {
    if (args.length >= fn.length) {
         return fn(...args);
       } else {
         return (...args2) => curried(...args, ...args2);
       }
    }
}

HTML5 offline storage mechanism

Users are online

When the browser finds manifest attribute on HTML head, it will request the manifest file.

  • If this is the first time visiting,

    • Then the browser will download the corresponding resources and store data based on the manifest file.
  • If not the first time visiting,

    • Then the browser will use the offline resource to load the page, then compares the old manifest file with the new manifest file, and update the manifest file if needed

Users are offline

  • The offline storage of HTML5 is based on a .appcache file. It works somehow like Cookie, which means web data will be downloaded and show the web data when users are offline

GET vs POST

GET is used to request a specified resource from server.

Some other notes on GET requests:

  • GET have no body data
  • GET requests can be cached
  • GET requests remain in the browser history
  • GET requests can be bookmarked
  • GET requests should never be used when dealing with sensitive data
  • GET requests have length restrictions
  • GET requests are only used to request data (not modify)

POST is used to send data to a server to create/update a resource.

Some other notes on POST requests:

  • POST have body data
  • POST requests are never cached
  • POST requests do not remain in the browser history
  • POST requests cannot be bookmarked
  • POST requests have no restrictions on data length

Unit 3: Data Storage

Lesson Introduction: Major Data Storage Layouts

Much of the success in computer technology, has been the tremendous progress that data storage has undergone. When dealing with big data, the amount of data will directly have an influence on the performance of the system.

In this Unit, we will learn more about Memory Hierarchy and both internal and external data storage.

We will be able to relate the need for external data storage with large internet-based applications that require new and more scalable storage solutions. An example is cloud-based storage systems like AWS.

Screen Shot 2021-09-28 at 5 13 51 PM

Topic: Introduction to Data Storage

How data is stored?
Normally, data is stored in a secondary storage device, which is the hard disk, to process the data in a computer, we need to load data into the main memory.

Processing Speed
CPU Register => CPU Cache => Main memory => Hard disk (Secondary Storage)

Internal Data Storage
Hard disk is a mechanical device, that's why it is very slow.
Back to the date, people use tape, because that is super cheap.
Modern, people use SSD, a lot faster than Hard disk.

Data on External Storage

  • File
    • A logical collection of data, physically stored as a set of pages
  • File Organization
    • Method of arranging a file of records on external storage, organized by Record ID(rid)
  • Architecture
    • Buffer manager stages pages from external storage to the main memory buffer pool.
    • File and index layers make calls to the buffer manager.

Why do we have a buffer manager?
Memory is smaller than disk, so we cannot load every data into the main memory at once, we can only load it page by page.

Lesson Introduction: Alternative File Organizations

In addition to traditional data storage, there are alternative file organizations. Many alternatives exist, each ideal for some situations, and not so good for others. We will explore more about Heap (random order) files, Sorted files, and Indexes in this topic.

Screen Shot 2021-09-28 at 5 44 43 PM

The Cost Model
The number of page accesses is a cost measure.
Reasoning
Page access cost is usually the dominant cost of database operations. An accurate model is too complex for analyzing algorithms.
Reading 3 pages is actually less time-consuming than reading just one page.

Heap File Advantage / Disadvantage
Advantage:

  • Efficient
    • for bulk loading data, (don't care about the order, just keep inserting)
    • for relatively small relations as indexing overheads are avoided
    • When queries need to fetch a large proportion of stored records

Disadvantages:

  • Not Efficient
    • for selective queries
    • sorting is time-consuming

Indexes

  • File Index
    • Speeds up selections on the search key fields
    • Any subset of the fields of a relation can be search key for an index on the relation
    • An index contains a collection of data entries and supports efficient retrieval of all data entries k* with a given value k

B+ Tree Indexes
Most popular indexes structure in the database system
Non-leaf pages have index entries; only used to direct searches.

Screen Shot 2021-09-28 at 6 27 20 PM

Knowledge Check: Data Storage

  1. Where is the database stored in a computer?
  • Central Processing Unit
  • [Correct] Hard disk (A database is stored in the hard disk of a computer.)
  • Memory
  • Cache
  1. What is the correct order of processing speed of major units in a computer from the fastest to slowest?
  • CPU, cache, memory, hard disk
  1. Why is the processing speed of a traditional computer hard disk lower than a modern solid-state drive (SSD)?
  • [Correct] Because a hard disk is a mechanical device. Contrary to the solid-state drive, a hard disk has to spin and spend more time to find a requested data byte)
  • Because solid state drive is a mechanical device.
  • Because the size of a solid state drive is bigger than that of a hard disk.
  • Because a hard disk can only read pages in sequence.
  1. What is the name of the software component in a computer that loads pages from hard disk into memory?
  • Memory Manager
  • [Correct] Buffer Manager (Buffer manager loads pages from hard disk into memory)
  • Load Manager
  • Index Manager

Top K Frequent Elements

Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order.

Screen Shot 2021-09-07 at 6 43 26 PM

var topKFrequent = function(nums, k) {
    const map = new Map();
    const res = [];
    const freqArr = [];
    
    for(let num of nums) {
        map.set(num, (map.get(num) || 0) + 1);
    }
    
    for(let [num, freq] of map) {
        freqArr[freq] = (freqArr[freq] || new Set()).add(num);
    }
    
    for(let i = freqArr.length - 1; i >= 0; i--) {
        // if(freqArr[I]) is necessary because not all index has element attached to it
        if(freqArr[i]) res.push(...freqArr[i]);
        if(res.length === k) break;
    }
    return res;
};

Time complexity : O(n)

Construct Binary Tree from Preorder and Inorder Traversal

Given two integer arrays preorder and inorder where preorder is the preorder traversal of a binary tree and inorder is the inorder traversal of the same tree, construct and return the binary tree.

Screen Shot 2021-09-04 at 8 54 05 PM


This is a very basic question and tested us about inorder and preorder traverse.

/**
 * Definition for a binary tree node.
 * function TreeNode(val, left, right) {
 *     this.val = (val===undefined ? 0 : val)
 *     this.left = (left===undefined ? null : left)
 *     this.right = (right===undefined ? null : right)
 * }
 */
/**
 * @param {number[]} preorder
 * @param {number[]} inorder
 * @return {TreeNode}
 */
var buildTree = function(preorder, inorder) {
    if(!inorder.length) return null;
   // The first node of preorder is always the root of the tree
    let root = new TreeNode(preorder.shift())
    let index = inorder.indexOf(root.val);
   // Inorder traverse, every elements on the left side of the root would be the left tree,
   // the elements on the right of the root will be the right subtree
    let leftTree = inorder.slice(0, index);
    let rightTree = inorder.slice(index + 1);
    
    root.left = buildTree(preorder, leftTree);
    root.right = buildTree(preorder, rightTree);
    return root;
};

Coin Change

You are given an integer array coins representing coins of different denominations and an integer amount representing a total amount of money.

Return the fewest number of coins that you need to make up that amount. If that amount of money cannot be made up by any combination of the coins, return -1.

You may assume that you have an infinite number of each kind of coin.
Screen Shot 2021-09-05 at 11 57 36 PM

A very interesting and typical Dynamic Programming problem, I really am not a big fan of it.
You may find this video helpful

/**
 * @param {number[]} coins
 * @param {number} amount
 * @return {number}
 */

// cannot use greedy: 1 3 4 5, if minus 5 first, ends up with 3 steps, but 3 + 4 only uses 2 steps!!
var coinChange = function(coins, amount) {
     // dp[i] represents the least amount of coins that can make the value equals to the i
    const dp = new Array(amount + 1).fill(Infinity);
    dp[0] = 0;
    for(let i = 1; i <= amount; i++) {
        for(let coin of coins) {
            if(i - coin >= 0) {
                // dp[i - coin] + 1 because at least we will have 1 step
                 dp[i] = Math.min(dp[i], dp[i - coin] + 1);
            }
        }
    }
    return dp[amount] === Infinity ? -1 : dp[amount];
};

Search Insert Position

Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

You must write an algorithm with O(log n) runtime complexity.

Screen Shot 2021-09-09 at 1 38 36 PM

/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 */

//Due to the fact that "start" will always approach the target if "mid" did not match target
var searchInsert = function(nums, target) {
    let start = 0, end = nums.length - 1;
    while(start <= end) {
        let mid = Math.floor((start + end) / 2);
        if(nums[mid] === target) {
            return mid;
        } else if(nums[mid] < target) {
            start = mid + 1;
        } else if(nums[mid] > target) {
            end = mid - 1;
        }
    }
    return start;
};

Merge Intervals

Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.


Example 1:
Input: intervals = [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6].
Example 2:

Input: intervals = [[1,4],[4,5]]
Output: [[1,5]]
Explanation: Intervals [1,4] and [4,5] are considered overlapping.


/
  @param {number[][]} intervals
  @return {number[][]}
 /
function merge(intervals) {
  if (!intervals.length) return intervals
    //让每一个数组的第一个数是从小到大排列
  intervals.sort((a, b) => a[0] - b[0])
    //按顺序拿到一个数组
  let prev = intervals.shift()
  //res (pass by reference) = prev
  let res = [prev]
// Traverse element in intervals, because we need an array with 2 elements, inseatd of a single number in a specific array
  for (let curr of intervals) {
	// must have a =, otherwise cannot pass [[1,4][4,5]]
    if (curr[0] <= prev[1]) {
      prev[1] = Math.max(prev[1], curr[1])
    } else {
      res.push(curr)
      prev = curr
    }
  }
  return res
}

Gas Station

There are n gas stations along a circular route, where the amount of gas at the ith station is gas[i].

You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from the ith station to its next (i + 1)th station. You begin the journey with an empty tank at one of the gas stations.

Given two integer arrays gas and cost, return the starting gas station's index if you can travel around the circuit once in the clockwise direction, otherwise return -1. If there exists a solution, it is guaranteed to be unique

262351630992022_ pic_hd

/**
 * @param {number[]} gas
 * @param {number[]} cost
 * @return {number}
 */
//其实是看totaltank里的油够不够开一圈
//curTank看现在的油是多少,只要不是负数就证明油够,就不加pos了,油不够就去下一个pos看看
//
var canCompleteCircuit = function(gas, cost) {
    let curTank = 0, totalTank = 0, pos = 0;
    for (let i=0;i<gas.length;i++) {
        curTank+= gas[i] - cost[i];
    //totalTank cannot depend on curTank, because curTank may become negative, //and total will be affected.
    //if solution existed, totalTank always larger than 0
        totalTank+= gas[i] - cost[i];
        if (curTank<0) {
            curTank = 0;
            pos = i+1;
        }
    }   
    return totalTank<0?-1:pos;
};

Hidden Markov Models

HMM can be viewed as dynamic Bayesian networks

  • We learned that DBN can be used to model given conditional independencies.

Discrete Markov Process

Transition prob of states

  • consider a system that may be described at any time as being in one of a set of N distinct states. S1...SN.

Use Markov to describe the transition

Screen Shot 2021-09-30 at 12 07 53 PM

s means state, t - 1, each one we have n value, if no limited, the probability is hard to specify
Screen Shot 2021-09-30 at 12 08 55 PM

Given the state at time t - 1, we don't care about t-2 anymore because it is a first-order Markov chain

Screen Shot 2021-09-30 at 12 10 43 PM

The transition from state i to state j.
Screen Shot 2021-09-30 at 12 13 19 PM
If I know today's weather, I can guess tomorrow's weather based on the understanding of past weather.

An example
Screen Shot 2021-09-30 at 12 17 46 PM

For example, Today is rainy, tomorrow will be cloudy, the probability is 0.3, based on the matrix.

Given the weather on day 1 being sunny, what's the prob that the following 7 days are sun-sun-rain-rain-sun-cloudy-sun?
Convert to more formal format:
{S3,S3,S3,S1,S1,S3,S2,S3}
=> Find P(O|Model)

Extension to an HMM

  • The previous example is an "Observable" Markov model, the output of the system/process in the states of interest.

Now:
We also want to observe if we have the same weather for the next few days.

Screen Shot 2021-09-30 at 12 28 48 PM

Specifying an HMM

Screen Shot 2021-09-30 at 12 34 26 PM

Given HMM

Screen Shot 2021-09-30 at 12 35 19 PM

  1. What is the most likely state sequence?

Inline elements, Block elements, and what are the differences?

  • Inline elements are: span, input, select, strong ....
  • Block elements are: div, ul, ol, li, dl, dt, dd, h1, h2, p....
  • Void elements: br, hr, i, input, link...
  • img(they are "inline block" elements. This means that they flow inline like text, but also have a width and height like block elements.)
  • Inline elements do not accept "height" and "width" setttings.
  • Block elements occupy the whole row, and accept "height" and "width"

Squares of a Sorted Array

Given an integer array nums sorted in non-decreasing order, return an array of the squares of each number sorted in non-decreasing order.

Screen Shot 2021-09-10 at 7 24 28 PM

Here is O(n) solution because the intuitive version is trivial

/**
 * @param {number[]} nums
 * @return {number[]}
 */
var sortedSquares = function(nums) {
    //1. We declare a result array first
    let res = [];
    //2. Put two pointers at the front and end
    let l = 0;
    let r = nums.length - 1;
    //3. Declare a special pointer 'p' for the result array only, we should make p points to the last of the array instead of 1st index, because absolute value of a negative number may become very large 
    let p = r;
    
    while(l <= r) {
        if(nums[l] ** 2 > nums[r] ** 2) {
            res[p] = nums[l] ** 2;
            l++;
            p--;
        } else {
            res[p] = nums[r] ** 2;
            r--;
            p--;
        }
    }
    return res;
    
};

Unit 1 - 6 Practice Questions Solutions

  1. Which of the following are the advantages of using a DBMS?
    (All Correct)
    a. Data Independence
    b. Data Security
    c. Concurrency
    d. Data Administration

  2. At which level of abstraction is the logical structure defined?
    a. Internal Schema
    b. External Schema
    c. [Correct] Conceptual Schema
    d. Physical Schema

  3. Which of the following is true with regard to weak entities?
    a. Owner entity set and weak entity set can participate in a many-to-many relationship.
    b. [Correct] Owner entity set and weak entity set must participate in a one-to-many relationship.
    c. [Correct] Weak entity must have total participation in the identifying relationship set. (When the owner entity is deleted, all owned weak entities must also be deleted.)
    d. Weak entities can exist without the owner entity

  4. SQL is a ______________ language.
    a. Representative
    b. [Correct] Declarative (A declarative language tells what data is to be retrieved but does not tell the system how to retrieve the data.)
    c. Functional
    d. Procedural

  5. Which query can be used to list the student information for computer science majors [C]
    who are not double majors in electrical engineering [E]?
    a. [Correct] C - E (The difference operator, ‘-’ can be used to list the necessary information.)
    b. C U E
    c. E x C
    d. E - C

  6. Which of the following is true when using Heap Files?
    a. [Correct] Heap Files are efficient for loading bulk data.
    b. Heap Files are efficient for sorting.
    c. [Correct] Heap Files are not efficient for selective queries.
    (1. Heap files are not efficient for sorting and may be time-consuming.
    Heap files are efficient while working on relatively small relations as indexing overheads
    are avoided.)
    d. Heap Files are not efficient while working on relatively small relations.

  7. Which component loads pages from hard disk to memory?
    a. Load Manager
    b. [Correct] Buffer Manager (Buffer manager stages pages from external storage to the main memory buffer pool)
    c. Page Manager
    d. Memory Manager

  8. Which of the following questions should be answered before creating an index?
    a. [Correct] What field(s) should be the search key?
    b. [Correct] Should you build several indexes?
    c. [Correct] Which relations should have indexes?
    d. What records(s) should be the search key? (False, The record(s) retrieved should not affect the decision of choosing an index)

  9. Which clustered index is the best choice for the following condition:
    Age = 35 40,000 < Sal < 80,000
    a.
    b.
    c. [Correct] <Age,Sal>
    (<Age,Sal> is a better choice than <Sal,Age> as the conditions use equality selection on
    the age attribute and a range selection over the salary attribute.)
    d. <Sal,Age>

  10. Which of the following indexes can be used to implement an index-only plan to evaluate the following query: [E.ssn is the primary key in this relation]

Screen Shot 2021-10-03 at 5 29 02 PM

a. b. c. d. Even though is a more optimal choice, even can be used to implement an index-only plan in this case.
  1. Which of the following is not a principle of database transaction:
    a. Atomicity
    b. Consistency
    c. [Correct] Integrity
    (Atomicity, Consistency, Isolation, and Durability are the four principles, which are also
    known as the ACID properties.)
    d. Durability

  2. Consider the following transactions:
    T1: X = X + 1300 Y = X - 800
    T2: X = X * 0.85 Y = Y * 1.25
    i. Initial value of X is 2000 and Y is 5000.
    ii. T1 arrives first.
    iii. Serial Schedule
    d. Y = 3125.00
    End of T1: X = 3300; Y = 2500 End of T2: X = 2805; Y = 3125

  3. Which component manages lock based concurrency control for transactions?
    a. [Correct] Lock manager (All lock and unlock requests are handled by the lock manager)
    b. Concurrency manager
    c. Buffer manager
    d. Control Manager
    e. Transaction manager

  4. Which lock can be upgraded should a transaction need to write into the database?
    a. Read lock
    b. Concurrency lock
    c. [Correct] Shared lock
    (If a transaction already holds a shared lock, it can be upgraded to hold an exclusive lock)
    d. Exclusive lock
    e. Write lock

  5. There are 4 transactions with 2 atomic instructions in each. How many possible serial
    schedules can be made?
    a. 6
    b. 8
    c. 16
    d. [Correct] 24 (4 transactions can be scheduled in 4! = 432*1 = 24 ways)

Binary Tree Inorder Traversal

Given the root of a binary tree, return the inorder traversal of its nodes' values.

Screen Shot 2021-09-07 at 11 00 18 PM

Screen Shot 2021-09-07 at 11 00 47 PM

Recursive Solution

var inorderTraversal = function(root, res = []) {
    if(!root) return [];
    if(root.left) root.left = inorderTraversal(root.left, res);
    res.push(root.val);
    if(root.right) root.right = inorderTraversal(root.right, res);
    return res;
}

O(n) iterative solution is awesome!

/*
As long as there is root or stack has length, we loop over. 
In the loop, if there is a root, we push root into stack and go see the left, 
until there is no root on left subtree,  then we find the nearest last root,
and put it into stack, then loop the right subtree.
*/
var inorderTraversal = function(root) {
    let stack = [];
    let res = [];
    while(root || stack.length) {
        if(root) {
            stack.push(root);
            root = root.left;
        } else {
            //find the nearst root
            root = stack.pop();
            res.push(root.val);
            root = root.right;
        }
    }
    return res
}

Unit 1: Basic Data Processing Concepts

Topic: Data Models

Levels of Abstraction

Screen Shot 2021-10-03 at 11 40 38 PM

Many views, single conceptual (logical) schema and physical schema.

  • Views describe how users see the data
  • Conceptual schema defines the logical structure
  • Physical schema describes the files and indexes used

Topic: Entity-Relationship Model (ER)

  • Phase 1: Requirement Analysis
  • Phase 2: Conceptual DB design
  • Phase 3: Logical DB design

ER Model is used at Conceptual DB design

ER model Basics

  • Entity: An entity is described using a set of attributes
  • Entity set: A collection of similar entities, e.g. All employees
    - Entity set has a key
    - Each attribute has a domain
  • Relationship: Association among 2 or more entities
  • Relationship Set: Collection of similar relationships

Key Constriants

Screen Shot 2021-10-04 at 11 43 24 AM

Each dept has AT MOST one manager, according to the Key constraint on Manages

Participation Constraints

  • Does every department have a manager?
    • if yes, this is a participation constraint: the participation of Departments in Manages is said to be total(vs. partial)

Thin line: Key participation
Bold Line: At least once, participation constraint, total participation
Bold Line with an arrow: Exactly once

Weak Entities

  • A weak entity can be identified uniquely only by considering the primary key of another (owner) entity.
    • Owner entity set and weak entity set must participate in a 1 : n relationship set. (One owner, many weak entities)
    • Weak entity set must have total participation in this identifying relationship set

Sum up

  • Conceptual design follows requirements analysis
    • Yields a high-level description of data to be stored

Knowledge Check: Introduction to Big Data and Data Processing Systems

  1. What kind of software should be used if one needs to store data online, make certain parts of it accessible by different user types, and searchable?
  • Word processing software
  • Spreadsheet software
  • [Correct] Database management software (Database management software is designed to implement all of these tasks)
  • Presentation software

Unit 4: Data Indexing

Lesson Introduction: Major Indexing Schemes in Database Systems

Screen Shot 2021-09-12 at 8 04 20 PM

Topic: Hash-based Indexes

Hash-based indexes, the hash function is built upon the function that we do the hasing on. For example, id = 2, the hash function is on id

  • Good for equality selections
  • ⬇️ The formular decide which bucket the data stored in

Screen Shot 2021-09-22 at 2 34 19 PM

Index entries help people to navigate and search, data entries is the last level where people retrieve the data where it's stored in the database

Lesson Introduction: Index Classification

We know that data is stored in the form of records. Every record has a key field, this make this field be recognized uniquely. An index is a data structure that locates these key fields within the database file. There are several different indexing systems.
Screen Shot 2021-09-22 at 2 45 24 PM

Topic: Index Classification

  • Clustered index is very well organized, its the same sorting order, the data entries and data records have.
  • Unclustered index: The sorting order in the data entry is not similar to the sorting order of the data records

One table can only have one clustred index since sorting order need to follow data records in a exact same way, but we can have as many unclustered index as needed, because there are many combinations of sorting order.

Index selection guidelines

  • Attribute in WHERE clause. (These are good candidate to add index keys), if the index we are gonna create is benefit multiple queries, that is a good criteria.

Screen Shot 2021-09-22 at 3 13 51 PM

If condition is: age = 30 AND 3000 < salary < 5000
Clustered <age, salary> index is much better than <salary, age>, since age is a euqality attribute and lot more specific and selective

Knowledge Check: Major Indexing Schemes

  1. Which of the following database operations can be achieved by using hash-based indexes?
  • To retrieve student data where age is between 18 and 20.

  • [Correct] To retrieve student data where age is equal to 20. (Hash-based indexes are good for equality selections.)

  • To retrieve student data where age is less than 20.

  • To retrieve student data where age is different than 20

  1. If a database table has m rows and n columns, what is the maximum number of clustered indexes for this table?
  • mn
  • m
  • n
  • [Correct!] 1 (A database table can only have one clustered index.)

Unit 3 & 4: Practice Quiz

  1. Which of the following file organizations must be used if one needs to retrieve all records in random order?
  • Heap Files
  1. For which type of operations are heap files a sufficient method?
  • Bulk loading data (Bulk loading data does not require special treatment. Therefore, heap files are sufficient for such operations.)
  1. What is the purpose of file indexes?
  • Searching Data (File indexes are created to speed up data search process.)
  1. In terms of decreasing the time it takes to process data searches, when does it make sense to create indexes for a database table?
  • When data retrieved by queries is a small percentage of the available data in the table. (Indexes are most useful when data retrieved by queries is a small percentage of the available data.)
  1. Creating indexes is not a straightforward decision because of the costs involved. One must answer certain questions before creating indexes. Which of the following questions is not relevant?
  • Should one build multiple indexes?
  • [Correct] Which record(s) should be part of an index?
  • Which field(s) should be part of an index?
  • Which tables should be indexed?

Unit 3 & 4: Quiz

  1. Which of the following computer components has the fastest processing speed?
  • CPU
  1. Which of the following computer components has the slowest processing speed?
  • Hard Disk
  1. The buffer manager loads pages from hard disk to which part of the computer?
  • Memory
  1. Which of the following statements about heap files are correct?
  • Heap files are in random order.
  1. What kind of file organization is sufficient for bulk loading data?
  • Heap Files (Bulk loading data does not require special treatment. Therefore, heap files are sufficient for such operations.)
  1. What kind of indexing scheme should be used in order to retrieve data on customers whose zip code is equal to 06902?
  • Hash-based index (Hash-based indexes are good for equality selections.)
  1. Which of the following is the biggest disadvantage of using indexes in a database?
  • Indexes require extra storage, which is a disadvantage
  1. Which of the following is not a decision variable when building indexes?
  • The records to be included in an index. (The records are the outcome of an index; they are not a decision variable.)
  1. Where are index files permanently stored in a computer?
  • Hard disk

Screen Shot 2021-09-12 at 8 10 52 PM

  1. Where is database stored in a computer?
    Central Processing Unit
    ✅ Hard disk (A database is stored in the hard disk of a computer)
    Memory
    Cache

  2. What is the correct order of processing speed of major units in a computer from the fastest to slowest?
    ✅ CPU, cache, memory, hard disk

  3. Why is the processing speed of a traditional computer hard disk lower than a modern solid state drive (SSD)?
    ✅ Because hard disk is a mechanical device. (Contrary to solid state drive, a hard disk has to spin and spend more time to
    find a requested data byte
    )
    Because solid state drive is a mechanical device.
    Because the size of a solid state drive is bigger than that of a hard disk.
    Because a hard disk can only read pages in sequence.

  4. What is the name of the software component in a computer that loads pages from hard disk in to memory?
    ✅ Buffer Manager

  5. Which of the following database operations can be achieved by using hash-based indexes?
    ✅ To retrieve student data where age is equal to 20.
    Hash-based indexes are good for equality selections.

  6. If a database table has m rows and n columns, what is the maximum number of clustered indexes for this table?
    ✅ A database table can only have one clustered index.

  7. Which of the following file organizations must be used if one needs to retrieve all records in random order?
    ✅ Heap Files

  8. ** For which type of operations are heap files a sufficient method?**
    ✅ Bulk loading data does not require special treatment. Therefore, heap files are sufficient for such operations.

  9. What is the purpose of file indexes?
    ✅ File indexes are created to speed up data search process.

  10. In terms of decreasing the time it takes to process data searches, when does it make sense to create indexes for a database table?
    ✅ Indexes are most useful when data retrieved by queries is a small percentage of the available data.

  11. Creating indexes is not a straightforward decision because of the costs involved. One must answer certain questions before creating indexes. Which of the following questions is not relevant?
    Should one build multiple indexes?
    ✅ Which record(s) should be part of an index?
    Which field(s) should be part of an index?
    Which tables should be indexed?

What happens when you type in a URL


  • After we type a URL, the browser will try to find the server’s IP that is related to the URL. First, the browser will look up the cache, and see if there is a record in cache. The order would be from browser cache => system cache => router cache, If there is no record in cache, then the browser will check the “hosts” file in the system. If the record still cannot be found, the browser will check DNS.

  • Second, after the browser gets the server’s IP, the browser will send a HTTP request based on that IP and port. The HTTP request would be encapsulated in a TCP package. That TCP package will pass the transport layer, network layer, data link layer and physical layer to reach the server.

  • Third, the server will respond to the request and return corresponding HTML to the browser. The reason behind the scene is because HTML is a tree structure, so the browser would build a DOM tree based on that HTML. If encountered javascript when constructing the DOM tree, then the browser will stop building the DOM tree and execute the code. (That’s why JS code should be put after the HTML). The CSSOM tree will be built if we have CSS code, and later on it will combine the DOM tree together.


Longest Consecutive Sequence

Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.
You must write an algorithm that runs in O(n) time.


Example 1:
Input: nums = [100,4,200,1,3,2]
Output: 4
Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4.

Example 2:
Input: nums = [0,3,7,2,5,8,4,6,0,1]
Output: 9


/**
 * @param {number[]} nums
 * @return {number}
 */
var longestConsecutive = function(nums) {
    //First, we need a set that stores UNIQUE numbers
    let set = new Set(nums);
    //initialize the longest result to 0
    let longest = 0;
    for(let i of set) {
        //if this is not the start of consecutive sequence, skip this iteration
        if(set.has(nums[i] - 1)) continue;
        let length = 1;
        let curr = nums[i];
        //if we have a sequence, increase the length
        while(set.has(curr + 1)) {
            curr++;
            length++;
        }
        //if this is longest consecutive sequence
        longest = Math.max(length, longest);
    }
    return longest;
};

Unit 5: Transactions and Recovery

Lesson Introduction: ACID Properties

Screen Shot 2021-09-20 at 3 54 44 PM

Topic: Principles of Transactions: ACID Properties

Atomicity:

  • A transaction might commit after completing all its actions, or it could abort after excuting some actions
  • Always executing all actions, or not excuting any actions at all
  • DBMS logs all actions so that it can undo the actions of aborted transacations.

Consistency

  • No violation of integrity constrains
  • A transaction which executes alone against a consistent database leaves it in a consistent state.
  • Transactions do not violate database integrity constrains.
  • Transactions are correct programs.

Isolation (Transacation are isolated or protected)

  • Serializability: If several transcations are executed concurrently, the results must be the same as if they were executed serially in some order.
  • Incomplete results: An incomplete transcation cannot reveral its results to other transcations before its commitment.

Durability

  • Once the transaction commits, the system must guarentee that the results of its operations will never be lost.
  • Database recovery.

A transaction is seen by DBMS as a series, or list of actions. The action can read and write

Knowledge Check: ACID Properties

  1. What is a sequence of reads and writes from/to a database called?
  • Transaction
  1. How does a database achieve concurrency?
  • A database can process multiple transactions concurrently by interleaving them.
  1. What are the four principles of database transactions?
  • Atomicity, Consistency, Isolation, Durability
  1. Which of the following describes the atomicity principle of database transactions?
  • All of the components of a transaction run in their entirety, or none of them run at all.

Topic: Concurrency Control

We call such interleave - Schedule

Serial Schedule

  • Schedule that does not interleave the actions of different transactions. T1 first, and then T2, or T2 first and then T1, NOT interleave each other.

Equivalent Schedule

  • The effect of executing first schedule is the same as the effect the second schedule

Serializable Schedule

  • A schedule that is equivalent to some serial execution of the transcations

Conflict Serializable Schedules

  • Two schedules are conflict equivalent if

    1. involve the same actions of the same transcations.
    2. Every pair of conflicting actions is ordered the same way
  • Schedule S is conflict serializable if S is conflict equivalent to some serial schedule

Dependency Graph

  • if there's NO CYCLE in the graph, that schedule is conflict serializable, which is great 👍
  • If there is a cycle, that is not conflict serializable, which might lead inconsistency in the database.

Screen Shot 2021-09-20 at 5 43 19 PM

Screen Shot 2021-09-22 at 1 44 18 PM

🔼 This is serialiazble

Screen Shot 2021-09-22 at 1 46 22 PM

🔼 This is not conflict serializable

Screen Shot 2021-09-22 at 1 56 34 PM

🔼 This is not serializable T1 => T2 (R(A), W(A)) T2 => T1 (R(B), W(B))

Example

Knowledge check: Transactions and Concurrency Control

  1. What is the result of the following database transaction if the initial values of both A and B is 100?

BEGIN

A=A+100

B=A+100

END

  • A=200, B=300
    Explanation : A = 100 + 100 = 200 B = 200 + 100 = 300

  1. Consider the following two database transactions with initial values of A=500 and B=500:

T1: A=A+100, B=A-100

T2: A=A1.06, B=B1.06

Assuming T1 arrives first, what will be the final values of A and B if the two transactions are processed using a serial schedule?

  • A=636, B=530
    In a serial schedule, T1 is processed in its entirety first and then T2 is processed.
    T1: A = 500 + 100 = 600 B = 600 - 100 = 500
    T2: A = 600 * 1.06 = 636 B = 500 * 1.06 = 530

  1. Consider the following two database transactions with initial values of A=500 and B=500:

T1: A=A+100, B=A-100

T2: A=A1.06, B=B1.06

Assuming T1 arrives first, what will be the final values of A and B if the database management system interleaves transactions?

  • A=636, B=568.16
    Starting with T1 and then interleaving after the first part to T1, these are the final values of A and B.

T1: A = 500 + 100 = 600 T2: A = 600 * 1.06 = 636 T1: B = 636 - 100 = 536 T2: B = 536 * 1.06 = 568.16

Rotate Array

Given an array, rotate the array to the right by k steps, where k is non-negative.

Screen Shot 2021-09-10 at 8 45 00 PM

/**
 * @param {number[]} nums
 * @param {number} k
 * @return {void} Do not return anything, modify nums in-place instead.
 */
var rotate = function(nums, k) {
    k %= nums.length // if k is greater than nums.length then one cycle is completed that means it will remain the same and we have to remainder shifts
    
   let reverse = function(i, j){
    while(i < j){
        [nums[i], nums[j]] = [nums[j], nums[i]];
        i++;
        j--;
    }
   } // suppose  ----->---> 
	reverse(0, nums.length-1); // reverse   <--<------
	 reverse(0, k-1) // reverse first part ---><----
   reverse(k, nums.length-1)// reverse second part --->----->
};

Unit 6: Concurrency

Lock-based Concurrency Control and Recovery From Failures

Lesson Introduction: Lock-based Concurrency Control

Database systems are equipped with lock-based protocols to ensure that any transaction to a database cannot read or write data until it acquires an appropriate lock on the transaction. In a big data system where thousands of transactions can be executed simultaneously, it is critical to control the concurrency of transactions.

We will learn about the family of approaches called Lock-Based Concurrency Control. You will learn about the most widely used protocol, the Strict Two-phase Locking, or Strict 2PL.

Topic: Lock-Based Concurrency Control

First, using a dependency graph, we can tell whether a schedule is conflict serializable or not.

Lock based concurrency control
Strict Two-phase Locking (Strict 2PL) Protocol

  • Each transaction must obtain a shared lock on the object before reading, and an exclusive lock on the object before writing.
  • All locks held by a transaction are released when the transaction completes.
  • Strict 2PL allows only serializable schedules, it simplifies transaction aborts

To be more clear, before reading a transaction A, R(A), it needs to acquire shared lock, S(A). Whenever a transaction wants to write a data item W(A), it needs to acquire exclusive lock X(A).

It calls Two-phase because the transaction goes to two main phases.

  • A phase where the transaction keeps acquiring locks, either shared locks or exclusive locks.
  • Release locks at the end of the transaction. Here is a less strict version where you can release it in the second phase, start releasing locks step by step.

There is a separate module in the database system called lock manager, it controls all the locking going up, all the transactions, or the concurrency control module in the database system has to call the lock manager to acquire locks. So the lock manager basically receives locks and releases all locks as well.

Simple rule:

  • if one transaction already holds a shared lock on item A, if another transaction comes and wants to also acquire a shared lock on the same item, this is allowed. So the lock manager will grant that lock to the other transaction as well.
  • If the transaction has a shared lock on item A, but another transaction came and it wants to acquire an exclusive lock, that is Not allowed
  • If the original transaction already has an exclusive lock on item A, and another transaction comes in and wants a shared lock. It is not allowed
  • If an original transaction has an exclusive lock and another transaction also wants an exclusive lock on the data item

As we can see. Shared on Shared is allowed, otherwise, not allowed

Screen Shot 2021-09-27 at 1 55 33 PM

We have to wait for the transaction to release the lock first if it has an exclusive lock in order to acquire a shared or exclusive lock on it.
And if we want to have an exclusive lock, we have to wait for a shared lock also to be released.

Deadlock
A deadlock means that one transaction wants to acquire a lock on a data item A, and this data item A is already locked by another transaction B. At the same time, this other transaction B also wants to acquire a lock on a data item A that is already also locked by transaction B. They both waiting for each other, and it leads to a deadlock because nobody will release the lock until the other one does.

Deadlock Detection

  • Create a data structure called the waits-for graph. In the graph, there is an edge from Ti to Tj if Ti is waiting for Tj to release a lock

Ti => Tj

To detect deadlock, we periodically check for cycles in the graph. if there is a cycle, it means we have a deadlock and we have to break the cycle by aborting one of the transactions that are causing the cycle

IMG_BEF9110C3F28-1

No deadlocks because of no cycle ⬆️

Screen Shot 2021-09-27 at 3 09 51 PM

deadlocks because of cycle ⬆️


Topic: Database Recovery

As we already know from the previous unit, a transaction is a collection of actions that make consistent transformations of system states while preserving system consistency. There might be temporarily in an inconsistent state during execution in the middle, but that is fine. As long as the beginning and the end of the transaction are consistent states.

If we have a deadlock, for example, we may need to abort the transaction that causes the deadlock.
However, aborting a transaction is a failure.
Type of Failures:

  • Transaction failures
    • Transaction aborts
    • Avg 3% of transactions abort abnormally.
  • System failure
    • Failure of processor, main memory loss due to power failure
    • Main memory contents are lost, but secondary storage contents are safe
    • partial vs. total failure
  • Media failures
    • Failure of secondary storage devices such that the stored data is lost
  • Communication failures
    • Lost/undeliverable messages due to network unstable

Local Recovery Management - Architecture

  • Volatile storage
    • consists of the main memory of the computer system (RAM).
  • Stable / Persistent storage
    • Resilient to failures and loses its contents only in the presence of media failures

Main memory is smaller than the persistent storage so you have to select a few pages that we can actually store in the buffer. When computers shut down, all data in RAM is wiped out.

That is why we have a Recovery manager

  • Before sending data to the new stable database state to do recovery, we have a database log, which logs every single operation that is happening in transactions into persistent storage. Database Log is an append-only file

Recovering From a Crash

  • There are 3 phases in the Aries recovery algorithm:
    • Analysis: Scan the log forward (from the most recent checkpoint)
    • Redo: For all the transactions committed before the crash, we will apply for a redo of all the operations of this transaction.
    • Undo: For transactions that did not commit before the crash, undo all operations to the old values

This way, we ensure that we recover from failure. Transactions that are committed, are redone again, we are fine. For transactions that did not commit before the crash, they don't have a commit record in the log, undo them, and run them again later

Knowledge Check: Lock-Based Concurrency Control

  1. What kind of lock must a transaction acquire in order to read from a database?
  • Concurrency Lock
  • [Correct] Shared Lock
    (This is the type of lock a transaction needs to acquire in order to read from a database)
  • Exclusive Lock
  • Read Lock
  1. What kind of lock must a transaction acquire in order to write to a database?
  • [Correct!] Exclusive Lock
    (This is the type of lock a transaction needs to acquire in order to write to a database.)
  • Shared Lock
  • Write Lock
  • Atomicity Lock
  1. What is the name of the database module that manages lock-based concurrency control for transactions?
  • Concurrency Manager
  • Transaction Manager
  • [Correct] Lock Manager
    (Lock-based concurrency control is managed by a specific database module called lock manager)
  • Control Manager

Unit 5 & 6: Practice Quiz

  1. What is the result of the following database transaction if the initial values of both A and B are 100?

BEGIN

A=A+100

B=A+100

END


A = 100 + 100 = 200
B = 200 + 100 = 300
A=200, B=300

  1. How does a database achieve concurrency?
  • By putting transactions in a queue.
  • [Correct] By interleaving transactions.
    (A database can process multiple transactions concurrently by interleaving them.)
  • By processing transactions at the same time.
  • By processing transactions as they come in.
  1. Which of the following describes the atomicity principle of database transactions?
  • A database can only serve one user at a time.
  • A database can only process one query at a time.
  • [Correct]All of the components of a transaction run in their entirety, or none of them run at all.
  • A database can only process one transaction at a time.
  1. What kind of lock must a transaction acquire in order to read from a database?
  • Read Lock
  • Concurrency Lock
  • [Correct] Shared Lock
    (This is the type of lock a transaction needs to acquire in order read from a database.)
  • Exclusive Lock
  1. Consider the following two database transactions with initial values of A=500 and B=500:

T1: A=A+100, B=A-100

T2: A=A1.06, B=B1.06


Assuming T1 arrives first, what will be the final values of A and B if the database management system interleaves transactions?

T1: A = 500 + 100 = 600
T2: A = 600 * 1.06 = 636
T1: B = 636 - 100 = 536
T2: B = 536 * 1.06 = 568.16

A=636, B=568.16


Unit 5 & 6: Graded Quiz

  1. Database transactions are processed according to a principle that all of the components of a transaction run in their entirety or none of them run at all. What is the name of this principle?
  • Concurrency
  • Durability
  • [Correct] Atomicity
    (The atomicity principle states that all of the components of a transaction run in their entirety or none of them run at all)
  • Isolation
  1. Which of the following database operations requires a transaction to obtain a shared lock?
  • Delete Data
  • Update Data
  • [Correct] Read Data
    (A database transaction needs to obtain a shared lock in order to read data from a database)
  • Write Data
  1. Which of the following database operations does not require a transaction to obtain an exclusive lock?
  • [Correct] Read Data
    (Reading data from a database does not require an exclusive lock; a shared lock is sufficient)
  • Write Data
  • Delete Data
  • Update Data
  1. Consider the following two database transactions with initial values of A=0 and B=0:

T1: A=A+10, B=A+10

T2: A=A*1.1, B=B*1.1

Assuming T1 arrives first, what will be the final values of A and B if the two transactions are processed using a serial schedule?

T1: A = 0 + 10 = 10
T1: B = 10 + 10 = 20
T2: A = 10 * 1.1 = 11
T2: B = 20 * 1.1 = 22

A=11, B=22

  1. Consider the following two database transactions with initial values of A=0 and B=0:

T1: A=A+10, B=A+10

T2: A=A1.1, B=B1.1

Assuming T1 arrives first, what will be the final values of A and B if the database management system interleaves transactions?

T1: A = 0 + 10 = 10
T2: A = 10 = 10 * 1.1 = 11
T1: B = 11 + 10 = 21
T2: B = 21 * 1.1 = 23.1

A=11, B=23.1

  1. Why do database management systems implement transaction interleaving?
  • To achieve atomicity
  • To achieve isolation
  • [Correct] To achieve concurrency
    (Database management systems implement transaction interleaving in order to achieve concurrency, which is the ability of a database to execute multiple transactions simultaneously)
  • To achieve consistency
  1. Which of the following describes the isolation principle of database transactions?
  • [Correct] Each transaction runs as if there is no other transaction running in the database system simultaneously.
    (This is the definition of the isolation principle of database transactions)
  • All of the components of a database transaction run in their entirety, or none of them run at all.
  • A database management system can only process one transaction at a time.
  • A database management system can only process one query at a time.
  1. Which of the following describes the serializability property of database transactions?
  • All of the components of a transaction run in their entirety or none of them run at all.
  • Each transaction runs as if there are no other transactions running in the database system simultaneously.
  • A database management system can only process transactions in series, not concurrently.
  • [Correct] If several transactions are executed concurrently, the results must be the same as if they were executed one after another.
  1. Which of the following statements about the ACID properties (Atomicity, Consistency, Isolation, Durability) is correct?
  • [Correct] Isolation implies Serializability
    (Isolation means that concurrent changes are invisible, which implies serializability)
  • Atomicity implies Serializability
  • Consistency implies Serializability
  • Durability implies Serializability
  1. Which of the following describes the durability property of database transactions?
  • Each transaction runs as if there are no other transactions running in the database system simultaneously.
  • [Correct] Once a transaction commits, the system guarantees the results will never be lost, in spite of subsequent failures.
  • All of the components of a transaction run in their entirety, or none of them run at all.
  • If several transactions are executed concurrently, the results must be the same as if they were executed one after another.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.