Presentation is loading. Please wait.

Presentation is loading. Please wait.

Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO.

Similar presentations


Presentation on theme: "Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO."— Presentation transcript:

1 Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

2 Quick Summary 2 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

3 Question 1: Tracing Arrays 3 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

4 Question 1: Tracing Arrays 4 List11122334455 List299 num11 passElement(int num) num1234 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

5 Question 1: Tracing Arrays 5 List11122334455 List299 changeElements(int list[]) 77 88 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

6 Question 1: Tracing Arrays 6 List11122334455 List299 779988 copyArray(list2, list1, 5) 1122334455 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

7 Question 2: Sieve Prime Numbers 7 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

8 Question 2: Sieve Prime Numbers 8 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

9 Question 2: Sieve Prime Numbers 9 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO Find the next Prime Number Use for loop to eliminate all the multiples of the prime number

10 Question 2: Sieve Prime Numbers 10 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

11 Question 3: Pascal Triangle 11 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

12 Question 3: Pascal Triangle 12 Element: Up Element: UpLeft CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

13 Question 3: Pascal Triangle 13 Question: is it possible to fill up the triangle without considering the border values? Yes, we could initialize all the elements in the Pascal Triangle (2D Array) to 1 first. And our index starts from 1 instead of 0. CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

14 Question 3: Pascal Triangle 14 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO

15 Question 3: Pascal Triangle 15 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO


Download ppt "Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO."

Similar presentations


Ads by Google