I Have not blogging for a long time, now I would like to use this blog to write week review as a university student.

This week theme – last celebrating week

MA1521

Limit and Continuity

  • Definition:  f (x) is arbitrarily close to L by taking x to be sufficiently close (but not equal) to a (Independent of value at x = a)
  • Discontinuity:
    1. removable discontinuity – missing point at x = a
    2. jump discontinuity – gap at x = a
  • Squeeze Theorem: if function x’s limit is within 2 other functions with same limit at x = a equals b, then x’s limit at x = a is b as well.
  • sin θ / 2 <  θ < tan θ / 2 (*)

MA1101R

Linear Systems and Gaussian Elimination

  • 0 linear system is in (reduced) row-echelon form
  • 3 elementary row operation:
    1. multiply an row with non-zero constant
    2. interchange two rows (can be achieved by operation 1 & 3)
    3. add a multiple of one row to another row
  • Gaussian elimination: find row-echelon form
  • Gauss-Jordan Elimination: find reduced row-echelon form
  • Homogeneous Linear System: trivial solution – 0 solution
  • #(non-zero rows) = #(pivot columns) ≤ #(variables)
  • Homogeneous Linear System is consistent  #(variables) = #(non-zero rows) + #(free variables)

CS2010

Binary Tree & Binary Search Tree implementation

  • BT as base class, Interface defines all BST methods
  • Use Serializable for output to file and read from file
  • BufferReader (faster) VS Scanner
  • UML – underline class name refers to object

CS2100

Boolean algebra, logic gates & circuit

  • Sum-of-Product & Product-of-Sum: no mixture of term like a*(b+c)
  • Maxterms: sum-of-product
  • Minterms: product-of-sum
  • Sum-of-Minterms & Sum-of-Maxterms Expression (unique for a function): once in Sum-of-Minterms never in Sum-of-Maxterms
  • Canonical form & standard form
  • NOT, AND (used as mask), OR, NAND (universal gate), NOR, XOR, XNOR (universal gate)
  • Always have input on logic trainer
Week 2 Review

I haven’t update my blog for a long time. After 3 months struggling in Final Year Project (FYP), Finally my First XNA game is out.

For more details, please check out our video http://goo.gl/ewTr6 and the website http://goo.gl/7esMw

Let’s set an ending to FYP1 and I am excited about the coming FYP 2.

BTW, please help to like our photo to support our project - http://goo.gl/PjWt9

Thank you very much.

 

 

 

Customized Rating Bar in Android

During my Assignment 1 for my Android Module, I find it interesting and fun to customize the rating bar in Android. I will share with you some tips that I have gained from my experience:

  1.  There are not much resource on the web, the most useful one I have found out was this . It clearly showed what you need to do to customize a rating bar in Android:
    • styles.xml – (values)
    •  layer-list.xml – (drawable)
    •  selector.xml – (drawable)
    •  your customized rating bar pictures (drawable)

    As each file has been explained very clearly in the origin post . Here I will just skip this part. Just keep your files in the correct folder.

  2. My initial thought was doing a glass cup rating bar which allows you to rate as half glass or something like that. After following the tutorial, I notice there is a big issue here. It’s not possible to do a vertical rating icon through this way. What I mean is you can’t do something like this:
    In my point of view, the reason is due to progressDrawable for progressBar is only for horizontal.I will be very pleased someone could propose a solution for this vertical rating bar and thank you in advance. :]
  3. If you want to use a different numStars rather than 5, e.g. 4 in this case, please be careful with the layout_width, if you set it to fill_parent, and unfortunately the parent of rating bar is actually the full screen width, you will hardly get 4 stars but more than that. :(

Have fun!
Here is my whole project .
My result:

Software Engineer Interview Questions @_@

I just check out the CreerUp Website, most of the interview questions are interesting but hard to answer :(

As a programming starter who wants to enter IT field later, I need to check these questions!

Google

Given a building of H number of floors and an elevator composed of N boxes such that only one box stops at a particular floor and that if a box stops at x-th floor than the box on top of that would stop at (x+d)-th floor for some constant d.
Given H and N, find the number of different elevator configurations. Two elevators are different if their bottommost box is at first floor than there exits an “i” such that a box is at i-th floor in one elevator and no box is at i-th floor in other elevator.
For example,
if H = 9 and N = 3, then there are 2 configurations possible.
1) First box stops at 1-st,2nd,3rd floor. Second box stops at 4-th,5th,6th floor and third box stops at 7th, 8th, 9th floor.
2) First box stops at 1st,4th, 7th floor. Second box at 2nd,5th,8th floor and third box at 3rd, 6th, 9th floor.

After some time thinking and reading comments for this questions, it seems that this problem is some kind of dynamic programming, based on the given example, I just figured out the possible configurations number must be related to the number of H/N. So I come out with a method like this:
(The possible configuration number should equal to number of factors of H/N)


def getConfigurationNum(floorNum,boxNum):
    configurationNum = 0
    fixNum = floorNum/boxNum
    for i in range(1,fixNum+1):
        if (fixNum % i) == 0:
            configurationNum +=1
    return configurationNum
print 'Final: %s'%(getConfigurationNum(9,3))

Wish anyone knows the correct answers help me out with this problem.

Microsoft

What data structure would you use to implement spell correction in a document. The goal is to find if a given word typed by the user is in the dictionary or not (no need to correct it).
What is the complexity? What if you have to support multiple languages/dictionaries?

This question is more towards the data structure, I would like to use python again for it.
We all know in python, dictionary can be used as Hash or Tree data structure, and list can be used as stack.
The key points from wgx731 :)

  • List as stack for correction, as when we find a wrong spelling user may want to undo the changes to compare where the spelling is wrong.
  • Dictionary of Dictionary to store all the correct words, for example, with multiple languages, we first categories by languages, then inside each dictionary we can categories by First letter, like what we do in real world dictionary.
  • I need help on complexity, how is the memory usage? I have no idea. :P

Just a few comments, maybe I am not on the right track, feel free to help me out :P

What is the time and space complexity of Fibonacci series recursive function.

First, let’s review how to write a recursive function to calculate Fibonacci series.


def fibonacci(n):
    if n == 0:
        return 0
    elif n == 1 or n == 2:
        return 1
    else:
        return fibonacci(n-2)+fibonacci(n-1)

After that I read something about space complexity.
Definition:
The space complexity of a program (for a given input) is the number of elementary objects that this program needs to store during its execution. This number is computed with respect to the size n of the input data.
It seems like number of if statements will affect time and number of the main calculation will affect complexity. Again, I haven’t dive deeply into what is complexity. Need Help here as well. :)

Check more at CreerUp Website. Wish you have benefited from reading this post. Thank you.

Better keep a WIN7 install CD

As I have tried dual boot Ubuntu and WIN 7 for about 3 months, I would like to share with you guys some tips I have gained:
1. Be careful when you install updates on Ubuntu, from my experience, sometimes a new kernel may not boot up normally, I have encounter this kind of problem a lot of times. For example, Linux 2.6.35-25-generic sometimes shut down suddenly when I want to boot it up, especially when I have used WIN 7 and change to Ubuntu. Not sure, if it’s a bug or just my computer special case. :|
2. Don’t trust EasyBCD too much. First, please keep in mind that always set WIN7 as default boot up OS, I have encountered a problem that I have 2 Linux boot up selection, but my WIN7 is gone. When there is update of Windows, it sometimes will break the grub. I want to fix it by using EasyBCD, after I delete all my boot up selection in MBR and add them back, the result is terrible. Only two Ubuntu boot up selection to Linux grub Left. After a lot of research on my Ubuntu, I gave up on trying to edit BCD in WIN7 under Linux. I will show you my steps here for your reference:

  • I have tried wine first, the result is obvious, all wine runtime is fake, so it’s impossible to use EasyBCD under wine.
  • Find a BCD editor in Ubuntu, failed as well.
  • Edit BCD directly by text editor, at the time I opened up the BCD file, I know I was stupid. It was not human readable.

At last, I remembered WIN7 install CD. Let WIN7 install CD solve my problem. Just use the Repair your computer Function, it will automatically reset the WIN7 BCD for you.

When I write this post in WIN7, it proves I was in the right track.

That’s all my learning experience on dual boot, please feel free to share with me your comments. Thanks :)

virtualenv == pvm for python ???

During my internship at HP Lab Singapore, I have used rvm a lot.
As python is my primary language, I am seeking a equivalent in python. I want to ask is there ‘pvm’? :)
The solution seems to be virtualenv, in this repository it makes life easier to install virtualenv.
A simple guide:
curl -s https://github.com/brainsik/virtualenv-burrito/raw/master/virtualenv-burrito.sh | bash
Follow the guideline you can create your first virtualenv, for example python2.7.
After that you can use pip install or easy_install to grasp your favorite Python packages, it seems good and working fine on my computer.
As I have used rvm and virtualenv both now, I have some comments for virtualenv:

  • I still need to compile specific version of python myself or use sudo apt-get in Ubuntu, whereas rvm has handled compiling different version of ruby itself.
  • There is no notes or instruction on how I can use virtualenv in byobu, I still need to type source .venvburrito/startup.sh before I can use it in byobu. PS: please forgive me that I am not good at shell scripting
  • .

The below screenshot is just a demo of my virtualenv, thx GEORGE, I know SyntaxError: not a chance. :P

my virtualenv screenshot

virtualenv


That’s my experience on virtualenv compared with rvm. Feel free to correct me and give comment. ^_^

My first WP7 project :)

This gallery contains 3 photos.

It seems that my Othello game is doing well in the market, which hit 768 downloads so far, and ranking in 98 worldwide in all free games. (Just a small comment for Microsoft, it’s better to include search for ranking. ) But the problem is that there is no one leaving comment for me to… Read more.

about pythonchallenge

http://www.pythonchallenge.com/

Level 4:
http://www.pythonchallenge.com/pc/def/linkedlist.php
This is really nice one, as there are 2 traps will stop u. Making use of urllib and urllib2, you can do a lot of things.
I am wondering how is linkedlist.php looked like? Is it just a linkedlist built by PHP?
Anyway having fun with it.

import urllib,re
num='12345'
p=re.compile('(\d+)')
print p

url = r"http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing="

while True:
if (num == '61067'):
num = '53522'
elif(num== '92118'):
num = '46059'
print "goto:",num
data = urllib.urlopen(url+num).read()
print data
m = p.search(data)
if m:
num=m.group(0)
else:
break

Not exactly my own work :-)

School Evaluation Autofiller

I have spent quite a long time on this project, as well as with the help from my classmate. Actually it’s just a small project that auto fill the form for you. But the problem is that school use NTLM and SESSION KEY to make me hard to complete the task. Anyway, it’s finished, I will find time to improve it by adding threading and complete it as a good GUI program. WISH u like it :-)
LINK is here: https://github.com/wgx731/PythonLeo