CMPSC-121-C29W15-Wed

Views:
 
Category: Entertainment
     
 

Presentation Description

No description available.

Comments

Presentation Transcript

CMPSC-121:

CMPSC-121 R. W. DelPorto Monday-Wednesday Class Section 1: 12:20PM-1:10PM Nick 166 Section 3: 1:25PM-2:15PM Nick 165 Thursday Lab Section 1: 8:00AM-9:50AM Nick 155 Section 2: 1:00PM-2:50PM Nick 155

Pre Class Questions:

Pre Class Questions There are no wrong answers this time. It’s a survey. Everybody gets 8 points! 1- 2

Question #1:

Question #1 The use of clickers in this class: Greatly enhanced the learning experience. Somewhat enhanced the learning experience. Had little or no effect. Somewhat negatively impacted the learning experience. Had a significantly negative impact. 1- 3

Question #2:

Question #2 Regardless of whether you are positive or negative on clickers, the questions chosen: Were relevant and fairly represented the material from the reading assignments. Were generally related and relevant. Were relevant but not much related to the assignment. Were generally useless and/or irrelevant. 1- 4

Question #3:

Question #3 Overall, my reaction to the use of clickers is: Very positive. Somewhat positive. Neutral. Somewhat negative. Very negative. 1- 5

Question #4:

Question #4 My opinion on the use of clickers now: Is much more positive than at the beginning of the semester. Is somewhat more positive than at the beginning of the semester. Unchanged. Is somewhat more negative than at the beginning of the semester. Is much more negative than at the beginning of the semester 1- 6

Templates:

Templates 12/18/2012 CMPSC-121 7

Template:

Slide 1- 8 Template In an effort to make a sort function general, we usually make it a templated function That way we can pass it a vector of anything and it will sort // Shell Sort template <class T> void sortit( vector <T>& v) Some possible calls: vector < int > numbers; vector <string> lastNames ; vector <double> costs ; ….. sortit (numbers); sortit ( lastNames ); sortit (costs);

swapper:

swapper Swapper is also a templated function: template <class T> void swapper(T &a, T &b) { } Help me write this! 12/18/2012 CMPSC-121 9

swapper:

swapper Swapper is also a templated function: template <class T> void swapper(T &a, T &b) { T temp; temp = a; a = b; b = temp; } 12/18/2012 CMPSC-121 10

Project #3 Note:

Project #3 Note When sorting parallel vectors, keep in mind that whenever you swap two values in the vector you are sorting, you must swap the same two values in the related vectors. swapper( part_number [j], part_number [j - increment]); swapper( part_class [j], part_class [j - increment]); swapper( ohb [j], ohb [j - increment]); swapper(cost[j ], cost[j - increment]); 1- 11

Sort descending:

Sort descending 12/18/2012 CMPSC-121 12

PowerPoint Presentation:

12/18/2012 CMPSC-121 13 #include < iostream > #include <algorithm> #include <vector> #include < cstdlib > #include < ctime > using namespace std ; int main() { vector < int > v1; srand (time(NULL)); for ( int i =0;i<30;i++) v1.push_back(rand() %500); // To sort in descending order. specify binary predicate sort( v1.begin( ), v1.end( ), greater< int >( ) ); cout << "vector v1 = ( " ; for (int i =0 ;i<v1.size(); i++) cout << v1[ i ] << " "; cout << " )" << endl ; } /* vector v1 = ( 467 459 447 445 443 441 441 400 388 363 363 350 327 290 257 206 206 203 201 188 187 163 137 131 126 102 87 82 6 1 ) */

Vector SubScripts:

Vector SubScripts 1- 14

Uses:

Slide 1- 15 Uses vector <string> month (13); month[1] = “Jan”; month[2] = “Feb”; … month[12] = “Dec”; What about month[0] ? Why 13? cout << “Which month? (1-12)” cin >> mon; cout << month[mon] << endl;

Subscript Translation:

Slide 1- 16 Subscript Translation Sales for 1990 through 2009 vector <double> sales (2010); // allocates sales[0] … sales[2009] – wasteful vector <double> sales (20) // allocates sales[0] … sales[19] // Could confuse the user!

How to use:

Slide 1- 17 How to use for (year=1990;year < 2010;year++) { cout << “Enter sales for “ << year << “: “; cin >> sales[year – 1990]; } Enter sales for 2000: Goes into sales[10] !

Final:

Final 1- 18

Functions:

Functions Void vs Value Returning Value parameters vs reference parameters Remember “Write a function” means “write a function!” 1- 19

while, do .. while, and for loops:

while, do .. while, and for loops Be able to trace the execution of a loop Be able to write a loop to accomplish a task Be able to convert one type of loop into another Eg for to while etc 1- 20

vectors, vectors, vectors:

vectors, vectors, vectors You need to understand how vectors work The differences between arrays and vectors Passing vectors or arrays to functions Strings, length of string 1- 21

What would you like me to review?:

What would you like me to review? This is your chance to get it straight. 1- 22

Logic:

Logic The most important skill is being able to think your way through a problem Let’s take a few minutes to solve this one. You can consult with others. When you think you have it, bring it up to me. http:// www.puzzles.com/projects/LogicProblems/CookingClass.htm 1- 23

Don’t forget!:

Don’t forget! Please do the Student Rating of Teacher Effectiveness (SRTE) on ANGEL. Please do leave comments. 12/18/2012 CMPSC-121 24

Going Forward:

Slide 1- 25 Going Forward I enjoyed having all of you in class. If I can ever be of help to you, let me know. Final Exam: Wednesday, December 19, 2012, 10:00AM – 11:50AM Burke 106

Two more questions!:

Two more questions! When is the Final Exam for CMPSC-121? Where is the Final Exam for CMPSC-121? 1- 26

Two more questions!:

Two more questions! When is the Final Exam for CMPSC-121? Wednesday, December 19, 2012, 10:00AM – 11:50PM Where is the Final Exam for CMPSC-121? Burke 106 1- 27

Thought for the Day:

12/18/2012 CMPBD-350 - DelPorto 28 Thought for the Day 42 - Douglas Adams -- giving the answer to "the ultimate question of life, the universe and everything.“ Author of “The Hitchhiker's Guide to the Galaxy” 1952-2001

authorStream Live Help