Tutorials Point, Simply Easy Learning
Javascript Tutorial
Tutorialspoint.com
Javascript is a scripting language produced by Netscape for use within HTML Web
pages.
JavaScript is loosely based on Java and it is built into all the major modern browsers.
Thi
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 4 STL Vector, List ADT
(Week starting 14 September 2015)
1. vector<T>
One simple idea to compress a string of characters is to group adjacent identical characters into a unit. We
can then specify each uni
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 3 Templates, Strings, ADT
(Week starting 7 September 2015)
1. Templates
Examine the following classes and their relationships:
class Animal cfw_ . ;
class Flyer : public Animal cfw_ . ;
class Glider : pub
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 6 Stacks and Queues
(Week starting 5 October 2015)
1. Stack and Queue Operations
In this exercise, we will use the STL Container adapter classes stack<T> and queue<T> to create stack and
queue instances,
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 8 Complexity Analysis
(Week starting 19 October 2015)
1. Big-Oh Analysis
Remember, Big-Oh time complexity gives us an idea of the growth rate of a function. In other words, for a
large input size N, as N
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 9 Sorting
(Week starting 26 October 2015)
1. Improvement of Bubble Sort
Remember the improved bubble sort in lectures?
void bubbleSort(int arr[], int size) cfw_
for (int skips = 1; skips < size; skips+) c
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 4 STL Vector, List ADT
(Week starting 14 September 2015)
1. vector<T>
One simple idea to compress a string of characters is to group adjacent identical characters into a unit. We
can then specify each uni
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 3 Templates, Strings, ADT
(Week starting 7 September 2015)
1. Templates
Examine the following classes and their relationships:
class Animal cfw_ . ;
class Flyer : public Animal cfw_ . ;
class Glider : pub
CS1010E Programming Methodology
Semester 1 2016/2017
Week of 29 August 2 September 2016
Tutorial 2
Control Structures Selection
1. The following program fragment determines the maximum of three possibly duplicating
integers.
if (a
max
if (b
max
if (c
ma
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 11 Hashing
(Week starting 9 November 2015)
1. Simulation
In this question we will simulate the operations insert(key) and erase(key) on a std:unordered_set,
denoted by the shorthand I(k) and D(k) respecti
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 2 Advanced OO
(Week starting 31 August 2015)
1. Advanced OO
New McDonald has a farm with some animals.
Each animal has a name, and makes a sound. Some animals are flyers. These animals can fly once they
s
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 10 Sorting
(Week starting 2 November 2015)
1. Divide and Conquer!
Explore the differences between Quick Sort and Merge Sort. While there are a number of different
implementations available, use the versio
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 8 Complexity Analysis
(Week starting 19 October 2015)
1. Big-Oh Analysis
Remember, Big-Oh time complexity gives us an idea of the growth rate of a function. In other words, for a
large input size N, as N
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 7 Recursion
(Week starting 12 October 2015)
1. Simple Recursion GCD
The greatest common divisor (GCD) of two positive integers is the largest positive integer that divides the
numbers without a remainder.
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 5 list<T>:iterator, Linked List
(Week starting 28 September 2015)
1. list<T>:iterator
You are given a very long piece of text in a linked list, an STL list<char>. You are to use list iterator(s) to
replac
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 6 Stacks and Queues
(Week starting 5 October 2015)
1. Stack and Queue Operations
In this exercise, we will use the STL Container adapter classes stack<T> and queue<T> to create stack and
queue instances,
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 11 Hashing
(Week starting 9 November 2015)
1. Simulation
In this question we will simulate the operations insert(key) and erase(key) on a std:unordered_set,
denoted by the shorthand I(k) and D(k) respecti
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 1 Basic C+, OOP Problem Solving
(Week starting 24 August 2013) (Q3 Code Censored)
1. Evaluation Order
Examine the code snippet. What is the output, and why?
Tip: Check your answer. Create a program in vim
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 7 Recursion
(Week starting 12 October 2015)
1. Simple Recursion GCD
The greatest common divisor (GCD) of two positive integers is the largest positive integer that divides the
numbers without a remainder.
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 5 list<T>:iterator, Linked List
(Week starting 28 September 2015)
1. list<T>:iterator
You are given a very long piece of text in a linked list, an STL list<char>. You are to use list iterator(s) to
replac
CS1010E Programming Methodology
Semester 1 2016/2017
Week of 5 September 9 September 2016
Tutorial 3
Control Structures Selection and Repetition
1. Given the following program fragment.
int i=1;
while (i > 0) cfw_
i = i + 1;
printf("0\n", i);
(a) What do
C Functions
CS1010E Lecture 6
C function is used to define
Functions as Procedures
In general, a C function allows
Henry Chia (hchia@comp.nus.edu.sg)
Semester 1 2016 / 2017
value-returning function
procedure
multiple arguments or no arguments
one return v
CS1010E Programming Methodology
Semester 1 2016/2017
Week of 22 August 26 August 2016
Tutorial 1 Suggested Answers
Basics of C Programming with Numerical Computations
1. The EditCompileRun cycle in program development is second nature to all programmers.
CS1010E Programming Methodology
Semester 1 2016/2017
Week of 26 30 September 2016
Tutorial 5
Value-Returning Functions
1. In tutorial #1, we performed a trace of a program containing only the main function.
Extend your mental model to include traces of pr
CS1010E Programming Methodology
Semester 1 2016/2017
Week of 29 August 2 September 2016
Tutorial 2 Suggested Answers
Control Structures Selection
1. The following program fragment determines the maximum of three possibly duplicating
integers.
if (a
max
i
CS1010E Lecture 3
Control Structures: Repetition
Henry Chia (hchia@comp.nus.edu.sg)
Semester 1 2016 / 2017
1 / 24
Lecture Outline
Repetition control structure
Multiple user input
Repetition statements
Types of loops
do.while
while
for
Flag-controlled
Resu
Designing Solutions for Large Problems
CS1010E Lecture 7
Functional Abstraction and Recursion
Break down large problem into smaller/simpler sub-problems
Define functions/procedures to handle each sub-problem
Functional abstraction
Henry Chia (hchia@comp.n
Math Functions
CS1010E Lecture 5
Value-Returning Functions
Henry Chia (hchia@comp.nus.edu.sg)
Given the lengths of two sides of a triangle b and c, and the
angle between them , compute a
Semester 1 2016 / 2017
a2 = b2 + c2 2bc cos
or
a=
p
b2 + c2 2bc cos
CS1010E Programming Methodology
Semester 1 2016/2017
Week of 5 September 9 September 2016
Tutorial 3 Suggested Answers
Control Structures Selection and Repetition
1. Given the following program fragment.
int i=1;
while (i > 0) cfw_
i = i + 1;
printf("0\n
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 9 Sorting
(Week starting 26 October 2015)
1. Improvement of Bubble Sort
Remember the improved bubble sort in lectures?
void bubbleSort(int arr[], int size) cfw_
for (int skips = 1; skips < size; skips+) c
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 2 Advanced OO
(Week starting 31 August 2015)
1. Advanced OO
New McDonald has a farm with some animals.
Each animal has a name, and makes a sound. Some animals are flyers. These animals can fly once they
s
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 10 Sorting
(Week starting 2 November 2015)
1. Divide and Conquer!
Explore the differences between Quick Sort and Merge Sort. While there are a number of different
implementations available, use the versio
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 1 Basic C+, OOP Problem Solving
(Week starting 24 August 2013)
1. Evaluation Order
Examine the code snippet. What is the output, and why?
Tip: Check your answer. Create a program in vim, paste main method
CS1020E: DATA STRUCTURES AND ALGORITHMS I
Tutorial 1 Basic C+, OOP Problem Solving
(Week starting 24 August 2013)
1. Evaluation Order
Examine the code snippet. What is the output, and why?
Tip: Check your answer. Create a program in vim, paste main method