Yoshi no Sekai

23 oct. 2011

Computer Science - Data Structure - Sorting

Ehh.... weren't we talking about japanese ???
Yes, but as the title of my blog says this blog won't be only for learning japanese, it will handle many subjects at the same time. Each person consulting it can make personal use the informations provided. Please don't hesitate to coment, or even leave send me e-mails about your impressions or advices or critics or whatever you want :p but the most important thing to do is to enjoy reading xP


So in this post we're going to talk about sorting types just some types i ll try to summarize the main idea of two or three we use the most, i ll try to be as clear as possible, all of this using C-Language.

Bubble sort (Tri à bulles) :

Example : (from wikipedia)

How to remember :

  • go across the tab from the end to the beginning with a first selector i=n;
  • with a second selector j go from the beginning to i, go across the tab this time by swapping each two values that need to be.
  • repeat the process with i-- and so on..

Program :



void tri_a_bulle (int t[],int n)
{
int i,j;
for(i=n-1;i>1;i--)
{
for(j=0;j<i;j++)
{
if(t[j]>t[j+1])
{
echanger(t+j,t+j+1); //echanger is a function that swaps two variables !
}
}
}
}


of course it's not the best version of the bubble sort, it's just a version i made to do exactly as the example shows. If there's any mistake or something isn't clear enough feel free to correct it in a coment or contact me directly. For the main program you'll find the download link at the end of this post, build&run it on your IDE like Code::Blocks (for windows) or Geany (for linux users), those two are my favorites by the way.



Let's move to a second type of sorting.

Insertion sort :

Example : (from wikipedia)


How to remember : 

  • consider your tab sorted until the position i-1
  • grab the T[i] and put it in "mem"
  • seek in the previous sorted squares if mem is lower then T[i-1] then put T[i-1] in T[i], go on like this until you find the first value < mem, this time u stop and put the value mem in its right place
Program :


void tri_par_insertion (int t[], int n)
{
int i,j,mem;
for(i=1;i<n;i++)
{
mem=t[i];
j=i-1;
while(j>=0 && mem<t[j])
{
t[j+1]=t[j];
j--;
}
t[j+1]=mem;
}
}

Selection sort :



Example :
 (from wikipedia)


How to remember : 

  • consider your tab sorted until the position i-1
  • seek the minimum of the following squares
  • put it in the i place, and repeat the same process until the end of your table
Program :


void tri_selection (int t[],int n)
{
int i,j,min;
for(i=0;i<n-1;i++)
{
min=i;
for(j=i+1;j<n;j++)
{
if(t[j]<t[min]) min=j;
}
echanger(t+i,t+min);
}
}

by this i end my post, it's not the best course you can find in the net of course but it's only my way of seeing things. hope you liked. Oh by the way here's the main.c file ^^!


22 oct. 2011

Japanese - Lesson Three

This time we're going to learn a lot of new words and the good way of making "self-presentation" when we meet someone, how to introduce ourselves correctly and nicely ^^! so let's take a look at it.

Self presentation : (じこしょうかい)

はじめまして。
わたしは(Yoshi)です。(replace Yoshi by your name of course ^^ )
(Morocco)じん です。(replace it by your country )
にほんご の がくせい です。
(nihongo : japanese language)
しゅみはおんがくです。(shumi : hobby / ongaku : music)
どぞよろしく おねがいします。(dozo yoroshiku onegaishimasu : pleased to meet you)

(by that time you should be able to read so i will only write some words to help...)

The other person can ask for more details about your specialty like this :
せんもん わなんですか。(senmon : specialty)
here are some possible answers :
ぶんがく               :         Literature
ぶつりがく           :         Physique
かがく                   :         Science
けんちくがく       :         Architecture
いがく                   :         Medicine
てつがく               :         Philosophy
やくがく               :         Pharmacy
じょうほうがく   :         Information science (jouhougaku)
けいざいがく       :         Economics
つうしんがく       :         Communication science (tsuushingaku)
...

if you noticed in the self presentation we also talked about hobbies, here are some other hobbies :

in katakana:

サッカー               :         Soccer  (sakkaa)
テニス                   :         Tennis (tenisu)
ゴルフ                   :         Golf (gorufu)
ジョギング           :          Jogging (jogingu)
インタネット       :          Internet (intanetto)
ピヤノ                   :         Piano
ギター                   :         Guitar (gitaa)
カメラ                   :         Camera

in hiragana:

すいえい               :         Swiming
りょこう               :         Travelling
さんぽ                   :         Walking
りょうり               :         Cooking
どくしょ               :         Reading

(bonus : からて and あいきどう)

hmm, that's are lot of new words...i guess it's enough for the moment.

Asking questions and answering :

Let's see how we ask yes-no questions, how to answer them negatively or positively.

Q: ヨシさん  わ   にほんご   の   せんせい   です  。(: to ask)
(yoshi-san)
A: いいえ、ヨシさんわせんせいじゃありません。ヨシさんわにほんごのがくせいです
(じゃありません : to express negation. です : for affirmative sentence or answer.)

Q:ヨシさん   わ  モロッコじん   です  
A:はい、 わたしはモロッコじんです。

i think it's enough for this lesson, hope you enjoyed ^^!


18 oct. 2011

Japanese - Second lesson


Here we go for the second lesson of japanese that we've gone through today. We've seen the "sister hiragana" wich is just like the normal hiragana but we add a small letter beside our letter wich changes the sound for example : き(ki) becomes きゃ(kya) or  きゅ(kyu) or  きょ(kyo) that all, isn't it easy :p ?

^^! you may be asking yourself : "But what is the difference between this きゃ(kya) and this きや(kiya) ?"
it's true that they seem almost the same, it's just that the first one is pronounced in one syllable the second one in two times, and the thing that is incredible in this, is that this sound can change the whole meaning for example :

う (jyuu)    : ten                     &               じう (jiyuu)    : freedom
く (hyaku) : one hundred       &               ひく (hiyaku) : jump
||||| (byouin) : hospital  &               |||||| (biyouin) : beauty salon
|   1  |2 | 3 | 4 |                                               | 1 |2 | 3| 4 | 5 |    
(Note: there a real difference in size if you take a good look at it, and also the diffrence in syllables shown in the last example)

So confusing i know, but don't worry, i m just as confused as you ^^!


Let's see now some new letters called "katakana" wich are like "hiragana" but used for specific things like : names, sports, countries.... both of hiragana and katakana were issued from "kanji" (something we'll see in futur lesson with god's willing) you can check wikipedia for more information about that. Most important things we need to know is the order of writing a letter, in those two pictures you can see exactly how to write each letter :

Hiragana : (that we've seen in the first lesson but this time try to focus on the order of writing it's important)

Katakana : (^^....again something we need to learn by heart :p and again you need to learn the order of writing as shown in the picture)

Let's see now some (or many i should say) examples of words written in katakana :

ク (ke~ku) : cake (this symbol ー means u need to lengthen the letter and say keeku not keku)
アイスクリーム (aisu kuri~mu) : ice cream
コーヒー (co~hi~) : coffee (but read hii and not fee like english !)
ーツ (supo~tsu) : sport (not the use of brother katakana)
サッカー (sa??ka~) : football (soccer) (there's a use of a sister katakana... but i'm not really sure about it...?)
テニス (tenisu) : tennis
ライオン(raion) : lion
スパイン (supain) : Spain
ロシア (roshia) : Russia
イタリー (itari~) : Italy
フランス (furansu) : France
ラバト (rabato) : Rabat

anyway, i think it's going to be enough for the moment, we'll see more things after, i hope you found this course interesting...if you have some advices or critics or.. anything that could help me improve what i'm doing just tell it to me, either in private or by commenting. Thank you for reading see you next time with new things with god's willing....

15 oct. 2011

Japanese - First lesson


After we've learned the hiragana to sit for the test for japanese lessons in the Faculty of human sciences (near to ENSIAS) we started the first lessons concerning the brother hiragana which is in the bottom left of the image. We add two points (ten ten) near the letter to obtain a new sound for example with か (ka)  it becomes が (ga) and so on. There is one exeption for は wich has two brothers ば (ba) and the second one ぱ (pa) we put a circle (maru) instead of two points. The sister hiragana ar going to be for the next lesson.

We have also learned many expressions of daily use like :


Some other expressions we've seen are :

おかげ さま です (okage sama desu) : praise be to god
にほん じん (nihon jin) : a japanese person
にほん ご (nihon go) :  japanese language
がくせい (gakusei) : student
だいがく (daigaku) : university
きもの (kimono) : traditional clothes

Some letters that have signification :

は (ha) : teeth  || て (te) : hands || め (me) : eyes || ち (chi) : blood || え (e) : picture

To ask questions :

Example :

1)  なまえ ?(o namae wa ?) : what is your name ?

: is a polite attachment. We put it in the begining of the sentence
: is a particule that designs "other person". like "you" for example

Other examples :

2)  うち ?(o uchi wa ?) : where do you live ?
3)  しごと  ?(o shigoto wa ?) : what is your job ?
4)  くに  ?(o kuni wa ?) : what is your country ?
(note : the last particule (ha) si pronounced 'wa' )

Answers :

1) あたしは Yoshi です。
2) (うち は) Salé です。
3) (しごと は) がくせい です。
4) (くに は) Morocco です。あたし Morocco じん です。
                                             atashi mo Moroccojin desu. (me too i'm moroccan)

Some more other words :

おなじです (onaji desu) : the same
おめでとう ございます (omedetou gozaimasu) : congratulations
せんせい (sensei) : teacher
(note: we don't pronounce "ou" we just lengthen the o like this "oo", the second read "ee" instead of "ei" )

おげんきですか ?(o genki desu ka ?) : how are you ?
--> はい、げんき です。(hai, genki desu.) : yes, i'm fine.
-->いいえ、びようき です。(iie, biyouki desu.) : no, i'm sick.

Here are some more things you should learn like numbers, time days...

            

(tip: for pictures try to oppend them in a new tab to see the full size)
じゃね (jane) ^^!