CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 ·...
Transcript of CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 ·...
![Page 1: CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 · CS250 Intro to CS II Doug Ryan ryand@pacific.edu Strain 201 Office hours: MWF 10-11am](https://reader036.fdocuments.in/reader036/viewer/2022070915/5fb5fa6ff1f0e5642f12d815/html5/thumbnails/1.jpg)
CS250 Intro to CS IIDoug Ryan
Strain 201
Office hours: MWF 10-11am
Or by appointment
Spring 2017 CS250 - Intro to CS II 1
![Page 2: CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 · CS250 Intro to CS II Doug Ryan ryand@pacific.edu Strain 201 Office hours: MWF 10-11am](https://reader036.fdocuments.in/reader036/viewer/2022070915/5fb5fa6ff1f0e5642f12d815/html5/thumbnails/2.jpg)
Welcome!
• Web Page http://zeus.cs.pacificu.edu/ryand/cs250/2017
• Syllabus
• Calendar
• Text Book
• Visual Studio 2015
Spring 2017 CS250 - Intro to CS II 2
![Page 3: CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 · CS250 Intro to CS II Doug Ryan ryand@pacific.edu Strain 201 Office hours: MWF 10-11am](https://reader036.fdocuments.in/reader036/viewer/2022070915/5fb5fa6ff1f0e5642f12d815/html5/thumbnails/3.jpg)
Progression!
• CS 150
– C++ mechanics
– Visual Studio mechanics, Debugger
• CS 250
– C++ mechanics (structs, classes)
– Object oriented programming and design
– Graphics (SDL 2)
• CS 485 (Spring 2019)
– C++ mechanics (C++11, C++14, templates, STL)
– Object oriented design
– Design patternsSpring 2017 CS250 - Intro to CS II 3
![Page 4: CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 · CS250 Intro to CS II Doug Ryan ryand@pacific.edu Strain 201 Office hours: MWF 10-11am](https://reader036.fdocuments.in/reader036/viewer/2022070915/5fb5fa6ff1f0e5642f12d815/html5/thumbnails/4.jpg)
What I think you know
• Variables & data types
• Relational & logical operators
• Decision statements
• Repetition statements including nesting
• Functions
• Files
• Arrays
• Character processing
• Visual Studio
• Debugger
Spring 2017 CS250 - Intro to CS II 4
![Page 5: CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 · CS250 Intro to CS II Doug Ryan ryand@pacific.edu Strain 201 Office hours: MWF 10-11am](https://reader036.fdocuments.in/reader036/viewer/2022070915/5fb5fa6ff1f0e5642f12d815/html5/thumbnails/5.jpg)
This class
• More C++ mechanics– Arrays
– Structs
– Classes
– Pointers
• Graphics programming– SDL
• Object Oriented Design
Spring 2017 CS250 - Intro to CS II 5
![Page 6: CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 · CS250 Intro to CS II Doug Ryan ryand@pacific.edu Strain 201 Office hours: MWF 10-11am](https://reader036.fdocuments.in/reader036/viewer/2022070915/5fb5fa6ff1f0e5642f12d815/html5/thumbnails/6.jpg)
Review
Review Reading: pp. 265-284 (files) pp. 375-425 (arrays)
Topics to Review
Files (Reading & Writing)
Arrays (1D & 2D)
Character Processing
Spring 2017 CS250 - Intro to CS II 6
![Page 7: CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 · CS250 Intro to CS II Doug Ryan ryand@pacific.edu Strain 201 Office hours: MWF 10-11am](https://reader036.fdocuments.in/reader036/viewer/2022070915/5fb5fa6ff1f0e5642f12d815/html5/thumbnails/7.jpg)
Files
What is a stream?
How do we create a stream for reading from a file?
Spring 2017 CS250 - Intro to CS II 7
![Page 8: CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 · CS250 Intro to CS II Doug Ryan ryand@pacific.edu Strain 201 Office hours: MWF 10-11am](https://reader036.fdocuments.in/reader036/viewer/2022070915/5fb5fa6ff1f0e5642f12d815/html5/thumbnails/8.jpg)
One-dimensional arrays
Consider int aIntArry[] = {1, 2, 3, 4, 5};
double aDoubleArry[10];
1. What are the index values for each array?
2. How many elements does each array have?
3. Arrays consist of homogeneous data. What does this mean?
Spring 2017 CS250 - Intro to CS II 8
![Page 9: CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 · CS250 Intro to CS II Doug Ryan ryand@pacific.edu Strain 201 Office hours: MWF 10-11am](https://reader036.fdocuments.in/reader036/viewer/2022070915/5fb5fa6ff1f0e5642f12d815/html5/thumbnails/9.jpg)
Problem #1DNA Length
A DNA string represents the order of nucleobasesalong one strand of a double-stranded DNA molecule
The other strand is the reverse complement of the string
DNA strings are constructed from the alphabet {A, C, G, T} representing the bases adenine, cytosine, guanine, and thymine
Spring 2017 CS250 - Intro to CS II 9
![Page 10: CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 · CS250 Intro to CS II Doug Ryan ryand@pacific.edu Strain 201 Office hours: MWF 10-11am](https://reader036.fdocuments.in/reader036/viewer/2022070915/5fb5fa6ff1f0e5642f12d815/html5/thumbnails/10.jpg)
Problem #1DNA Length
• The DNA string AAGATGCCGT has length 10 nucleobases (or just bases)
• Write a function getDNALength that accepts a character array (that ends with null) and returns the length of a DNA string
Spring 2017 CS250 - Intro to CS II 10
![Page 11: CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 · CS250 Intro to CS II Doug Ryan ryand@pacific.edu Strain 201 Office hours: MWF 10-11am](https://reader036.fdocuments.in/reader036/viewer/2022070915/5fb5fa6ff1f0e5642f12d815/html5/thumbnails/11.jpg)
Problem #2Reverse Complement
In DNA strings, the symbols A and T are complements of each other as are C and G
The reverse complement of a DNA string 𝑠 is formed by reversing the contents of 𝑠 and then taking the complement of each symbol
The DNA string AAAACCCGGT has the reverse complement ACCGGGTTTT
Spring 2017 CS250 - Intro to CS II 11
![Page 12: CS250 Intro to CS IIzeus.cs.pacificu.edu/ryand/cs250/2017/Lectures/01Review.pdf · 2017-02-06 · CS250 Intro to CS II Doug Ryan ryand@pacific.edu Strain 201 Office hours: MWF 10-11am](https://reader036.fdocuments.in/reader036/viewer/2022070915/5fb5fa6ff1f0e5642f12d815/html5/thumbnails/12.jpg)
Problem #2Reverse Complement
The data file dnastrings.txt contains an unknown number of DNA strings where each string has length at most 1000 bases
Write a program to output
each DNA string
the reverse complement of each DNA string
Let’s write
well-defined function prototypes
each function definition
main function for solving the stated problem
Spring 2017 CS250 - Intro to CS II 12