Solution to hw00c
- Log in to post comments
Solution to hw00a
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
printf("Hello, CP!\n");
return EXIT_SUCCESS;
}
- Log in to post comments
Solution to hw00b
[code language="c"] #include #include
using namespace std;
int main(int argc, char *argv[]) {
// read input from keyboard and store in n
int n;
scanf(\"%d\",&n);
int curr; // current fibonacci number
int next; // the next fibonacci number
// compute n-th fibo number
curr = 0;
next = 1;
for (int i = 0;i < n;i++) {
int tmp = next + curr;
curr = next;
next = tmp;
}
//display output
printf(\"%d\\n\",curr);
return EXIT_SUCCESS;
}
[/code]
- Log in to post comments
Algorithm Design, first semester, 2010
News (latest first)
cafe grader is available at http://www.nattee.net/grader For discussion, please use the main webboard Email is encouraged, please start your subject by [algo] and include your real name and id as well
- (15-09-2010) Slide and lecture note #3 of search is available.
- (13-09-2010) Lecture note for search is available, graph lecture note #3 is also online.
- (29-08-2010) Slides and lecture notes of graph algorithm and shortest path and greedy are available.
- (27-08-2010) Homework #6 is published.
- (13-08-2010) Graph: slide and lecture note are available.
- (12-08-2010) Homework #5 is published.
- (25-07-2010) add more slides for Dynamic Programming
- (21-07-2010) Homework #4, Lecture note #2 is available. (see below)
- (14-07-2010) Lecture note #1 is available. (see below)
- (13-07-2010) Homework #3 is extended to monday (19 Jul).
- (08-07-2010) Homework #3 is available. Due date is 14 Jul.
- (05-07-2010) Full syllabus is available here
- (16-06-2010) Homework #1 is available. Nobody opts out of homework system. This marks the end of opt-out period. For section 3, we won't have a class on 18 Jun and 25 Jun. On 27 Jun, we will have the second quiz.
- (10-06-2010) Tomorrow we will have first quiz. Please check this file for your seating. Quiz will start exactly at 0900. This is test run, anybody attending the quiz will get full score regardless of their submission.
- (09-06-2010) Syllabus --short version-- can be downloaded
- (01-06-2010) list of username for grader system is available.
- (31-05-2010) The first set of h/w is available. This one does not count for final scoring.
- (31-05-2010) Video and docs for introduction is up!.
- (18-05-2010) Course syllabus will be available soon.
- (18-05-2010) The student are required to finish homework 00 before semester begin.
Resource
- Download course syllabus here.
- Lab docs of 2009 can be found here
- Introduction to cafe-grader is here. You can also download dev-c++ and grader introduction video.
- Our local copy of Bloodshed Dev-C++
C++ Resource
- !!!Read this first!!! Our Hello, CP! tutorial, which is the first lab of the 2009. This will guide you through your first C program. The IDE used in the lab is Dev-C++
- An Introduction to C Programming for Java Programmers is a good starting point since you all are familiar with JAVA
- Website cprogramming.com has very good tutorials. We suggest reading lesson 1 to lesson 10.
- Array and pointer in C is more complex than that of JAVA, check this one for a good introduction.
- The C Book, another book for C beginners.
- Thinking in C++ by Bruce Eckel, a must-read for most C++ developers. The second edition of the book can be downloaded for free.
C++ Development platform
- Dev-C++ is the recommended platform
- Code::Blocks is also a good alternative
Quizzes
- The first quiz (11 Jun) is here. Its solution is also available.
- The second quiz (25 Jun) will be available soon.
Assignment
Solution and test data will be available when the submission of the particular problem is closed. Solution marked by [ref] means it is the reference solution. Be noted that there are definitely more than one ways to solve the problem.
Name Issue Date Due Date Solution Test Data hw00a_helloworld pdf 18 May 2010 7 Jun 2010 ref hw00b_fibo pdf 18 May 2010 7 Jun 2010 ref hw00c_drawbox pdf 18 May 2010 7 Jun 2010 ref hw00d_timeafter pdf 31 May 2010 7 Jun 2010 ref hw00e_BMI pdf 31 May 2010 7 June 2010 ref hw00f_aminmax pdf 31 May 2010 7 Jun 2010 ref hw01a_palindrome pdf 16 Jun 2010 27 Jun 2010 hw01b_drawtri pdf 16 Jun 2010 27 Jun 2010 hw01c_minmax2 pdf 16 Jun 2010 27 Jun 2010 hw02a_drawstar pdf 30 Jun 2010 7 Jul 2010 hw02b_sudoku pdf 30 Jun 2010 7 Jul 2010 hw02c_nodemax pdf 30 Jun 2010 7 Jul 2010 hw03a_pairsum pdf 8 Jul 2010 14 Jul 2010 hw03b_tiling pdf 8 Jul 2010 14 Jul 2010 hw03c_sds pdf 8 Jul 2010 14 Jul 2010 hw04a_lcs pdf 21 Jul 2010 4 Aug 2010 hw04b_barcode pdf 21 Jul 2010 4 Aug 2010 hw04c_denomination pdf 21 Jul 2010 4 Aug 2010 hw05a_path pdf 12 Aug 2010 18 Aug 2010 hw05b_dilation pdf 12 Aug 2010 18 Aug 2010 hw05c_friends pdf 12 Aug 2010 18 Aug 2010 hw06a_wall pdf 27 Aug 2010 3 Sep 2010 hw06b_virus pdf 27 Aug 2010 3 Sep 2010 hw06c_exchange pdf 27 Aug 2010 3 Sep 2010 hw07a_mst pdf 8 Sep 2010 15 Sep 2010 hw07b_sort pdf 8 Sep 2010 15 Sep 2010 hw07c_salesman pdf 8 Sep 2010 15 Sep 2010 hw08a_seqsum pdf 21 Sep 2010 15 Sep 2010 hw08b_knapsack pdf 21 Sep 2010 6 Oct 2010 hw08c_robot pdf 21 Sep 2010 6 Oct 2010Lecture summary (Section 3)
Lecture note assignment is here. Lecture note should be handed in in the next lecture. If you wish to send via email, please include [algo] in the topic.
- (09-06-2010) First meeting slide
- (16-07-2010 -- 25-07-2010) Analysis Introduction slide
- (30-06-2010 -- 02-07-2010) Converting program into Big-O slide
- (07-07-2010 -- 14-07-2010) Divide and Conquer slide | lecture note #1 #2
- (21-07-2010 -- 23-07-2010) Dynamic Programming slide slide MCM slide LCS | lecture note #1 #2
- (04-08-2010 -- 11-08-2010) Graph algorithm slide lecture note #1 #2 #3
- (11-08-2010 -- 25-08-2010) Shortest Path slide lecture note #1 #2
- (27-08-2010) Greedy slide lecture note
- (01-09-2010 -- 15-09-2010) Search slide lecture note #1 #2 #3 #4
- (15-09-2010 -- 17-09-2010) NP Complete slide lecture note
- Log in to post comments
Diet Diary #48 -- #52
26 April 2010, Mon
morning weight: 82.0 kg (ซาลาเปา Spree does not kill me)
09:00 BF: 2 Bananas + water 12:30 Lunch: ข้าว + ปลาทอด 18:15 Dinner: ข้าว + ทอดมัน + กะหล่ำปลีดอง + ไข่ลูกเขย 04:00 go to bed
The last day at IOI camp. All I can remember is that I ate a lot of stack today. Lays, Tarts, Cola, Dim Sum ,etc....
27 April 2010, Tue
morning weight: 82.6 kg (No banana!)
10:00 BF: 2 Bananas + water 12:30 Lunch: ไก่ย่าง + ข้าวเหนียว + ส้มตำ + ลาบ + ต้มแซ่บ 20:15 Dinner: มาม่าผัด + ขนมจีบ + ยำสาหร่าย 04:00 go to bed
The banana I brought from IOI camp is inedible. So I don't have anything to eat in the morning
28 April 2010, Wed
morning weight: 83.0 kg (2nd Day without banana!)
12:30 Lunch: ข้าวกะเพราไก่ทอด 15:00 Snack: Creme Roll + Banana Cake 18:15 Dinner: Sausage Steak + เส้นหมี่ราดหน้าไก่ @ สะอาดโภชนา 04:00 go to bed
No badminton again... This month, I hardly done any exercise.
29 April 2010, Thu
morning weight: 82.6 kg
09:00 BF: 2 Bananas + water 12:30 Lunch: Tuna Saland (350g) 18:45 Dinner: Hamburger เข้าเหนียวหมูย่าง + 2 x Big Bite @7-11 22:00 go to bed (but woke up at 04:30)
Finally, I managed to get banana in the morning.
30 April 2010, Fri
morning weight: 82.2 kg (Back to 82, finally)
06:30 BF: 2 Bananas + water 13:30 Lunch: Tuna Salad (350g) 15:00 Snack: เต้าส้อ + biscuit 18:15 Dinner: ข้าวราดหมื่นลี้กุ้ง 02:00 go to bed
Another day with salad. My friend, Sun, came back from Japan for a short stay and he visited me with biscuit, irresistible.
- Log in to post comments
Diet Diary #46 , #47
24 April 2010, Sat
morning weight: 81.8 kg (slightly upward)
10:00 BF: 2 Bananas + water 12:30 Lunch: ก๋วยเตี๋ยวไก่ + ข้าวขาหมู 14:00 Snack: ขนมปัง 16:00 Snack: ซาลาเปา 16:10 Snack: ซาลาเปา 16:20 Snack: ซาลาเปา 18:30 Dinner: Fillet Minion steak + lots of side dishes 19:20 Snack: ซาลาเปา 20:20 Snack: ซาลาเปา 03:00 go to bed
No more salad today, but in the evening we went to Cowboy land, a nearby steak house. For the total of 12 people, we spend around 4,000 baht for dinner. I ate ซาลาเปาใส้หมูแดง all day.
25 April 2010, Sun
morning weight: 81.8 kg (ซาลาเปา Spree does not kill me)
10:00 BF: 2 Bananas + water 12:30 Lunch: ไก่ย่าง + ข้าวเหนียว + ส้มตำ + ลาบ + ต้มแซ่บ 13:00 - 18 :00 Snack Spree!!!: Lays + ขนมปังใส้กรอก + ขนมปังใส้กรอก + ทาร์ตจิ๋ว + ขนมปังใส้กรอก + ทาร์ตจิ๋ว + Lays 18:15 Dinner: ข้าว + ทอดมัน + กะหล่ำปลีต้ม + หมูย่าง 19:20 Snack: กล้วย 04:00 go to bed
Lots of work to do. Lots of food nearby, so, I simply eat a lot. Let's see tomorrow weighting. In the past 3 days, I had to work very late. Don't know whether it affects my weight much.
- Log in to post comments
Diet Diary #42 -- #45
20 April 2010, Tue
morning weight: 82.9 kg (Is this possible!!)
08:00 BF: 2 Bananas + water 12:30 Lunch: Tuna Salad (350g) + Tuna spread & Cracker 16:00 Snack: ทาโร่ยักษ์ (another souvenir from Korea) 18:00 Dinner: ข้าวราดแกง 01:30 go to bed
Surprised!!! My weight drop 1 kg in a day! Either my scale is broken or Morning Banana is working as it claims. In the book, it is said that excess weight from short-term eating spree can be siphon quickly. I guess it's the former case, though.
21 April 2010, Wed
morning weight: 82.5 kg (Dwindle)
08:00 BF: 2 Bananas + water 12:30 Lunch: Tuna Salad (350g) 18:00 Dinner: ข้าวราดแกง 22:30 go to bed (but woke up on 03:00 the next day, have some work to be done before morning....)
22 April 2010, Thu
morning weight: 82.2 kg (And Dwindling)
08:30 BF: 2 Bananas + water 12:30 Lunch: Tuna Salad 15:00 Snack: Sponge Cake 18:30 Dinner: ข้าว + หมูทอด + ผัดผัก + ไก่อบ + ต้มยำเห็ด 20:00 Snack: Sausage Bread 02:00 go to bed
I went to IOI camp at Kasetsart, Kamphaeng Saen campus. The food here is abundant. They treat us with light meal all the day. I can't resist the afternoon snack and night snack. However, I didn't eat after 20:00
23 April 2010, Fri
morning weight: 81.7 kg (Hmm?)
10:00 BF: 2 Bananas + water 12:30 Lunch: Tuna Salad 14:00 Snack: กะหรี่ปั๊ป + Donut + ไมโล 16:00 Snack: เอแคลร์ 18:30 Dinner: ข้าว + ผัดผัก + ปลาทอด + แกงจืดวุ้นเส้น + ไก่ผัด 20:00 Snack: Donut 03:00 go to bed
Another day at Kamphaeng Saen. I did bring my scale here. Today marks the five consecutive day of "Tuna Salad Lunch". However, snacking is even worse. I had three treats of snack.
- Log in to post comments
Diet Diary #38 -- #41
16 April 2010, Fri
morning weight: 82.3 kg (Wooohoooo)
08:00 BF: 2 Bananas + water 12:30 Lunch: Chester Grill @ Lotus ดาวคะนอง 19:00 Dinner: Zen restaurant + Swensen's Earthquake @ Central Rama 2 (BIG MEAL) 01:00 go to bed
Hmm... The dinner is quite BIG! Also this has been the first time of ice cream since Morning Banana.
17 April 2010, Sat
morning weight: 82.9 kg (Hmmm)
09:00 BF: 2 Bananas + water 12:00 Lunch: Loong Fong Restaurant (Dim Sum buffet) Eat WAYS TOO MUCH 17:00 Dinner: กุ้งเต้น Restaurant @ Ratchapruek Rd. 19:00 Supper: Banoffee Cake, Chocolate Mud Cake, Blueberry Pie @ Anna Charlie's cafe 01:00 go to bed
Take my mom to dim sum restaurant (all-you-can-eat style). The first of "eating too much". In the afternoon, we went to see my grandma, unexpectedly ran into the rest of the family so we all went out for another big meal. That's "eating too much #2". On the evening, we have party with Group G. friends. Though we were quite full, we manage to thrown down few pieces of cake. This has been the worst day since the Morning Banana. (Yup, worse than yesterday.)
18 April 2010, Sun
morning weight: 83.2 kg (Arrgggg...)
09:00 BF: 2 Oranges + Water 13:00 Lunch: ข้าวต้ม ไข่เจียว + บร็อคโคลี่ผัดเต้าหู้ + ผักดอง + 0 cal Jelly 18:00 Dinner: Sausage Steak + Ham Steak @ ถ. เจริญกรุง 02:00 go to bed
Ran out of banana, using orange instead. Also tried to eat less, but failed.
19 April 2010, Sun
morning weight: 83.9 kg ( [censored] )
08:00 BF: 2 Bananas + water 13:00 Lunch: Tuna Salad 300g 16:00 Snack: Pineapple filled cake from Korea 18:00 Dinner: ข้าวหมูทอด 00:00 go to bed
I hate holidays. Trying to sleep early. Let's see what tomorrow will be.
- Log in to post comments
Diet Diary #34 -- #37
12 April 2010, Mon
morning weight: 83.0 kg (Supper is not good)
08:00 BF: 2 Bananas + water 12:30 Lunch: McDonald @ Lotus Rama 3 17:00 Snack: One stick of หมูปิ้ง 18:00 Dinner: Two bottles of Green Tea 01:00 go to bed
Today, Badminton gang were unavailable. So, one more week without exercise.
13 April 2010, Tue
morning weight: 82.5 kg (...)
08:00 BF: 2 Bananas + water 12:30 Lunch: ข้าวมันไก่ 18:00 Dinner: HANAYA Restaurant, BIG MEAL 01:00 go to bed
Went to see Small Puppet at Aksra Theater. Don't really
14 April 2010, Wed
morning weight: 82.4 kg (...)
09:00 BF: 2 Bananas + water 12:00 Lunch: Tuna Salad 19:30 Dinner: Lucky Seafood, BIG MEAL 01:00 go to bed
Went to visit grandma, she made ก๋วยจั๊บ and then, for dinner, we all went to my home and Lucky Seafood.
15 April 2010, Thu
morning weight: 82.8 kg (Big meal always hurts)
09:00 BF: 2 Bananas + water 12:30 Lunch: ข้าวพะแนงไก่ไข่ดาว 18:30 Dinner: Spaghetti Tom Yam Tuna 01:00 go to bed
I made Spaghetti today.
- Log in to post comments
Diet Diary #29 -- #33
7 April 2010, Wed
morning weight: 83.6 kg (...)
08:00 BF: 2 Banana + water 12:00 Lunch: Tuna Salad 15:00 Snack: ทองม้วน + ขนมถั่ว 19:30 Dinner: can't remember 01:00 go to bed
Today, Badminton gang were unavailable. So, one more week without exercise.
8 April 2010, Thu
morning weight: 83.3 kg (Phew...)
09:00 BF : 2 Banana + water 12:00 Lunch : Tuna Salad 20:30 Dinner: เกี้ยวจีน Big Meal! 01:00 go to bed
ป๋วยเล้ง....
9 April 2010, Fri
morning weight: 83.1 kg (Huh?)
09:00 BF : 2 Banana + water 12:30 Lunch : ข้าวหน้าไก่ 19:30 Dinner: Bar-B-Q Plaza @ The Mall Tha Pra 01:00 go to bed
10 April 2010, Sat
morning weight: 83.7 kg (Good!)
10:00 BF : 2 Banana + water 14:00 Lunch : Dim Sum + Salmon Teriyaki + Milk Bread 19:30 Dinner: A&W @ The Mall Tha Pra 01:00 go to bed
Today, Red Shirt clashed with police & army. All public bus were scheduled to stop operating around 21:00 and The Mall announced that the department store will close at 20:15. We stuck in The Mall until 21:00.
11 April 2010, Sun
morning weight: 82.6 kg (Hehe)
09:00 BF : 2 Banana + water 13:00 Lunch : Tonkatsu + Miso 19:30 Dinner: ข้าว + กุ้งอบวุ้นเส้น 21:00 supper: มันต้ม 00:30 go to bed
- Log in to post comments