tutorial 5 arrays basics (1d, 2d) nus school of computing cs1010e programming methodology 1 cs1010e...
TRANSCRIPT
![Page 1: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/1.jpg)
1
Tutorial 5 Arrays Basics (1D, 2D)
NUS SCHOOL OF COMPUTING
CS1010E PROGRAMMING METHODOLOGY
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
![Page 2: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/2.jpg)
2
Quick Summary
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
![Page 3: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/3.jpg)
3
Question 1: Tracing Arrays
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
![Page 4: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/4.jpg)
4
Question 1: Tracing Arrays
List1 11 22 33 44 55List2 99 99 99 99 99
num 11
passElement(int num)
num 1234
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
![Page 5: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/5.jpg)
5
Question 1: Tracing Arrays
List1 11 22 33 44 55List2 99 99 99 99 99
changeElements(int list[])
77 88
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
![Page 6: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/6.jpg)
6
Question 1: Tracing Arrays
List1 11 22 33 44 55List2 99 99 77 99 88
copyArray(list2, list1, 5)
11 22 33 44 55
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
![Page 7: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/7.jpg)
7
Question 2: Sieve Prime Numbers
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
![Page 8: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/8.jpg)
8
Question 2: Sieve Prime Numbers
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
![Page 9: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/9.jpg)
9
Question 2: Sieve Prime Numbers
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
Find the next Prime Number
Use for loop to eliminate all the multiples of the prime number
![Page 10: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/10.jpg)
10
Question 2: Sieve Prime Numbers
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
![Page 11: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/11.jpg)
11
Question 3: Pascal Triangle
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
![Page 12: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/12.jpg)
12
Question 3: Pascal Triangle
Element: Up
Element: UpLeft
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
![Page 13: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/13.jpg)
13
Question 3: Pascal TriangleQuestion: 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
![Page 14: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/14.jpg)
14
Question 3: Pascal Triangle
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO
![Page 15: Tutorial 5 Arrays Basics (1D, 2D) NUS SCHOOL OF COMPUTING CS1010E PROGRAMMING METHODOLOGY 1 CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO](https://reader030.vdocuments.us/reader030/viewer/2022032612/56649ee55503460f94bf4e33/html5/thumbnails/15.jpg)
15
Question 3: Pascal Triangle
CS1010E TUTORIAL SLIDES PREPARED BY WU CHAO