Tuesday, November 22, 2016

Big-O Notation

By National Institute of Standards and Technology (NIST), the definition of Big-O notation is a "theoretical measure of the execution of an algorithm, usually the time or memory needed, given the problem size n, which is usually the number of items. " In essence, an algorithm's big-o notation is determined by how effectively it responds to different input, n. Would the process rate be different if we have 100,000 inputs instead of 10 inputs?

The measure of the execution can be expressed as f(n)=O(g(n)). O function is the order function, f(n) is your algorithm, and g(n) is the function you use to estimate f(n). For example, if you f(x)=n^2+3n-40. As n approaches infinity, the value of (3n-40) does not matter as much as n^2, so we can use n^2 to estimate your f(x). Below are some typical Big-O notations:



  • O(1) is the constant time function, where it takes the same amount of time to process any size of inputs. An example of O(1) algorithm is to determine if the binary input in odd or even. 
  • O(log n) is very efficient to analyze large inputs. The growth peaks at the beginning the marginal time decreases as you increase the number of inputs. For example, the algorithm takes 1 second to analyze the first 100 times, but only take 2 seconds to analyze the first 1000 items.  An example of O(log n) algorithm is to find an item in a sorted array.
  • O(n) is the linear function, where the time is proportional to the size of input. An example of O(n) algorithm is to find an item in a unsorted array.
  • O(n^2) is an quadratic algorithm that processes inner loops. An example would be what we learned in class on Thursday - bubble sort.
  • O(n^n) is an algorithm whose performance is proportional to the square of the size of inputs. To process each element, it will go through the entire set of data. An example would be merge sort.
--------------------------------------------------------------------------------------------------------------------------
Picture References:
1.https://www.google.com/search?q=big+o+notation&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjKg67hsMXQAhXnslQKHQQHBiQQ_AUICigD#imgrc=C161EKuPr8u7CM%3A
Writing References:
1. https://xlinux.nist.gov/dads/HTML/bigOnotation.html
2. https://justin.abrah.ms/computer-science/big-o-notation-explained.html
3. https://en.wikipedia.org/wiki/Big_O_notation
4. https://rob-bell.net/2009/06/a-beginners-guide-to-big-o-notation/
--------------------------------------------------------------------------------------------------------------------------

Tuesday, November 15, 2016

Everything about operators in Java

Remember in the midterm midterm, Professor Jory asked a question about operator as a bonus question? In fact, there are so many more different kinds of operators than what we learnt in class. Addition, subtraction, etc. are only a subset of operators, called arithmetic operators. 

Unary operators can be increment or decrement. (++), (-), (--) are all examples of unary operators. 

Binary operators has six major categories as listed in the picture above. We covered most of the arithmetic operator during the class. Assignment operator is (=) and it is used when you set the values of data, e.g. String name = "Cathy." Logical operators are (&&),(||), and (!). Relational operators are (==),(!=),(>),(<),(<=) or (>=), which we also discussed in the classroom. Compound operator performs operation on the two operands before assigning the result to the first operand. Compound operator works on both arithmetic and bitwise operator. There are 11 different kinds of operators and (+=) is the one we often use throughout this semester. The other compound operators include (-+),(*=),(/=),(%=),(&=),(|=),(^=),(<<=),(>>=),(>>>=).

The only operator we have never seen before is bitwise operator. Bitwise operator works on all integer data types including int, long, short, char, and byte. It converts all the integers to bits and perform bit-by-bit operations on integers. An example given on this website (https://www.tutorialspoint.com/java/java_basic_operators.htm) is a = 60 and b = 13. In binary world, a = 0011 1100 and b = 0000 1101. Bitwise operators include (&),( |), (^),(~),(<<),(>>) and (>>>). (&) is binary and, which copies a bit to the result if it exists in both operands, otherwise it will copy 0. (a&b)=0000 1100. (~) flips the bits, so (~a) returns 1100 0011. (<<) is binary shift and moves all the bits to the left. (a<<2) returns 1111 0000. (>>>) is zero fill right operator. The left operand is shifted by the number in the right operands and zero fills all the empty bits. (a>>>2) returns 0000 1111.

Ternary operator takes three operands and conditional operator is a ternary operator. The syntax for ternary operator is (?:) expressionA?expressionB:expressionC. Expression A is implicitly converted to a boolean. If it is true, expression B will be evaluated, otherwise expression C will be evaluated. A good example would be compute the minimum value of x and y. 

minimum = (x < y) ? x : y;
--------------------------------------------------------------------------------------------------------------------------
Picture References:
1.https://www.google.com/search?q=java+operator&biw=1280&bih=583&source=lnms&tbm=isch&sa=X&ved=0ahUKEwjvzZnSoKvQAhXBylQKHcw5CLEQ_AUICygA#imgrc=G73VcUwBb5rsVM%3A
Writing References:
1. http://www.computernotes.in/java/core-java/operators-in-java/
2. https://www.tutorialspoint.com/java/java_basic_operators.htm
3. http://www.c4learn.com/java/java-operators/
4. https://www.tutorialspoint.com/cplusplus/unary_operators_overloading.htm
5. https://msdn.microsoft.com/en-us/library/e4213hs1.aspx
6. http://alvinalexander.com/java/edu/pj/pj010018

--------------------------------------------------------------------------------------------------------------------------

Wednesday, November 9, 2016

Inheritance: Single, Multilevel and Hierarchial

During the lab in Wednesday, we talked about inheritance. As we know, inheritance is one of the four design principles for object-oriented programs and it helps with the organization of large programs and has reusability feature. Inheritance is obtained by building new child classes from the existing parent classes. Through the magic word "extends," we can reuse and add all the methods and properties from the parent class. To reduce the chance of error and increase reusability, we can apply overriding and revise the methods in the parent class, instead of creating a new one. Inheritance represents IS-A relationship, also known as parent-child relationship.  

There are five types of inheritance in Java: single, multilevel, hierarchical, multiple and hybrid.  
However, there are only three types of them(single, multilevel, hierarchical) available in Java programming. 
Not supported directly in Java, multiple and hybrid inheritance are supported through interface. 

1. Single: one class inherits from the other
2. Multilevel: one class inherits from the other class which inherits from another
3. Hierarchical: multiple classes inherit from the same class
4. Multiple: one class inherits from multiple classes
5. Hybrid: a mixture of multilevel, hierarchical and multiple inheritance

The two diagrams below provide graphical representation of these types.
--------------------------------------------------------------------------------------------------------------------------
Picture References:
1.https://www.google.com/search?q=inheritance+java&biw=1280&bih=620&source=lnms&tbm=isch&sa=X&sqi=2&ved=0ahUKEwiZ7-WRjp3QAhXB5yYKHT0JBssQ_AUIBygC#imgrc=NTtuIobiMKjsUM%3AWriting
2. http://www.javatpoint.com/inheritance-in-java
References:
1.http://www.javatpoint.com/inheritance-in-java
2.https://docs.oracle.com/javase/tutorial/java/IandI/subclasses.html
3.http://docstore.mik.ua/orelly/java-ent/jnut/ch03_04.htm

--------------------------------------------------------------------------------------------------------------------------


Friday, November 4, 2016

How does Netflix make recommendations?

Do you like Netflix?
Have you ever watched netflix and just could not stop watching it?
If you, have you ever wondered why Netflix always make those wonderful recommendations to you?

Your wonderful Netflix experience is based on Machine learning algorithms. The recommendation system on Netflix and other apps/websites use complex algorithm based on linear algebra and matrixes to determine which content you might like. The Algorithm for Netflix was also referred to as "rating prediction" algorithm, which was the most important system in Netflix and was researched in the Netflix Prize in 2006 as the "Netflix Recommendation Algorithm." 

There are two major algorithms that are being used right now: Restricted Boltzman Machines (RBM) and a form of Matrix Factorization, which is also referred as Singular Value Decomposition. These two algorithms take user input, run through to determine their preferences and interests and finally output the recommendation for users. Both of these algorithms contain some error and inaccuracies bur a linear blend of these two methods reduced the error margin significantly.

--------------------------------------------------------------------------------------------------------------------------
Picture References:
1.https://www.google.com/search?q=netflix+recommendation+system&source=lnms&tbm=isch&sa=X&ved=0ahUKEwigrObu3ZDQAhUF6CYKHbMKB9MQ_AUICCgB&biw=1257&bih=620#q=netflix&tbm=isch&tbs=rimg%3ACabzecxy0tsIIjilQUCjVaiql4Fx_1EXSAg32zmNGRo0kTcYaTEzXLj6mhshKArr74Kvr_1JicUsEGaUQTBlSzSePd0SoSCaVBQKNVqKqXEYjgkUhdbbLGKhIJgXH8RdICDfYR6yDoZR-bvTMqEgnOY0ZGjSRNxhE9_1vOiHwDGlioSCRpMTNcuPqaGEWltLkD-9BeoKhIJyEoCuvvgq-sRhbebbti3HIEqEgn8mJxSwQZpRBFOBZV95MKM8ioSCRMGVLNJ493RESAQ6MacSGeD&imgdii=P57_EbfDdSsDZM%3A%3BP57_EbfDdSsDZM%3A%3BcsgyFL_uUe6v3M%3A&imgrc=P57_EbfDdSsDZM%3A
Writing References:
1.http://www.businessinsider.com/how-the-netflix-recommendation-algorithm-works-2016-2
2.http://techblog.netflix.com/2016/02/recommending-for-world.html
3.https://www.quora.com/How-does-the-Netflix-movie-recommendation-algorithm-work#
--------------------------------------------------------------------------------------------------------------------------

Monday, October 24, 2016

How do you release a software?

A software release life cycle is a channel of all the stages of product development. It starts with initial development and testing and ends with release of a software/product. This post talks about each of this step, based on the picture below.

Pre-alpha: 
Pre-alpha refers to all activities performed during the software project before formal testing. These activities can include requirements analysis, software design, software development, and unit testing. In typical open source development, there are several types of pre-alpha versions. Milestone versions include specific sets of functions and are released as soon as the functionality is complete.
Alpha:
Alpha is the first letter in Greek alphabet and it is the first phrase to begin software testing. Alpha software can be unstable but by the end of this phrase, no more feature will be added to the software. So, alphaware is usually said to be feature complete.
Beta:
Beta is the second letter in Greek alphabet and it is a process to reduce error and increase stability of the software. The delivery of betaware is the first time that the software will be available to the public.
Release Candidate:
After the completion of beta phrase, a software will become release to candidate, unless significant problem occurs. This stage is referred as code complete, because all the features have been designed, coded and tested with no known significant bugs.
RTM:
This is the phrase when the product is ready to be released. The software is first released to hardware manufacturers for bundling. This process will help developers to work out all the products before general release to the public.
GA:
This is the phrase when the product is released to general public, after all the commercialization activities have been completed. The time between RTM and GA can be weeks to months, depending on the time taken to finish all the commercialization activities.
Production or live release:
Production or live release aka Gold: this is the phrase when the product has released.
--------------------------------------------------------------------------------------------------------------------------
Picture References:
1.https://en.wikipedia.org/wiki/Software_release_life_cycle
Writing References:
1. http://releaseboard.com/what-is-a-software-application-release-cycle.html
2. https://en.wikipedia.org/wiki/Software_release_life_cycle
3. http://www.brighthub.com/internet/web-development/articles/42592.aspx

--------------------------------------------------------------------------------------------------------------------------

Wednesday, October 19, 2016

How did google get started?


Google is coming to campus today and all the events are hosted in Jepson Hall.
While you can learn much about  Google’s hiring process, culture, job and/ internship opportunities, are you curious about how did Google get started?

Start:
Google started with two students Larry Page(at age 23) and Sergey Brin (at age 24), who were pursuing their Ph.D. at Stanford University. While they were collaborating on a search engine called BackRub in 1996, which was written in Java and Python and ran on several Sun Ultras and Intel Pentiums running Linux.

They achieved great success with the server and officially launched Google.com as a domain on September 15, 1997. The company was formally incorporated on September 4, 1998. The name Google was a word play on mathematical term "googol," which means ten raised to the power of a hundred (10^100). This term represented their mission to organize a seemingly infinite amount of information on the web.

Development and Today:
Instead of allowing pop-up advertisement in the search engine, Google only allows is single text ads. Even though the home page was still marked "Beta (development stage)," many articles already argued that Google provided better search results than its competitors. During the dot-com bubble, Google was also referred to as "the future of the Web", especially by stock market investors.

Over the next ten years, Google took a series of acquisitions and launched many applications including Google Group, Google Toolbar, Google News, Google Images and so much more. In 2004, Google had IPO of 19,605,052 shares of Class A common stock takes place on Wall Street. Opening price was $85 per share. It also owns websites including YouTube and Blogger. In August 2015, Google reorganized its interesting as a holding company named Alphabet Inc. 

--------------------------------------------------------------------------------------------------------------------------
Picture References:
1.https://www.google.com/search?q=google&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiB5_nPkOfPAhVIHT4KHQQuBMMQ_AUICygE&biw=1249&bih=589#imgdii=7IKHjqDTO__xIM%3A%3B7IKHjqDTO__xIM%3A%3B2stnn3dUTo2FjM%3A&imgrc=7IKHjqDTO__xIM%3AICygE&biw=1280&bih=628#imgrc=mRJiumYp6_53fM%3A
2.https://www.google.com/search?q=Larry+Page+23+and+Sergey+Brin+24&source=lnms&tbm=isch&sa=X&ved=0ahUKEwji746UkefPAhXKWz4KHefRCCIQ_AUICSgC&biw=1249&bih=585#imgrc=hXyZDfTlNsffUM%3A
Writing References:
1. https://www.google.com/about/company/history/
2. http://www.steegle.com/about/google-101-facts/1-11-how-it-all-began
3. https://en.wikipedia.org/wiki/History_of_Google

--------------------------------------------------------------------------------------------------------------------------

Friday, October 14, 2016

Javacode, Java Virtual Machine, and machine code


Have you every wondered when you program with Java, why do you always have to compile your code? What does the ".class" file mean? Well, the answer is that your computer does not read English words, and the compiler takes your code and translate into machine-level code. This process is more complicated for Java. Your code is first translated into bytecode and then executed by JVM (Java Virtual Machine), and finally processed by the computer, as shown in the picture above.

Bytecode
Bytecode is the output from a Java compiler and is a form of instruction set designed for efficient execution by a software interpreter. It is composed of numeric codes, constants, and references (normally numeric addresses). Each bytecode is has one, or in some cases two bytes that represent the instruction (opcode), along with zero or more bytes for passing parameters. Below is an example of the bytecode:

Java Virtual Machine
JVM (Java Virtual Machine) is a virtual machine that executes bytecode outputted by Java compiler and enabled the computer to run the program. Java is powerful, because once a program is compiled, it can be run on any platform without having to be rewritten or recompiled. A Java virtual machine can interpret the bytecode one instruction at a time or interpret the bytecode with just-in-time compiler.

Machine code:
While humans understand languages, computer's CPU (central processing unit) only understand machine language, aka machine code, which is the most elemental language of computers, comprising a long sequence of zeros and ones.  Each machine code gives CPU an instruction to perform a simple operation or to store data in RAM. 
--------------------------------------------------------------------------------------------------------------------------
Picture References:
1.https://www.google.com/search?q=java+virtual+machine&source=lnms&tbm=isch&sa=X&ved=0ahUKEwiW_ZSk5trPAhUGVT4KHd2UBfgQ_AUICygE&biw=1280&bih=628#imgrc=mRJiumYp6_53fM%3A
2.https://en.wikipedia.org/wiki/Java_virtual_machine#/media/File:JvmSpec7.png
3.https://en.wikipedia.org/wiki/Java_bytecode
Writing References:
1. http://durofy.com/10-major-differences-between-c-and-java/
2. https://en.wikipedia.org/wiki/Java_virtual_machine
3. https://en.wikipedia.org/wiki/Machine_code
4. https://en.wikipedia.org/wiki/Java_bytecode
5. http://www.theserverside.com/definition/Java-virtual-machine-JVM
--------------------------------------------------------------------------------------------------------------------------