Python is slow cuz it's read line by line
you can simply use array to represent a alphabet dictionary (check the isomorphic)
The do while loop executes the content of the loop once before checking the condition of the while.
Whereas a while loop will check the condition first before executing the content.
AJAX how to implement two-way data binding?
OO design? what is that?
upper_bound: return the first iterator of the num that lager than input value.
condition ? value_if_true : value_if_false
What is difference between top half and bottom half ?
- Interrupt handlers run asynchronously, and must respond to time-critical inputs quickly. Therefore, interrupt handler is divided into top half and bottom half. First half was executed by the kernel immediately after a hardware interrupt, whereas bottom half are the tasks that can be deferred to execute later.
What is interrupt? How does interrupt work?
An interrupt is a signal to notify kernel(processor) that something needs to be handled as soon as possible. It's called interrupt because kernel(processor) may suspend what it is running to handle the interrupt event(by calling ISR) and then resume its execution.
There are two types of interrupts: hardware interrupt(which caused by external device, like keyboard, mouse, disk, etc) and software interrupt(which caused by program, like system call, divide-by-zero)
Smart pointer
lhttp://ootips.org/yonat/4dev/smart-pointers.html
The address of a variable can be obtained by preceding the name of a variable with an ampersand sign (
&), known asaddress-of operator. For example:
foo = &myvar;
- Pointer arithmetics
*p++ // same as *(p++): increment pointer, and dereference unincremented address
*++p // same as *(++p): increment pointer, and dereference incremented address
++*p // same as ++(*p): dereference pointer, and increment the value it points to
(*p)++ // dereference pointer, and post-increment the value it points to
kernel trick:
http://crsouza.com/2010/03/17/kernel-functions-for-machine-learning-applications/
The choice of a Kernel depends on the problem at hand because it depends on what we are trying to model. A polynomial kernel, for example, allows us to model feature conjunctions up to the order of the polynomial. Radial basis functions allows to pick out circles (or hyperspheres) – in constrast with the Linear kernel, which allows only to pick out lines (or hyperplanes)
- Use linear kernel when number of features is larger than number of observations.
- Use gaussian kernel when number of observations is larger than number of features.
- If number of observations is larger than 50,000 speed could be an issue when using gaussian kernel; hence, one might want to use linear kernel.
https://courses.engr.illinois.edu/cs241/sp2012/lectures/25-condition.pdf
PCA and SVD
SVD is a numerical method and PCA is an analysis approach (like least squares). You can do PCA using SVD, or you can do PCA doing the eigen-decomposition , or you can do PCA using many other methods, just like you can solve least squares with a dozen different algorithms like Newton's method or gradient descent or SVD etc.
So there is no "advantage" to SVD over PCA because it's like asking whether Newton's method is better than least squares: the two aren't comparable.
true positive and false positive:

Zoox
1.Size of pointer
Pointers generally have a fixed size, for ex. on a 32-bit executable they're usually 32-bit.
Function Pointers can have very different sizes, from 4 to 20 bytes on an X86 machine, depending on the compiler.
2.Deep copy and shallow copy
- Shallow copies duplicate as little as possible. A shallow copy of a collection is a copy of the collection structure, not the elements. With a shallow copy, two collections now share the individual elements.
- Deep copies duplicate everything. A deep copy of a collection is two collections with all of the elements in the original collection duplicated.
3.pointer and reference
https://blog.csdn.net/weikangc/article/details/49762929
- 1.reassignment 2. NULL 3.memory address 4.arithmetic 5.indirect-
4.smart pointer
unique_ptrAllows exactly one owner of the underlying pointer. Use as the default choice for POCO unless you know for certain that you require ashared_ptr. Can be moved to a new owner, but not copied or shared. Replacesauto_ptr, which is deprecated. Compare toboost::scoped_ptr.unique_ptris small and efficient; the size is one pointer and it supports rvalue references for fast insertion and retrieval from STL collections. Header file:<memory>. For more information, seeHow to: Create and Use unique_ptr Instances and unique_ptr Class.shared_ptr
Reference-counted smart pointer. Use when you want to assign one raw pointer to multiple owners, for example, when you return a copy of a pointer from a container but want to keep the original. The raw pointer is not deleted until allshared_ptrowners have gone out of scope or have otherwise given up ownership. The size is two pointers; one for the object and one for the shared control block that contains the reference count. Header file:<memory>. For more information, see How to: Create and Use shared_ptr Instances and shared_ptr Class.weak_ptr
Special-case smart pointer for use in conjunction withshared_ptr. Aweak_ptrprovides access to an object that is owned by one or moreshared_ptrinstances, but does not participate in reference counting. Use when you want to observe an object, but do not require it to remain alive. Required in some cases to break circular references betweenshared_ptrinstances. Header file:<memory>. For more information, seeHow to: Create and Use weak_ptr Instances and weak_ptr Class.
5.polymorphism
- means that a call to a member function will cause a different function to be executed depending on the type of object that invokes the function. ... You have different classes with a function of the same name, and even the same parameters, but with different implementations.
6.cpu caching
- A CPU cache is a part of memory used by the CPU to reduce the average cost (time or energy) to access data from the main memory. A cache is a smaller, faster memory, closer to a processor core, which stores copies of the data from frequently used main memory.
7.virtual table: https://www.hackerearth.com/zh/practice/notes/virtual-function-and-virtual-table-in-c/
An object's virtual method table will contain the addresses of the object's dynamically bound methods. Method calls are performed by fetching the method's address from the object's virtual method table. The virtual method table is the same for all objects belonging to the same class, and is therefore typically shared between them. Objects belonging to type-compatible classes (for example siblings in an inheritance hierarchy) will have virtual method tables with the same layout: the address of a given method will appear at the same offset for all type-compatible classes. Thus, fetching the method's address from a given offset into a virtual method table will get the method corresponding to the object's actual class.[1]
TheC++standards do not mandate exactly how dynamic dispatch must be implemented, but compilers generally use minor variations on the same basic model.
Typically, the compiler creates a separate virtual method table for each class. When an object is created, a pointer to this table, called the virtual table pointer, vpointer or VPTR, is added as a hidden member of this object. As such, the compiler must also generate "hidden" code in the constructors of each class to initialize a new object's virtual table pointer to the address of its class's virtual method table.
Many compilers place the virtual table pointer as the last member of the object; other compilers place it as the first; portable source code works either way.[2]For example, g++previously placed the pointer at the end of the object.[3]
8.Inheritance
- Public Inheritance− When deriving a class from a public base class, public members of the base class become public members of the derived class and protected members of the base class become protected members of the derived class. A base class's private members are never accessible directly from a derived class, but can be accessed through calls to the public and protected members of the base class.
Protected Inheritance− When deriving from a protected base class, public and protected members of the base class become protected members of the derived class.
Private Inheritance− When deriving from a private base class, public and protected members of the base class become private members of the derived class.