Friday, May 27, 2011

Your (Hopefully Correct?) Guide Answer

Hi, Hin Hin. I finally got some times now to help you with your interview question that day.

You say you were given the series 0,1,1,2,3,5,8,13,21,34,55

Create an algorithm or Mathematics expression for the database

First we start from 0 and give i name as t0

t0  , t1  , t2  , t3  , t4  , t5  , t6  , t7  , t8  , t9  , t10
0     1      1     2      3     5      8     13    21    34    55

We can see that pattern of it sums up to t2= t0+t1, t3=t2+t1 , t4=t3 +t2 and such.
We may not learn it in school but there is name for it, it is called Fibbonacci Sequences

It is defined in this way, if you remembered it.

So the mathematics expression part is solved.By the way, tn=t (n-2)+t(n-1) is also correct. And you said that he do not care what language that you used, it is just syntax, so I used Java  pseudocode (For easy references ^_^)

class Fibbonacci {
public static main void main(String [] args){

     //initialize the t0=0, t1=1 and t2 =2
//print out 0 and 1 first

   while(t2<100){

//offset t0=t1, t1=t2 and declares t2=t1+t0
                         }
//print out t2 and , 
                                                                }
                          }

*If you confuse which open and closed loops paired together, see the indent, same indent means it is a pair. 

Jia yu on your job interview! Sorry, I don't know anything about database as now, so cant help you .  

Process Scheduling Algorithms Examples

This is a one of the rarest examples of all process scheduling algorithm that you can found in Internet.
Digitized from my own Operating System lecture notes actually (before I send them to recycling center).
:)

First you must know why, process scheduling is important. In the past (i.e 1950 or 1960's -ish, there are computer existed already but it is far too slow to be compared with your dear truly Casio 5700), a computer which might be as big as your home is capable of doing one task at the time which we called batch processing which as you might suspect is quite ineffective.



So some sort of computer scientist developed a system which enabled several users/programs runs concurrently on a computer system and each programs takes a slices of available processing time. The distribution of time sharing system gives the illusion to user that (s)he is running multiple program at  the same time.


Without wasting more time, here is a brief example of process scheduling algorithm
---------------------------------------------------------
|Process     |Arrival Time     |Processing Time|
---------------------------------------------------------
|A              |0                      |3                       |
|B              |1                      |6                       |
|C              |4                      |4                       |
|D              |6                      |2                       |
--------------------------------------------------------

(1) Plot the execution time for following algorithms

(i) First Come First Served
(ii) Shortest Job First
(iii) Shortest Remaining Time
(iv) Round Robin (quantum =1)

(i) All are executed as they received in order

-----------------------
|A   |B      |C    |D  |
-----------------------
0    3      9      13  15

(ii) *At time 0, A runs because it is only choice
     *At time 3, B is only process in the queue
     *At time 9, D runs first because D is shorter than C

------------------------
|A   |B      |D  |C    |
------------------------
0   3        9   11     15

(iii) *At time 0, A runs because it is the only choice
      *A runs even though B arrives because A got 2 times left compared to B (6)
      *At time 4, C overtake B because C still has 4 times left compared to B (5)
      *At time 6, C overtake D because C still has 2 times left (D=2)
      *At time 8, D overtakes B because D still has 2 times left compared to B(5)

--------------------------
|A   |B |C    |D  |B     |
--------------------------
0   3   4     8   10    15

(iv) *Each time slices cannot be more than two (minimum is one)

---------------------------------
|A  |B |A |B  |C  |D  |B  |C  |
---------------------------------
0   2  4  5   7  9    11  13  15

(2) What is average turn around time for 4 algorithms in (1)?

Formula for average turn around time is
[ Time Process Enter Sequences - Time Process Exit Sequences ]/[Number of Processes]
(i)   ( [3-0]+ [9-1]+    [13-4]+ [15-6] )/4 = 7.25
(ii)  ( [3-0]+ [9-1]+    [15-4]+ [11-6] )/4 = 6.75
(iii) ( [3-0]+ [15-1]+  [8-4]+   [10-6] )/4 = 6.25
(iv) ( [5-0]+ [13-1]+  [15-4]+ [11-6] )/4=8.25

(3) What is the wait time for each processes for 4 algorithms in (1)

Formula for wait time is
[ Turnaround Time ]- [ Execution Time ]

(i)   A:[3-3]=0   B:[8-6]=2   C:[9-4]=5    D:[9-2]=7
(ii)  A:[3-3]=0   B:[8-6]=2   C:[11-4]=7  D:[5-2]=3
(iii) A:[3-3]=0   B:[14-6]=8  C:[4-4]=0   D:[4-2]=2
(iv) A:[5-3]=2   B:[12-6]=6  C:[11-4]=7 D:[5-2]=3

(4) What is average throughput for 4 algorithms in (1)?
Same

15 time units / 4 jobs = 3.754 time units / jobs



^_^ Bye bye OS lectures notes. Gonna miss you .... erm not ... well sort of.

Tuesday, May 24, 2011

Nat Geo: The Microchip Special [Part1]

This is one of the few articles which sparks my interest in Electronics. ^_^ And you betcha National Geographic in 1980's is way more informational than the current National Geography

(P.S: DOUBLE CLICK ON THE PICTURE TO ENLARGE THEM)



 

Monday, May 23, 2011

Something is best left not to said . . .

But it is way much more better to put it up as web comics !


P.S: Notice that the Zeus is represented as God
Sometimes my beloved Idol move also failed

(So to those anyone else who claimed that the world is gonna end, please be reminded of the quack prophet ! Wonder what happens to that prophet who make the absurd claims) 

Saturday, May 21, 2011

Trip to Kaki Bukit, Perlis [Part2]

(P.S: Sorry for slow update. Got loads of stuffs to do)

After filling the stomach with pau , more pau and even more pau, and the Gua Kelam is not far from our destination, we decides to visit that cave.

 Yeah, yeah.... Gua Kelam

The entrance fee is RM 2 which is well ... pretty much reasonable. 
And you need to climb up the legendary "hundred steps" stairs 



After reaching the tops, you got 2 options 
Which are 
1: Take the choo choo train into the cave
2:Take the hanging bridge and hire RM40 experienced tour guide for leading expedition insides

 

But neither options are available as the infrastructure of caves inside are destroyed by Perlis Great Flood in Dec 2010 and March 2011. Pretty heavy combo damage yah which makes it is not safe for visitors to pay a visit inside. And don't forget to mention, a big gaping holes on the signboard possibly made by angry birds. Hehehehe ....


So what is left to done here? 
Basically is nothing, since there are also some chilly waterfall nearby but without extra sets of clothes, we just shrugged off the idea of dipping in.


I can bore with you some of the boring facts of Gua Kelam and Hakka communities but I think most of you would be scared upon hearing the word "Sejarah". So we went to Timah Tasoh Lake and see the Timah Tasoh flood gate which is partly responsible for Perlis great flood.



That's pretty much summarize the one morning trip to Kaki Bukit ^_^



Saturday, May 14, 2011

Trip to Kaki Bukit, Perlis (Pt1)

Just to celebrate of being the final year students in Unimap, my besties just decided to go to Kaki Bukit for the sight seeing and jalan jalan cari makan trip on a fine Saturday morning.

Along the way to Kaki Bukit, you can see lots and lots of rubber tree. 
This shot is taken at ~120km/h . My Powershot shutterspeed also geng leh .... 


And you can also see the beautiful big hills too along the way


If you see this signboard, congrats ! You just reached Kaki Bukit !

(P.S: If you drive from Kangar, it will takes only around 40 minutes) 
(Note: You can enter the Thailand thru Wang Kelian borders) 


And just sight seeing some pre-colonial house of Chinese communities. Btw, Kaki Bukit is mainly comprised of majority Hakka Chinese communities who were brought into Malaya as tin miner. 



I had to admit it, we are getting "lost" in here after turning rounds and rounds in here for hours just to find the legendary bigger-than-your-palm char siew pau. :) 
We finally found it but it is a nondescript shop . ;) You might as well miss it the 1st time you pass this shops but never mind. It is time to makan ! makan ! MAKAN !

Just to note, the char siew pau is ONLY available after the afternoon , so while we wait for pau to be made, me and my best friends  ordered some prawn mee. Emm.... the taste is quite nice not too oily and spicy. The noodles texture is just quite nice. Just try some of it when you arrived here. 


Coupled with the cool and sweet chrysanthemum drinks to quench thirst on blistering hot days.It is really damn hot here ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 
(P.S: The only available drinks they had is chrysanthemum .)


 Next, after waiting for quite "some" time. The 传说中 biggest pau in the Northern Malaysia (The *illusive* Kaki Bukit Pau) is at our tables. The 1st time, we look at it and just amazed. It is really big ! To show it is not illusions, just compared the pau to the size of both wallet and Iphone from the background. Forget to mentions, the pau sifu makes 3 types of pau: Char siew pau, Da pau and Dou Sa pau and remember they only came out ready only in noon (~12.30 pm). 

*illusive* means that the shop is really well hidden from main trunk road*_*


(Note: Free publicity for the pau shop !)
To those who wants to take away, you need to call first as the sifu limits himself in making a limited number of paus each day to maintain high qualitiness . What is their call number ? Hehehe... Just check the signboard out below 
(To the outstation visitors, you may need to append 04 in front)  . . . 








Another random post to read ? Come !

Related Posts with Thumbnails