COMP 2012H - Spring 2014

Spring 2014, COMP 2012H Object-Oriented Programming and Data Structures (Honors Study Track) [4 credits]
Lecture L1-LEC(1844), TuTh 16:30-17:50, Rm 5506 (L25-26)
Prof. Dekai WU, Rm 3539, 2358-6989,

Lab LA1-LAB(1845) TA: Karteek ADDANKI, Th 11:30-13:20, Rm 4214 (L19),

You are welcome to knock on the door of the instructor any time. The TAs' office hours are posted at


Welcome to COMP2012H! On Tues 14 Feb, in Week 2, there will be a makeup lecture. Other labs will begin Tues 21 Feb, in Week 3.

Always check the Discussion Forum for up-to-the-minute announcements.

Discussion forum is at Always read before asking/posting/emailing your question.
Course home page is at
Lab info is at


Welcome to the honors track COMP 2012H. This course is designed to give you the solid software engineering experience necessary to build, extend, and maintain a realistically sized non-toy program, using both traditional and up-to-date techniques that you will need on the job. Most students find that C++ and other modern languages offer a huge, confusing variety of different and often-contradictory complexities. In this sequence you will untangle the confusion by gaining an enhanced holistic theoretical perspective, comparing and contrasting the most important paradigms of programming languages.

Understand by doing. The only way to learn languages is through serious practice. The only way to appreciate software engineering is to engineer some serious software. And by far the best way to understand programming languages is to implement one.

So, through an integrated series of programming assignments, you will use C++ to gradually implement your own complete interpreter for a real programming language that is a small but fully operational version of Scheme (or Lisp).

You will learn the most important procedural, static and dynamic object-oriented, and generic programming paradigms of C++ programming, through hands-on practice with building the basic pieces of your Scheme interpreter. The Scheme programming project will help deepen the C++ concepts you have learned, by giving you a better understanding of the functional and generic programming roots and foundations that underlie the design and effective use of STL in the C++ Standard Library. If we progress sufficiently rapidly, then we will also learn about the syntactic description and analysis of programming languages, and their runtime environments. Throughout the entire series, you will focus on developing adequate software engineering habits, so that you can continue to build, extend, and maintain the code you have built so far.

Academic Calendar Description

[Previous Course Code(s): COMP 152H] To learn data structures in an object-oriented programming language. Abstract data types such as: sequences, maps/dictionaries, stacks, priority queues. Class hierarchies and inheritance; polymorphism; early and late binding; static and dynamic object-oriented programming; generic programming, templates, and algorithm abstraction. Data structures such as: linked lists, trees, heaps, tries, graphs, hash tables. Sorting and search algorithms: asymptotic notations, complexity analysis, and lower bound. Enrollment in the course requires approval of the course instructor. Exclusion(s): COMP 151 (prior to 2009-10), COMP 151H (prior to 2009-10), COMP 171 (prior to 2009-10), COMP 171H (prior to 2009-10), COMP 2012 Prerequisite(s): COMP 1003 OR COMP 1004 OR COMP 2011 OR COMP 104H (prior to 2009-10)


Reference Books


To receive a passing grade, you are required to sign an honor statement acknowledging that you understand and will uphold all policies on plagiarism and collaboration.


All materials submitted for grading must be your own work. You are advised against being involved in any form of copying (either copying other people's work or allowing others to copy yours). If you are found to be involved in an incident of plagiarism, you will receive a failing grade for the course and the incident will be reported for appropriate disciplinary actions.

University policy requires that students who cheat more than once be expelled. Please review the cheating topic from your UST Student Orientation.

Warning: sophisticated plagiarism detection systems are in operation!


You are encouraged to collaborate in study groups. However, you must write up solutions on your own. You must also acknowledge your collaborators in the write-up for each problem, whether or not they are classmates. Other cases will be dealt with as plagiarism.


The course will be graded on a curve, but no matter what the curve is, I guarantee you the following.

If you achieve 85% you will receive at least a A grade.
75% B
65% C
55% D

Your grade will be determined by a combination of factors:

Midterm exam ~20%
Final exam ~25%
Participation ~5%
Homework ~40%
Labs ~10%


No reading material is allowed during the examinations. No make-ups will be given unless prior approval is granted by the instructor, or you are in unfavorable medical condition with physician's documentation on the day of the examination. In addition, being absent at the final examination results in automatic failure of the course according to university regulations, unless prior approval is obtained from the department head.

There will be one midterm worth approximately 20%, and one final exam worth approximately 25%.


Software engineering is about communication between people. Good participation in class and/or the online forum will count for approximately 5%.


All programming assignments must be submitted by 23:00 on the due date. C++ programming assignments must be compiled using g++ on Unix and will be collected electronically using the automated CASS assignment collection system. Late assignments cannot be accepted. Sorry, in the interest of fairness, exceptions cannot be made.

Programming assignments will account for a total of approximately 40%.


All information for laboratory/tutorial assignments is at

Laboratory/tutorial assignments will be due Monday of the week after they are announced at 23:00. Laboratory/tutorial assignments must be in C++ on Unix and will be collected electronically using the automated CASS assignment collection system. Late assignments cannot be accepted. Sorry, in the interest of fairness, exceptions cannot be made.

You will also have the option to turn in your laboratory/tutorial assignments in lab by demonstrating to the TA. This will also give you an opportunity to get an early indication of whether your assignment is correct. If not, you may still decide to fix it, and then wait until the Monday 23:00 CASS collection to turn in your assignment.

There will be up to 10 laboratory/tutorial assignments, which in total will count for approximately 10%.


Date Wk Event Paradigm Topic Notes Reading Assignments
2014.02.11 2 Lecture Administrivia (honor statement, HKUST classroom conduct), Self-review (References, Const) Business Week, New York Times, Bjarne Stroustrup on Educating Software Developers, The Perils of JavaSchools, V1.Ch3,
2014.02.13 2 Lecture SwEngr Introduction: C++ and software engineering [makeup, 12:00-23:20, Rm 4214] (doxygen notes: Marine's, Adam's) V1.Ch1
2014.02.13 2 Lecture SwEngr Introduction: Data abstraction (YourPets2a.cpp, YourPets2b.cpp) V1.Ch2, V1.Ch4
2014.02.13 2 Lecture Functional Project (Assignment 1): Encapsulation, s-expressions, cons lists, tagged unions, eval [makeup, 19:00-20:20, Rm 5583]
2014.02.18 3 Lecture Procedural Forum; Declaration and definition (reverse_print.cpp, use_reverse_print.cpp, reverse_print.hpp) V1.Ch5
2014.02.20 3 Lecture Procedural Declaration and definition, cont'd [extra lecture, 12:00-13:20, Rm 4214]
2014.02.20 3 Lecture StaticOO Overloading and constructors; Assignment 1 V1.Ch6
2014.02.25 4 Lecture StaticOO Destructors, Order of construction/destruction, Post Office example, argc & argv V1.Ch6
2014.02.26 4 A1 due
2014.02.27 4 Lecture Functional Project (Assignment 2): Polymorphic reimplementation, exposing car/cdr/cons/nullp
2014.03.04 5 Lecture StaticOO Inheritance: Introduction V1.Ch14
2014.03.06 5 Lecture StaticOO Inheritance: Substitution principle; Inheritance: Access control: public, protected, private; Inheritance: Public, private, protected inheritance [extra lecture, 12:00-13:20, Rm 4214] V1.Ch14
2014.03.06 5 Lecture DynamicOO Inheritance: Virtual functions; Inheritance: Abstract base classes, ex1, ex2, ex3, ex4 V1.Ch15
2014.03.11 6 Lecture DynamicOO Inheritance: Overriding vs overloading V1.Ch15
2014.03.11 6 Lecture StaticOO The "this" pointer V1.Ch4
2014.03.13 6 [rescheduled to 2014.02.20]
2014.03.18 7 Lecture Functional More on Project (Assignment 2): Polymorphic reimplementation, exposing car/cdr/cons/nullp
2014.03.19 7 A2 due
2014.03.20 7 Lecture Generic Introduction to generic programming; Function and class templates [extra lecture, 12:00-13:20, Rm 4214] V1.Ch16
2014.03.20 7 Lecture Functional Project (Assignment 3): Exceptions, boolean operators, exposing eval & print V2.Ch1
2014.03.25 8 Lecture SwEngr Exceptions V2.Ch1
2014.03.25 8 Lecture Generic Overloading operators V1.Ch12
2008.03.27 8 Lecture Generic Container classes [extra lecture, 12:00-13:20, Rm 4214] V2.Ch7
2008.03.27 8 Lecture Generic STL: Sequences & Iterators V2.Ch6
2014.03.31 9 A3 due
2014.04.01 9 Exam Midterm (sample exam for your practice)
2014.04.03 9 Lecture Generic STL: Introduction to algorithms; STL: Function pointers V2.Ch6, ref V1.Ch3
2014.04.08 10 Lecture Functional Project (Assignment 4): lambda, apply, bootstrapping, Turing equivalence
2014.04.10 10 Lecture Generic STL: Function objects or functors; STL: More algorithms V2.Ch6
2014.04.15 11 A4 due
2014.04.17 11 Holiday Mid-Term Break
2014.04.22 11 Lecture Dictionaries Trees: binary trees
2014.04.24 11 Lecture Functional Project (Lab Assignment): more bootstrapping: list-tail, list-ref, reverse, equal?, assoc [extra lecture, 11:30-13:20, Rm 4214]
2014.04.24 11 Lecture Dictionaries Trees: binary search trees; Project (Assignment 5): binary search trees, STL map interface
2014.04.29 12 Lecture Dictionaries Hashing
2014.05.01 12 Holiday Labor Day
2014.05.06 13 Holiday The Birthday of the Buddha A5 due
2014.05.08 13 Lecture Functional Project (Lab Assignment): quicksort: list-partition, list-sort [extra lecture, 11:30-13:20, Rm 4214]
2014.05.08 13 Lecture Algorithms Sorting: insertion sort, mergesort, quicksort, heapsort; More on sorting
2014.05.17 14 Exam Final (Rm 2463 12:30-15:30) sample final exam plus a sample midterm and another sample midterm for your practice)
Last updated: 2014.05.08