This course introduces students to the design and implementation of fundamental data structures and algorithms. The course covers basic data structures (linked lists, stacks, queues, binary heaps, hash tables, trees, and graphs), searching and sorting algorithms, and basic analysis of algorithms.
The programming language used for this course is Java.
We use very basic object-oriented programming concepts in various data structures implementations, e.g., Stack class inherits LinkedList class (more details of OOP are in CS2030).
Note: This introductory message will not be prominent the next time you visit this URL again. This behavior is normal. You can view it again by scrolling to the top of this page.
For AY 2026/27, Prof Halim only teaches CS2040S (CS students) in S1.
his return to CS2040C (CEG, InfoSecurity, exchange students) in S2 AY 2025/26 last semester ends up just one-off as he will run both CS3230 S1 AND S2 of AY 2026/27.
As of Wed, 06 May 2026, the max class size for S1 AY 2026/27 is configured at 240.
Prof Halim will now no longer be surprised if the enrollment for S1 AY 2026/27 is ≥ 200, i.e., between [206 (last S1 AY 2025/26 size)..240].
He is now looking for 12 best of the best part-time TA applications (contact Prof Halim as early as possible).
Generally: the higher your past teaching feedback rating (for senior TAs), your CS2040/C/S grade (for new TAs), the higher your LeetCode rating/number of solves, the higher your chance to be TA of this course.
Some facts:
| Rating (out of 5.0) |
Aug-Nov 26 (n=1??/2??) ≥50% |
Aug-Nov 25 (n=163/206) 79% ▼ |
Aug-Nov 24 (n=128/161) 80% ▲ |
Aug-Nov 23 (n=90/128) 70% |
|---|---|---|---|---|
| Course feedback (SoC CS avg lvl 2000 ~3.9) | [4.2..4.4] (tgt) | 4.4 (PB) ▲ | 4.2 == | 4.2 |
| Course difficulty (SoC CS avg lvl 2000 ~4.1) | [3.9..4.1] (tgt) | 4.0 (PB) ▼ | 4.2 ▼ | 4.3 |
| Prof Halim's teaching (SoC CS avg lvl 2000 ~4.2) | [4.5..4.7] (tgt) | 4.6 (PB) ▲ | 4.5 ▲ | 4.4 |
TAs:
| Date, Time | Live Session (Venue) (#Stu/#Cap) | No | TA |
|---|---|---|---|
| 1/Mon, 1000-1200 | TBA (PLX) (??/20) | 01 | @TBA |
| 1/Mon, 1000-1200 | TBA (PLX) (??/20) | 02 | @TBA |
| 1/Mon, 1000-1200 | TBA (PLX) (??/20) | 09 - TBA | @TBA |
| 1/Mon, 1200-1400 | TBA (PLX) (??/20) | 03 | @TBA |
| 1/Mon, 1200-1400 | TBA (PLX) (??/20) | 04 | @TBA |
| 1/Mon, 1200-1400 | TBA (PLX) (??/20) | 10 - TBA | @TBA |
| 1/Mon, 1400-1600 | TBA (PLX) (??/20) | 05 | @TBA |
| 1/Mon, 1400-1600 | TBA (PLX) (??/20) | 06 | @TBA |
| 1/Mon, 1400-1600 | TBA (PLX) (??/20) | 11 - TBA | @TBA |
| 1/Mon, 1600-1800 | TBA (PLX) (??/20) | 07 | @TBA |
| 1/Mon, 1600-1800 | TBA (PLX) (??/20) | 08 | @TBA |
| 1/Mon, 1600-1800 | TBA (PLX) (??/20) | 12 - TBA | @TBA |
List of TAs (ordered using Lab Group Number):
Part-time TAs applications:
Any other applicant(s) who put CS2040S in the TMTF system but without informing Prof Halim will not be considered.
This is what students learn in CS2040/C/S as taught by Prof Halim, compare it with the subset IT5003 version:
If you have any important questions regarding this course, email dcssh at nus edu sg. Relevant answers will be posted here to reach wider audiences.
Note: This course registration section will not be prominent from Week 1 onwards. This behavior is normal. You can view it again by scrolling to the top of this page.
| Date | News |
|---|
The 4 units CS2040/C/S syllabus will be delivered over 13 weeks.
This course is a superset of the content of a similar IT5003 course, approximately 39/24 ~= 63% more content than IT5003.
The weekly lesson plan of Week X is typically as follows (2+(1+1)+(2+1)+3 = 10 hours/week):
Then, repeat this throughout the semester :).
The S1 AY 2026/27 timetable below is still tentative, especially those that are highlighted with pink color. The Wed morning of CS2040S will be as close as possible with Wed evening of IT5003.
| Week | Tutorial+Lab Combo | Lecture | Interesting Problem Set |
|---|---|---|---|
| Cells with course material that have not been updated are highlighted with pink color, past classes more than one week ago are hidden so that we can focus on the current and future classes, but you can restore them by clicking 'Show Past' button above, future classes are not highlighted | |||
|
-01, 27-31 Jul |
Has Not Started |
Has Not Started, but please revise your CS1101S/CS1010/equivalent Prof Halim assumes that all of you have taken or exempted from this course/its variants Register at Kattis and LeetCode (use full name as in Matric card), read Java specific instructions @ Kattis, pick up basic Java by yourself, and solve the selected Online Judge (OJ) Problem Set 0 (PS0) by yourself (CS1101S/CS1010/equivalent level) and LeetCode OJ programming-skills study plan (solving many 'trivial problems' from this set ---the Kattis one is trackable by Prof Halim, indirectly tells him about your CS1101S/CS1010/equivalent rough grade) There should be a CS2040 placement test for AY26/27 incoming IOI medallists Details TBA |
PS0: Easy Coding Challenges (01-12 Aug) Already graded to speed up registration admins Solve any 3 out of 10 trivial tasks for 1% |
|
00, 03-07 Aug |
Has Not Started Essential LeetCode exercises from programming-skills 1: Mon: plus-one (simulate +1 on a 'big' integer), Tue: to-lower-case (simple string processing), Wed: average-salary-excluding-the-minimum-and-maximum-salary (use library), Thu: matrix-diagonal-sum (2D grid processing, still with one loop), Fri: find-the-highest-altitude (simple one pass), Sat: move-zeroes (use two pointers). |
Has Not Started Continue attempting Kattis PS0 and LeetCode programming-skills study plan (hints in class Discord) |
PS0, continued Remember, solve any 3 for 1% |
|
01, 10-14 Aug |
Has Not Started Essential LeetCode exercises from programming-skills 2: Mon: find-winner-on-a-tic-tac-toe-game (small (3x3) 2D grid processing), Tue: spiral-matrix (interesting 2D grid traversal variant), Wed: count-odd-numbers-in-an-interval-range (PIE), Thu: product-of-array-except-self (prefix/suffix products), Fri: robot-return-to-origin ((virtual) 2D grid traversal with one loop), Sat: robot-bounded-in-circle (a bit harder than robot-return-to-origin). |
Singapore National Day on Sun, 09 August 2026 The following Mon, 10 August 2026 is a Public Holiday but this class is not affected with that PH but of something else Prof Halim is away to IOI 2026, Tashkent, Uzbekistan The first class is a recording... 01a. Course Admin, (Re-)Introduction to Java 1. Setting the tone for a flipped classroom course VisuAlgo + this Private Canvas + Kattis (NUS) + LeetCode 2. Basic Java review/new feature introduction 3. Kattis/LeetCode problem(s) discussed today: A few PS0 and/or programming-skills problems (just for warm-up) In the middle of 01a: VisuAlgo Online Quiz 0 (0%) There was 1 trivial question during the first lecture Bring your own laptop This one is put here to speed-up admins (don't skip the first lecture) Reminder: Read simple algorithms on unsorted array (Slide 1 to 6-1) before the next lecture 01b. Algorithms on Unsorted Array Kattis/LeetCode problem(s) discussed today: rankproblem (a List ADT task; Java ArrayList operations: add (2 versions), indexOf, remove; and using Java class) Reminder: Read sorting intro, algorithm analysis, and O(N^2) sorting algorithms (Slide 1 to 9-3) before the next lecture |
PS0 (1%) Due: Wed, 12 Aug 26, 11.29am PS1: Basic Programming Out: Wed, 13 Aug 25, 11.30am Mentioned at the end of the first lecture CS2040S students do problem B+C problem A is optional (extra (easy) practice) |
|
02, 17-21 Aug |
Has Not Started Essential LeetCode exercises involving (simple) problems with two (or more) solutions: Mon: monotonic-array (a monotonic array is a sorted array), Tue: Wed: Thu: shortest-unsorted-continuous-subarray (O(n log n) vs O(n) solutions), Fri: kids-with-the-greatest-number-of-candies (avoid accidental O(n^2)), Sat: largest-perimeter-triangle |
02a. Analysis of Algorithms (Slide 1 to 9-3) 1. Live SpeedTest.cpp | py | java demo (measure runtime, count # of operations, vs asymptotic analysis) 2. Fast review of O(N^2) sorting algorithms 3. Kattis/LeetCode problem(s) discussed today: thanos (analysis: exponential growth, logarithmic steps) mjehuric (bubble sort simulation) height (insertion sort simulation) nothanks (sorting library and linear pass) 02b. Algorithms on Sorted Array Kattis/LeetCode problem(s) discussed today: classfieldtrip (merge of mergesort; or any other solution that works) shortest-unsorted-continuous-subarray Last flipped classroom reminder: Read all sorting e-Lecture slides before next lecture |
PS1 (2%) Due: Sat, 22 Aug 26, 07.59am PS2: Sorting-related Problems Out: Sat, 22 Aug 26, 08.00am |
|
03, 24-28 Aug |
T01+L01: tut01.pdf Introduction, OOP review (List ADT, ListArrayTest.py | java) Algorithm Analysis, Hands-on, a basic List ADT task, PS1 Debrief (short), PS2 Discussion (algorithmic) Essential LeetCode exercises involving sorting: Mon: squares-of-a-sorted-array (CS2040S final S1 AY25/26, B.2), Tue: merge-strings-alternately (variant of merge of Merge sort), Wed: sort-colors (Dutch National Flag problem), Thu: verifying-an-alien-dictionary (CS2040C midterm S2 AY25/26, B.1), Fri: separate-black-and-white-balls (IT5003 midterm S2 AY25/26, B.1), Sat: find-pivot-index |
03a. Sorting (Slide 10 to 13-2) 1. O(N log N) Merge Sort (C++ stable_sort; Java Collections.sort; Python list.sort) 2. Exp O(N log N) (Rand) Quick Sort (C++ sort; Java Arrays.sort (primitives); N/A in Python) Sorting Online Quiz (easy) White-box: SortingDemo.cpp | py | java Black-box: Java Collections.sort, Arrays.sort (object), Arrays.sort (primitives) 3. Kattis/LeetCode problem(s) discussed today: sortofsorting (custom comparator, stable sorting library) merge-strings-alternately sort-colors 03b. Sorting Extras (until end) A preview of Ω(N log N) lower-bound of comparison-based sorting algorithms Special-purpose O(N) sorting algorithm: Counting Sort (Only) Other topics of sorting, e.g., counting inversions, counting minimum swaps LeetCode problem(s) discussed today: verifying-an-alien-dictionary |
PS2, continued |
|
04, 31 Aug-04 Sep |
T02+L02: tut02.pdf Sorting Application(s), Sorting, mini experiment, QuickSelect, ADT/List ADT, VA OQ demo (sorting), Hands-on, sorting applications, PS2 Discussion (algorithmic) Essential LeetCode exercises involving list: Mon: can-make-arithmetic-progression-from-sequence (sort first), Tue: design-linked-list (try adapting SLLDemo (Lec03a) to solve this), Wed: delete-the-middle-node-of-a-linked-list (two passes versus two pointers), Thu: removing-stars-from-a-string (bracket matching variant), Fri: maximum-twin-sum-of-a-linked-list (in SLL, we can only go forward?), Sat: odd-even-linked-list |
04a. List ADT: SLL/Stack/Queue/DLL/Deque (all slides) 1. Introducing List ADT, (resizeable) array versus Singly Linked List (SLL) way 2. Introducing Stack/Queue/Deque (DLL) ADT Linked List Online Quiz (easy) White-box: SLLDemo.cpp | py | java implementation Black-box: Stack, but using Java ArrayList implementation versus Java LinkedList and Stack classes Fixed-size array, circular array version, versus Java Queue and Deque interfaces 3. Kattis/LeetCode problem(s) discussed today: design-linked-list (try adapting SLLDemo (Lec03a) to solve this) 04b. List Extras Kattis/LeetCode problem(s) discussed today: delete-the-middle-node-of-a-linked-list (two passes versus two pointers) removing-stars-from-a-string (bracket matching variant) |
PS2 (2%) Due: Sat, 05 Sep 26, 07.59am PS3: List+PQ Problems Out: Sat, 05 Sep 26, 08.00am |
|
05, 07-11 Sep |
T03+L03: tut03.pdf Linked List, mini experiment, Applications: Reversing/Sorting a List, Application: Stack-related, PS2 Debrief (short), Java LinkedList/Stack/Queue/Deque, VA OQ demo (list), Hands-on, a list application, PS3 Discussion (algorithmic) Essential LeetCode exercises involving PQ: Mon: add-two-numbers-ii (use two stacks; do LSB to MSB), Tue: reverse-linked-list (there are several ways to do this), Wed: kth-largest-element-in-an-array (O(n log k) version), Thu: smallest-number-in-infinite-set (min PQ simulation; with lazy deletion), Fri: remove-stones-to-minimize-the-total (max PQ simulation), Sat: top-k-frequent-elements |
05a. Priority Queue (PQ) ADT: Binary Heap (Slide 1 to 8-2) 1. Introducing PQ ADT 2. Introducing basic Binary Heap structure and its Insert+ExtractMax operations 3. Discussing CreateHeap (two versions) and HeapSort operations Binary Heap Online Quiz (easy) White-box: BinaryHeapDemo.cpp | py | java Black-box: priority_queue.cpp | py | java Kattis/LeetCode problem(s) discussed today: kth-largest-element-in-an-array Last 15m of 05a: VisuAlgo Online Quiz 1 (4%) Bring your own laptop that can run at least 15 minutes on battery power. (we do not provide any spare laptop). Material: /array (1Q + 2 'new'), /sorting (3 Qs), /list (3 Qs), and 3 'new' questions especially on asymptotics. 05b. PQ Extras (until end) 1. O(N) CreateHeap analysis and O(N+K log N) PartialSort 2. Discussing UpdateKey(i, newv) and Delete(i) operations Kattis/LeetCode problem(s) discussed today: smallest-number-in-infinite-set |
PS3, continued |
|
06, 14-18 Sep |
T04+L04: tut04.pdf Binary Heap, Max-Min conversion, Additional ADT PQ Operations, Java PriorityQueue, VA OQ demo (heap), Hands-on, a problem involving PQ, PS3 last Discussion (algorithmic) Essential LeetCode exercises involving hash table: Mon: total-cost-to-hire-k-workers (min PQ simulation), Tue: design-hashmap (try adapting HashTableDemo (Lec06a) to solve this), Wed: longest-consecutive-sequence (discussed in Lec06a), Thu: group-anagrams (discussed in CS2040S Lec06b), Fri: unique-number-of-occurrences (set application), Sat: |
06a. Table ADT part 1: Hash Table (slide 1 to 10-5) 1. Table ADT, DAT, Basic Hashing; Easiest Collision Resolution (CR): CA (SC) HashTableDemo.cpp | py | java (all use SC) 2. More CR Techniques: OA (LP, QP, DH); Comparing CA: SC with OA: DH Hash Table Online Quiz (easy; a bit too tedious on medium/hard settings) 3. Kattis/LeetCode problem(s) discussed today: design-hashmap (use HashTableDemo) longest-consecutive-sequence (use set to help checks) 06b. Hash Table Extras (until end) Other technicalities of Hash Table Java HashSet/HashMap/Hashtable classes See unordered_map_unordered_set.cpp | py | java at GitHub repo of CPbook website Kattis/LeetCode problem(s) discussed today: group-anagrams (sort and hash) |
PS3 (2%) Due: Sat, 19 Sep 26, 07.59am PS4: Hash Table Problems Out: Sat, 19 Sep 26, 08.00am |
|
Recess Week, 19-27 Sep 2026 You can take a break this week :) |
|||
|
07, 28 Sep-02 Oct |
T05+L05: tut05.pdf [Special] Past midterm paper(s) discussions Essential LeetCode exercises (mix and match; UFDS): Mon: find-k-pairs-with-smallest-sums (discussed in Lab05), Tue: min-stack (CS2040S midterm S1 AY23/24, B), Wed: last-stone-weight (IT5003 Final S2 AY24/25, B.2), Thu: number-of-provinces (simple with UFDS), Fri: redundant-connection (simple with UFDS), Sat: making-a-large-island (hard UFDS LC task). |
Midterm Test (10% → 20%) Venue: TBA ? Date and Time: Wed, 30 Sep 26 (wk7), 10:10-11:30am (80 mins), TBC Open book Details TBC Midterm Test Past Papers (recent 3 AYs only): AY 2023/24: S1-midterm.pdf, [I didn't teach CS2040S in S2], AY 2024/25: S1-midterm.pdf, [I didn't teach CS2040S in S2], AY 2025/26: S1-midterm.pdf, S2-midterm.pdf (CS2040C), AY 2026/27: S1-midterm.pdf (to be our paper), [I don't teach CS2040S in S2]. 07b. Union-Find Disjoint Sets (all slides) 1. Quick Recap with VisuAlgo See unionfind_ds.cpp | py | java at GitHub repo of CPbook website 2. Kattis/LeetCode problem(s) discussed today: number-of-provinces PS: UFDS is reused in Connected Component (CC) and MST topics |
PS4, continued |
|
08, 05-09 Oct |
T06+L06: tut06.pdf Table ADT 1 - unordered, Basic hashing concepts, Hash Table issues, Java HashSet/HashMap, PS3 Debrief (short), Only for CS2040S: UFDS review, VA OQ demo (hashtable,ufds), Hands-on, a hash table application PS4 Discussion (algorithmic) Extra exercises: Mon: determine-if-two-strings-are-close (discussed in Lab06), Tue: search-in-a-binary-search-tree (implement recursive BST search), Wed: delete-node-in-a-bst (implement the three cases of BST deletion), Thu: minimum-absolute-difference-in-bst (use the correct tree traversal), Fri: validate-binary-search-tree (recursive check), Sat: |
08a. Table ADT part 2: BST (Slide 1 to 12-1) 1. BST concepts, BST operations, and the multiset idea BST (only) Online Quiz (medium) BSTDemo.cpp | py | java 2. Randomly built BST and a preview of balanced BST, e.g., AVL Tree 3. Kattis/LeetCode problem(s) discussed today: search-in-a-binary-search-tree delete-node-in-a-bst 08b. Balanced BST and Applications (until end) QnA about AVL Tree concepts A short discussion of Select and Rank operations BST+AVL Online Quiz (hard; need to clear pre-req) AVL.cpp | (no py yet) | java Java TreeSet/TreeMap classes See map_set.cpp | (no built-in py) | java at GitHub repo of CPbook website LeetCode problem(s) discussed today: minimum-absolute-difference-in-bst Fri, 09 Oct 2026 is NUS Well-Being Day This class is not affected |
PS4 (2%) Due: Sat, 10 Oct 26, 07.59am PS5: Combo DS + Graph 1 Out: Sat, 10 Oct 26, 08.00am |
|
09, 12-16 Oct |
T07+L07: tut07.pdf Table ADT 2 - ordered, (balanced) BST advanced stuffs: Select and Rank, PQ ADT alternative implementation, Comparison with Table ADT 1: unordered vs ordered, Java TreeSet/TreeMap, PS4 Debrief (short), VA OQ demo (bst or avl (need to clear pre-req)) Hands-on, a tree-related task, PS5 Discussion (algorithmic) Extra exercises: Mon: construct-binary-tree-from-preorder-and-inorder-traversal (discussed in Lab07), Tue: maximal-network-rank (just degree and edge existence checks), Wed: destination-city (in/out degree checks; use hash table), Thu: keys-and-room (visitation check from 0; showing DFS way), Fri: count-good-nodes-in-binary-tree (modified preorder; precursor of DFS), Sat: minimum-number-of-vertices-to-reach-all-nodes (compute in-degrees). |
09a. Graph DS (all slides) + DFS Traversal (Slide 1 to 5-8) 1. Concept checks: Graph DS Online Quiz (medium), Implementations of graph DS and its applications No built-in C++ STL container | Python standard library | Java API, See graph_ds.cpp | py | java at GitHub repo of CPbook website, 2. Early discussion of the basic forms of Graph Traversal algorithms: DFS first See dfs_cc.cpp | py | java 3. Kattis/LeetCode problem(s) discussed today: destination-city Last 15m of 09a: VisuAlgo Online Quiz 2 (4%) Material: /heap (3 Qs), /hashtable (3 Qs), /ufds (3 Qs), /bst (3 Qs) but NO new question this time... 09b. Graph Traversal Applications (Slide 7-3 to 7-8) Finding Connected Components Kattis/LeetCode problem(s) discussed today: weakvertices (AM demo) keys-and-room |
PS5, continued |
|
10, 19-23 Oct |
T08+L08: tut08.pdf Graph DS Review, Some Graph Properties Discussion, Graph DS Conversion Exercise, DFS/BFS Review, Custom graph DS implementation review, VA OQ demo (graphds,dfsbfs), Hands-on, a Graph-related task, PS5 Discussion (algorithmic) Essential LeetCode exercises (graph 1): Mon: maximum-star-sum-of-a-graph (CS2040S final S1 AY25/26, B.5), Tue: reorder-routes-to-make-all-paths-lead-to-the-city-zero (make undirected to simplify). Wed: number-of-provinces (AM; count #CC; showing BFS way), Thu: course-schedule (using DFS ternary states to detect back edge (cycle)), Fri: binary-tree-right-side-view (BFS on a binary tree: level order traversal), Sat: number-of-islands (flood fill on an implicit grid graph). |
10a. Graph Traversal Applications (Slide 6 to 7-12) 1. Review DFS and introducing BFS 2. Focus on a few more basic DFS/BFS applications (we skip slide 8-11, out of CS2040/C/S and IT5003 scope) DFS/BFS Online Quiz (medium) No built-in C++ STL algorithm | Python standard library | Java API, See UVa00469.cpp | py | java, and bfs.cpp | bfs.py | java at GitHub repo of CPbook website, 3. LeetCode problem(s) discussed today: number-of-provinces 10b. Graph Traversal Extras 1. LeetCode problem(s) discussed today: course-schedule binary-tree-right-side-view NUS Online Teaching Feedback opens this Fri But this timing is too early for our course... You can wait until you have completed the course |
PS5 (2%) Due: Sat, 24 Oct 26, 07.59am PS6: Graph 2 Out: Sat, 24 Oct 26, 08.00am |
|
11, 26-30 Oct |
T09+L09: tut09.pdf DFS/BFS advanced stuffs: Cycle Detection, Toposort++, Floodfill/CC, Bipartite Graph Checker Modeling exercise, PS5 Debrief (short), VA OQ demo (dfsbfs,sssp), Hands-on, an unweighted SSSP task, PS6 Discussion (algorithmic) Essential LeetCode exercises (graph 2): Mon: course-schedule-ii (discussed in Lab09), Tue: rotting-oranges (SSSP; implicit unweighted grid graph; BFS; MSSP), Wed: network-delay-time (basic Dijkstra's), Thu: snakes-and-ladders (SSSP; implicit (with a twist) unweighted grid graph; BFS), Fri: nearest-exit-from-entrance-in-maze (SSSP; implicit unweighted grid graph; BFS), Sat: minimum-genetic-mutation (SSSP; implicit unweighted graph; BFS). |
11a. SSSP Problem (all slides) 1. Review of basic SSSP problem + O(VE) / O(kE) Bellman-Ford algorithm 2. QnA on BFS algorithm for unweighted SSSP QnA on Dijkstra's algorithm (original Dijkstra's first; but focus on modified Dijkstra's for IT5003) See dijkstra.cpp | py | java at GitHub repo of CPbook website Quick discussion of SSSP on Tree and on DAG SSSP Online Quiz (medium) 3. LeetCode problem(s) discussed today: rotting-oranges network-delay-time 11b. SSSP Extras 1. Modified Dijkstra's and other SSSP special cases 2. LeetCode problem(s) discussed today: snakes-and-ladders |
PS6, continued |
|
12, 02-06 Nov |
T10+L10: tut10.pdf BFS/Dijkstra's review Only for CS2040S: MST review, Modeling exercises (continued), VA OQ demo (sssp), Hands-on, an SSSP task, PS6 Discussion (algorithmic) Essential LeetCode exercises (graph 3): Mon: word-ladder (discussed in Lab10) Tue: find-the-city-with-the-smallest-number-of-neighbors-at-a-threshold-distance (IT5003 final S2 AY24/25, B.6) Wed: min-cost-to-connect-all-points (basic MST), Thu: minimum-time-to-visit-disappearing-nodes (SSSP; weighted graph; with a small twist), Fri: minimum-cost-path-with-edge-reversals (IT5003 final S2 AY25/26, A.5), Sat: find-edges-in-shortest-paths (CS2040C final S2 AY25/26, A.6). Tut+Lab participation marks given (5%) |
12a. MST Problem (all slides) 1. Review of basic MST problem 2. QnA on Kruskal's and Prim's algorithms Mix and Match of various data structures/algorithms covered so far 3. LeetCode problem(s) discussed today: min-cost-to-connect-all-points Onsite class photo as momento Last 15m of 12a: VisuAlgo Online Quiz 3 (4%) Material: /graphds (4 Qs), /dfsbfs (3 Qs), /sssp (2 Qs), and 3 'new' questions (inclusive of 2 specifically unweighted SSSP). 12b. MST+another SSSP Extras 1. Other MST Variants 2. LeetCode problem(s) discussed today: minimum-time-to-visit-disappearing-nodes |
PS6 (2%) Due: Sat, 07 Nov 26, 07.59am Optional Final Tracker Out: Sat, 07 Nov 26, 08.00am |
|
13, 09-13 Nov |
As Sun, 08 Nov 2026 is Deepavali PH We cancel the last lab No session on last week, only online exercises Essential LeetCode exercises (past finals 1): Mon: List Review, Tue: ugly-number-ii (Min Priority Queue + Hash Table Review), Wed: map-sum-pairs (Hash Table Review), Thu: flatten-binary-tree-to-linked-list (Skewed Right BST (LL) Review), Fri: Sat: |
13a. No lecture, make-up time window Details TBC 13b. The Last Lecture 1. Course wrap-up and Semester Summary Review of what can be done better for future iterations, 2. Advertisement of future (algorithm) courses: CS3230 (S1 or S2) Advertisement for part-time TA jobs (A-/A/A+ only), 3. Ending: a few Final Assessment Tips. |
Optional, continued |
|
Reading, 14-20 Nov |
Essential LeetCode exercises (past finals 2): Mon: Tue: Wed: Thu: Fri: map-of-highest-peak ((unweighted) SSSP Review) Sat: |
Final Assessment Past Papers (recent 3 AYs only, note the mix of CS2040S/Java and CS2040C/C++): AY 2023/24: S1-final.pdf, [I didn't teach CS2040S in S2], AY 2024/25: S1-final.pdf, [I didn't teach CS2040S in S2], AY 2025/26: S1-final.pdf, S2-final.pdf (CS2040C), AY 2026/27: S1-final.pdf (will be our paper), [I don't teach CS2040S in S2]. NUS Online Teaching Feedback System closes on Friday of Reading Week |
|
|
Final Assessment (50%) Date and Time: ???, ?? Nov? 2026, ?-??m Venue: TBA Open book No electronic device except one calculator Details TBC |
|||