Java: MergeSort
Fully functional but I still can’t quite understand the syntax. I know the logic but Java is new to me, so it needs a lot of debugging time ^_^
—-Beginning of Code—-
import java.io.*;
public class MergeSortArray {
private long[] theArray;
private int nElems;
public MergeSortArray(int max) {
theArray = new long[max];
nElems = 0;
}
public void insert(long value) {
theArray[nElems] = value; // insert it
nElems++; // increment size
}
public void display() {
for (int j = 0; j < nElems; j++)
System.out.print(theArray[j] + " ");
System.out.println("");
}
public void mergeSort() {
long[] workSpace = new long[nElems];
recMergeSort(workSpace, 0, nElems - 1);
}
private void recMergeSort(long[] workSpace, int lowerBound, int upperBound) {
if (lowerBound == upperBound) // if range is 1,
return; // no use sorting
else { // find midpoint
int mid = (lowerBound + upperBound) / 2;
// sort low half
recMergeSort(workSpace, lowerBound, mid);
// sort high half
recMergeSort(workSpace, mid + 1, upperBound);
// merge them
merge(workSpace, lowerBound, mid + 1, upperBound);
}
}
private void merge(long[] workSpace, int lowPtr, int highPtr, int upperBound) {
int j = 0; // workspace index
int lowerBound = lowPtr;
int mid = highPtr - 1;
int n = upperBound - lowerBound + 1; // # of items
while (lowPtr <= mid && highPtr <= upperBound)
if (theArray[lowPtr] < theArray[highPtr])
workSpace[j++] = theArray[lowPtr++];
else
workSpace[j++] = theArray[highPtr++];
while (lowPtr <= mid)
workSpace[j++] = theArray[lowPtr++];
while (highPtr <= upperBound)
workSpace[j++] = theArray[highPtr++];
for (j = 0; j < n; j++)
theArray[lowerBound + j] = workSpace[j];
}
public static void main(String[] args) {
int maxSize = 100; // array size
MergeSortArray arr = new MergeSortArray(maxSize); // create the array
System.out.print("How many input? [1-100]: ");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Integer howMany = null;
try {
howMany = Integer.parseInt(br.readLine());
} catch (IOException e) {
System.out.println("Error!");
System.exit(1);
}
for(int i=1; i<=howMany; i++){
System.out.print("Enter number " + i + ": ");
BufferedReader br1 = new BufferedReader(new InputStreamReader(System.in));
Integer iNum = null;
try {
iNum = Integer.parseInt(br1.readLine());
} catch (IOException err) {
System.out.println("Invalid Input!");
System.exit(1);
}
arr.insert(iNum);
}
arr.display();
arr.mergeSort();
arr.display();
}
}
—-End of Code—-
Jennifer’s Body
I watched Jennifer’s Body last night and it was not as I expected. I read about how this movie sucked before in various forums and blogs so I had little expectations with this movie, and surprisingly it was not that bad. Storyline was good but Megan’s acting is not that good. I think they included her in the cast just for eye candy, just to sell sex; the transition from good to bad of the character was not properly played by Megan. Aside from her acting, everything else is good enough to see it. Plus the soundtrack is great!
Mission Report
Mission Objective:
To conquer the Isles
The Team:
The Drama Queen – team leader, mission researcher and planner, master of disguise
The Caregiver – chief medical officer, quarter master
The Foreigner – intelligence officer, team interpreter and spokesperson
The Exorcist – research officer, marine, detoxification expert, bomb expert
The Girlfriend – equipments officer responsible for overall navigation and transport, communications engineer, specialized biological weapons expert capable of stopping speech
The Killer – special weapons officer, has a deadly wink, master magician
Ang Huling Birhen sa Lupa – surveillance officer, medical officer
Ang Tsuk-Tsak – psychological war expert, weapons master, able to deliver a deadly blow potent up to 3 minutes, superior physical strength
The Night Before:
21:00 — The Girlfriend arrived at The Foreigner’s place first, The Drama Queen arrived a short while later. After careful planning, the three set out to meet with the other operatives.
First stop was at The Caregiver’s place. Then they went to pick-up Ang Huling Birhen sa Lupa. The Academic was the next stop but was caught up in another mission. They met-up with The Killer then roamed the streets in search of Ang Tsuk-Tsak who had to swing by his safehouse to acquire much needed equipment.
Day 1:
00:00 — The team arrived back at The Foreigner’s place and attempted to rest for the day’s mission.
04:30 — The sleep-deprived team was roused by The Exorcist’s text message. The Girlfriend went to meet up with the Exorcist while the foreigner and the caregiver prepared breakfast. The drama queen contacted the academic who still wasn’t available for the mission.
05:30 — After taking care of some loose ends, the team was en route to the mission site. The Girlfriend was driving with Ang Tsuk-Tsak navigating. Everybody was in high spirits.
Secondary Mission: Survey all churches along the way and document the visits
The team deemed it impossible to accomplish the mission without compromising the main mission so they decided to implement random sampling. They were able to visit 3 churches.
09:00 — The team, not wanting to blow their cover, posed as regular tourists and took pictures on the viewdeck. Ang Tsuk-Tsak took over the driving while the drama queen navigated.
09:30 — The team arrived at the seaside safehouse and immediately made arrangements to acquire supplies.
10:30 — The team split-up into 2 groups, one (The Exorcist, The Caregiver, The Drama Queen, The Foreigner) set-out to survey the place while group 2 (The Girlfriend, The Killer, Ang Tsuk-Tsak, Ang Huling Birhen sa Lupa) went out for some additional supplies.
Special weapons were distributed to all team members. The items were: a shirt, 2 shorts, a nail grooming set, 2 combs, a box of rubber hair bands, a wooden mug and a deck of cards. All of which proved to be very useful in the mission.
11:00 — After changing into their dry wetsuits, the team was finally on their way to the primary mission site aboard an ocean vessel steered by a certain Mang Jerry. He briefed the team on the local knowledge of the site and took them on a tour.
Finally arriving at the primary mission site, they set out to have the time of their lives. There was nobody else there but the team. They swam, ate, drank and laughed. Pictures were taken of almost anything and everything on the island.
The team decided to do a survey of the primary mission site and ended up under a hollow side of the island. As the waves grew stronger the team was pushed into the sharp rough wall of rock and sustained injury. When Ang tsuk-tsak, ang huling birhen sa lupa, the virgin and the girlfriend were able to get the team out of the immediate danger, the caregiver attended to the cuts and scrapes.
Sand and water samples were analyzed and tested for possible uses—exfoliant, building material, sustenance and waste/evidence disposal.
17:00 — The team went back to the safehouse for the night on the same ocean vessel bringing with them sand samples as well as a few algal samples.
19:30 — The exhausted team had dinner of green mangoes, tomatoes and chicken at the safehouse terrace overlooking the ocean then trained for the next morning’s mission. Night surveillance was considered but being too tired they decided against it.
Inside the safehouse, the team practiced their special skills until morning. Details of which are deemed as “need-to-know” basis.
Day 2:
07:30 — The team was awakened by The Foreigner informing them of an emergency operation to be done on the primary mission site. The team geared-up for it.
08:30 — The team was again en route to the primary mission site in the same vessel. Once there, they again tested sand and water samples plus rock samples but the weather wasn’t cooperating. The Drama Queen discovered that sand and water can preserve 25-cent coins. The Foreigner became skilled in handling the surveillance camera. The Caregiver discovered extra sensory perception. The Girlfriend discovered how calendar pictures were shot. The Killer, Ang Tsuk-Tsak and Ang Huling Birhen sa Lupa surveyed the water for seaweed and algal growth. The Exorcist saved strength for the trip home.
13:00 — Time to leave the primary mission site for the safehouse and get ready for the trip home. The wind was becoming stronger and the waves bigger. The team had to get out fast. Braving the waves one final time on the same vessel, the team headed back.
16:30 — After checking all the equipment, the team was ready to head home. The Girlfriend drove and The Caregiver navigated. They had a very late lunch comprising of noodles and toppings at a fastfood place.
The team made a quick stopover at The Caregiver’s summer house. During the long and rainy trip (no STAIRS in the sky) the team assessed the mission and made plans for the next one. They decided that the next one might just be in Subic or if time and resources would allow, maybe even Boracay.
20:00 — The team arrives at The Foreigner’s place. They rested and had the debriefing over dinner. The Caregiver and The Killer took care of cleaning up the evidence.
23:00 — The Girlfriend drove everybody home. Everybody was reluctant to go but the vision of the next mission was enough to inspire them.
Recomendations:
There is a need to train and invite more operatives for the next, bigger mission.
“tatawagan mo parin ba ‘ko susulatan mo pa ba ako tayo parin ba ‘ng dalawa kahit …na bye bye na aalis ka na bye bye na rin ba sa atin alaala”
Mission Accomplished!
“Grabe guys thanks for the company, this outing is so fun, sobra ang bonding. Miss ko agad kayo. We should do this again and again to the nth time. Thanks talaga. Love yah all!” — The Exorcist
“Thanks guys, and I want to grow old with you all! Ay mali, ulit…..I want to grow old with you guys!” — The Caregiver
“Guys, thanks for lending me your ears and for just simply being you..I have found the real unconditional, fun-loving, happy, etc. etc. frends in you! I thank God for that…Love you all..GBU” — The Drama Queen
“We went on this trip as friends, we came back as a family. My heart has found seven new places to come home to. Thank you for making room in your lives for me. Love you guys so much.” — The Foreigner
“Thanks for inviting me to this outing, sana nag-enjoy kayo sa company ko.” — Ang Huling Birhen sa Lupa
“Heller!!! Sarap ng feeling ko kahit sermon me sa bahay! Sana maulit yung outing pwedeng mamaya ulit? Hehe. Thanks guys! I really enjoyed sa outing natin. Just keep in touch and stick together. MGA PANGET!” — Ang Tsuk-Tsak
“Oo nga e..Pati din ako may lagnat. Pero mas matindi pa din yung effect ng mga alaala natin…Uy nagdrama daw! Hahhaha!” — The Killer
“All the smiles, the laughter and the tears, I have only seen and experienced it here. Years may have passed and we may have matured, but definitely the kid in us always appears whenever we’re together. I would never trade a single moment i have experienced with you guys. You all are true friends and i hope we can pass this treasure to future generations. thanks! i love you all”. — The Girlfriend
MV: Hikari by Utada Hikaru
I just thought about one of my favorite singers and I remembered the first time I saw her and liked her video. The music video is really simple and yet it didn’t fail to catch my attention. I first saw her and this video back in 2003 when Noel included it in a compiled VCD and played it during Betlog’s birthday party. I was captured by her grace it took me about a week to find out who she was. Here is the music video.
Ez Quotes
I have made a collection of quotes from Ezra’s Facebook Profile. Some are downright funny and some hit you right on the spot.
- Miss, ok ka rin noh?! Ang kapal ng mukha mo! Hindi pa nga kita nakikilala pina-ibig mo na ang puso ko.
- Ice ka ba? – Crush kita, okay lang?
- You look cold. Want to use me as a blanket?
- Do you have a Band Aid? I just scrapped my knee falling for you..
- your lips look so lonely – would they like to meet mine?
- I may not be Fred Flintstone but I can sure make your bed rock!
- minsan gusto kita tisurin bigla… para mahulog ka na sa akin
- feeling ko mouse tayong dalawa.. you know.. we just click!
- Aanhin mo pa ang bahay nyo.. Kung nakatira ka na sa puso ko?
- kung may rabis ang laway mo. handa akong maulol makahalik lang sayo
- magaling ka naman sa math di ba?? paki substitute naman yung X ko please
- 1 over 100 lang ako kanina sa exam ko dahil sayo!!.. Ikaw lang kasi ang tama sa buhay ko
- Excuse me! Miss alam mo ba yung kasabihan ng mga Pilipino?”Aanhin pa ang damo, kung sayo pa lang may tama na ko”
- pag ako gumawa ng planeta, gusto ko ikaw ang axis ko para sayo lang iikot ang mundo ko?
- Kung ikaw ay bola at ako ang player, mashu shoot ba kita?? hindi, para lagi kita mamimiss..?
- Nung mahalin kita…..daig ko pa ang na traffic sa EDSA……I can’t move on
- ibibili kita ng salbabida… kasi malulunod ka sa pagmamahal ko
- ang buhay ko ay parang nakasakay sa seesaw…pag wala ka down ako
- your tears don’t fall.. they crash around me
- Biniro kita, ginago mo ko. Nasaktan kita, tinarantado mo ko. Sa lahat ng ginawa ko, mas matindi ang ganti mo. Kaya ngayon, tanong ko lang. Bakit di mo pinantayan ang ginawa ko nung mahalin kita ng todo-todo?
- infatuation can only hold the mind for a maximum of 4 months.. if it exceeds that point, i guess you’re already in love..
- mas madaling ngumiti kahit hindi ka masaya kesa ipaliwanag kung bakit malungkot ka
- staying single makes a person a permanent public temptation
- may kandila ka ba dyan?? pwede pakitirik sa dibdib ko, para sa puso kong patay na patay sa iyo
- pwede ba pagkatapos mo sagutan ang exam mo, ako naman ang sagutin mo?
- pwede bang tumingin ka sa akin habang nakataingin ako sa iyo?? para may pagtingin tayo sa isa-t isa
- hindi ka manlalamig sa isang tao kung wala kang nilalanding bago
- the silence of a woman tremendously shakes the consciousness of men
- miss BariL kba? pede pa tira? kahit isang putok lng..
- sometimes the people who are afraid of having commitments are the persons who know the real meaning of it
- (advice from dentists): treat your bf / gf like a toothbrush, do not let anybody use them.. and change them every three months
- sana holdaper ka na lang.. para ibibigay ko sa iyo ang lahat basta wag mo lang akong sasaktan
- advisory: do not use real sarap or magic sarap seasoning.. dahil ang tunay na sarap, sa akin mo lang malalasap ehehe
- don’t make the same mistake twice, madami pang kasalanan dyan, try mo din yung iba
- i am not sad when i see my ex flirting with someone because i know how to share my used toys to poor children
- (advice para sa mga ex) – ingat ka ha.. tanga ka pa naman
- before you find fault be sure you are dealing with facts, not figments of the imagination.. (translation: bad ang manlait pero kung totoo ayos lang)
- don’t ever try to understand everything.. some things will just never make sense
- the trouble with most people is that they have diarrhea of the mouth but constipation of the brain
- love hurts when God knows we deserve someone else
- you have to learn that sometimes it is not love, it is just a feeling and you just over- reacted
- how can you simply forget someone who has given you so much to remember?
- everything will be okay in then end, if it is not okay then it is not yet the end
- the only thing more dangerous than a beautiful lady is a lady who can think
- no matter how plain and simple you are, there is someone who will surely look at you as if you are the most perfect creature that ever existed
- everybody go crazy over happy endings but how could it be happy if it is already the end?
- i can always take care of myself.. still, i want to meet the person who can prove me that i can’t
- it’s better to have nobody than somebody who is half yours, half there or doesn’t want to be there or is there and then suddenly disappears
- it is true that people can move on but you can never change the fact that only amnesia and death can erase memories
- if you can’t be happy, be yummy
- don’t underestimate the power of stupid people in large numbers
- what’s the use of your so-called beauty when no man takes you seriously??
- there are two perfect guys out there, the only problem is that they are dating each other ehehe
- wag kang matakot na hindi na maayos ang lahat ng gulo sa buhay mo.. malay mo ginulo lang talaga yan para umayos ka
- why is it that the phrase ” i love you ” desperately seeks an answer when in the broadest sense it is not even a question?
- lahat ng problema may solusyon, kung walang solusyon, wag mong problemahin
- everybody go crazy over happy endings but how could it be happy if it is already the end??
- wag kang choosy kung hindi ka naman yummy!!
- masarap magmahal kung ang minamahal mo ay masarap..
- sometimes, just to make sure i was wrong, i’d make the same mistake twice
- di mo pa ako binabato pero tinamaan na ako sa iyo
- pinapatanong ng nanay ko kung ABSCBN ka daw ba?? gusto ka na niya kasi maging kapamilya..
- kung magiging bagay ako gusto ko maging palito.. ikaw? sana palito ka na lang din para match tayo
- pwede ba kitang maging side car? single kasi ako eh
Reflection
Here I am lying in bed listening to the squeak of the electric fan accompanied by the sound of the rain dropping on our roof. I feel sleepy and yet I can’t seem to doze off, must be the ganja I smoked earlier. I never had this silence for a while and this gave me the chance to think and reflect about the things happening in my life. A lot is going through my mind right now and I sort of think that I am having a mid-life crisis.
I recently submitted my letter of resignation for the company I worked for. The main reason is that I really don’t enjoy now what I am doing, then there are other factors like the incompetence of your co-workers or the fact that some of them talk shit behind my back. People with so little room for thinking are not allowed to become superiors in my opinion. I used to love what I was doing at work. Every day, I look forward to coming to work back then. I look forward to learning new things and discovering solutions to the problems that lay. And then after a couple of years, things started to get dull, work became monotonous and soon I realized that career growth was very slow. And since my original plan was to stay there for 5 years and last September I have achieved that goal, I think that it is time for me to move on.
My only concern now is whether I think I made the right choice or not. With my current job, we could somehow get by and manage to save a little. There’s a sense of financial security… somehow. What I am afraid of now is that I have no plans whatsoever after I resign. I want to take a break first before I find another job. I want a new line of work. I want to experience something new, something different. Then I found this car for sale online and it made me want to buy the car, the only solution I can think of is to sell my Nouvo and then get a 2-year loan from our cooperative. If I get that loan though, it would mean I have to extend my stay for 2 years. So I really need to think about whether I really like the car or not, because if I really want the car, I will convince myself that 2 years is not that long. But then I again, I think couldn’t even last a month at my work. See my dilemma?
The reason that I really can’t stay long now at my job is that our department is falling apart. Every one of us has a fault and people are scared enough to not face the problem or even bother to know what is wrong. I got a boss that is kind and understanding, sometimes too much for the departments good. Sometimes we need a boss that would reprimand our mistakes right? Then there’s this guy who has got nothing else to do but put blame on all the people that he can lay his sight on! Every time you hear his voice, you can just hear that he is blaming some other guy. Or rather he has a wise-ass comment about every other person in the department. An advice I could give him is that, if he has nothing good to say, better shut up. Who needs a superior that doesn’t give compliments to his guys? And then there’s this person who has a great inferiority complex who thinks that he is always right and that he could practically do what he pleases. He is never wrong. And for the rest, including me, we are just plain lazy! We slack off because we can. Who would want to work for such a department?
I just hope things will turn out good with my decision of leaving the company. I want to find a job where I don’t feel like I am doing a job but rather doing something I really like and getting paid for it.


