# Register now to access 7 million high quality study materials (What's Course Hero?) Course Hero is the premier provider of high quality online educational resources. With millions of study documents, online tutors, digital flashcards and free courseware, Course Hero is helping students learn more efficiently and effectively. Whether you're interested in exploring new subjects or mastering key topics for your next exam, Course Hero has the tools you need to achieve your goals.

8 Pages

### cop3530sp12lecture

Course: COP 3530, Fall 2011
School: University of Florida
Rating:

Word Count: 445

#### Document Preview

passing call cop3530sp12 Parameter by value- appropriate for small objects that should not be altered by the function call by constant reference- appropriate for large objects that should not be altered by the function call by reference -appropriate for all objects that should be altered by the function using pointers -- see the swap method explained in class We discussed this example in class. We dont want the...

Register Now

#### Unformatted Document Excerpt

Coursehero >> Florida >> University of Florida >> COP 3530

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
passing call cop3530sp12 Parameter by value- appropriate for small objects that should not be altered by the function call by constant reference- appropriate for large objects that should not be altered by the function call by reference -appropriate for all objects that should be altered by the function using pointers -- see the swap method explained in class We discussed this example in class. We dont want the contents of of the vector arr to change so we pass it by constant reference. The value of errorFlag is passed by reference because we want that the change in its value should be refelected in the calling function. double avg (const vector<int> & arr, int n, bool & errorFlag) (// source: Mark Allen Weiss' DSA book) Return Passing Return by Value Return by constant reference return by reference (occasionally) using pointers (see the 2d dynamic array allocation example). // note that in the correct version we are returning a string by constant reference which was not declared inside the function, so when the function returns the tsring doesnt go out of scope. In the incorrect version, terrible things may happen as the string maxValue is declared inside the function and so returning by reference or constant reference is not correct. Return by value would have been correct. #include <string> #include <iostream> #include <vector> using namespace std; const string & findMax( const vector<string> & ) { int arr maxIndex = 0; for( int i = 1; i < arr.size( ); i++ ) if( arr[ maxIndex ] < arr[ i ] ) maxIndex = i; return arr[ maxIndex ]; } const string & findMaxWrong( const vector<string> & arr ) { string maxValue = arr[ 0 ]; for( int i = 1; i < arr.size( ); i++ ) if( maxValue < arr[ i ] ) maxValue = arr[ i ]; return maxValue; } // continued on next slide // ... continued from previous slide int main( ) { vector<string> arr; arr.push_back( "hello" ); arr.push_back( "there" ); arr.push_back( "world" ); cout << findMax( arr ) << endl; cout << findMaxWrong( arr ) << endl; return 0; } // using pass by value doesnt work void swap (int a, int b) { int temp = a ; a=b; b = temp ; } int main () // pass by reference -- works void swap (int & a, int & b) { int temp = a ; a=b; b = temp ; } int main() { int p = 6 ; int q = 7 ; swap (p, q) ; cout << p ; // prints 7 cout << q ; // prints 6 //call by reference // this works void swap (int *a, int *b) { temp = *a ; *a = *b ; *b = temp ; } int main() { int p = 6 ; int q = 7 ; swap(&p, &q) ; cout << p ; //prints 7 cout << q ; // prints 6 // Using pointers. This is actually a Cstyle swap code. IN C always passby value happens and so the address of p and q gets copied into a and b. So, even though it is pass by value we are still able to accomplish the swapping using pointers.
Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

University of Florida - COP - 3530
COP 3530Data Structures &amp; AlgorithmsDiscussion Session 3OutlineInput-output streams in C+Floating point precisionFile manipulationPointers in CVector class in C+Strings in C and C+About meEyup Serdar Ayazayaz@cise.ufl.eduTA Office: E309This
University of Florida - COP - 3530
Copyright 2003 Pearson Education, Inc.Slide 1Chapter 11Strings and VectorsCreated by David Mann, North Idaho CollegeCopyright 2003 Pearson Education, Inc.Slide 2OverviewAn Array Type for Strings (11.1)The Standard string class (11.2)Vectors(11.3
University of Florida - EEL - 4712
University of Florida - EEL - 4712
University of Florida - EEL - 4712
EEL 4712Midterm 2 Spring 2011VERSION 1Name:UFID:Sign your name here if you would like for your test to be returned in class:_IMPORTANT: Please be neat and write (or draw) carefully. If we cannot read it with areasonable effort, it is assumed wron
University of Florida - EEL - 4712
EEL4712Name: Midterm1Spring2012VERSION1UFID: IMPORTANT: Please be neat and write (or draw) carefully. If we cannot read it with areasonable effort, it is assumed wrong. As always, the best answer gets the most points.COVERSHEET:Problem#: Points
University of Florida - EEL - 4712
EEL4712Name: Midterm2Spring2012VERSION1UFID: Signyournamehereifyouwouldlikeforyourtesttobereturnedinclass:_IMPORTANT: Please be neat and write (or draw) carefully. If we cannot read it with areasonable effort, it is assumed wrong. As always, the
University of Florida - EEL - 4712
University of Florida - EEL - 3396
Book sections to be covered in EEL 3396 Spring 2012 during (tentatively):Week 1: Ch 1 superficially, 2.3W2: 2.5 ,3.1.allW3: 3.2. all except 3.2.5W4: 3.3 allW5: 3.4 all, 3.5W6: 4.1, 4.2, 4.3W7: 4.4, except 4.4.5W8: 5.1 superficially, 5.2, 5.3W9: 5
University of Florida - EEL - 3396
Home work assignments in preparation for the weekly Wednesday 10 minute quizzes.Note that you can only work the quiz problem successfully if you have studied theseassignments. Quizzes will be closed book, no notes. Physical constants will be given.The
University of Florida - EEL - 3396
Home work assignments in preparation for the weekly Wednesday 10 minute quizzes.Note that you can only work the quiz problem successfully if you have studied theseassignments. Quizzes will be closed book, no notes. Physical constants will be given.Brin
University of Florida - EEL - 3396
Home work assignments in preparation for the weekly Wednesday 10 minute quizzes.Note that you can only work the quiz problem successfully if you have studied theseassignments. Quizzes will be closed book, no notes. Physical constants will be given.Brin
University of Florida - EEL - 3396
Course Number and TitleEEE 3396- Solid State Electron Devices1. Catalog Description (3 hrs) Introduction to the principles of semiconductorelectron device operation.2. Pre-requisites and Co-requisites EEL 3111 - Circuits I3. Course Objectives: To pre
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
University of Florida - EEL - 3396
Purdue - AAE - 340
Purdue - AAE - 340
C1Moment / Angular MomentumOperate on Law of Motion to obtain relationship between moment andrate of change of angular momentuma pivotal equation inrotational dynamicsDerivationiid r opvdtpiid iv pAdtLaw of Motion:F m iApOperate onthe
Purdue - AAE - 340
D1Integrals of the MotionI. Work and EnergyOperate on Law of MotioniFv m ApiipiipdvmdtiiFvpd1 imvdt 2vpivppivpkinetic energy TiiFdTvTdtpAnother form of Law ofMotionyields one scalardifferential equationIntegr
Purdue - AAE - 340
M1Rigid Bodies Angular MomentumlLaws of Motion:F M i Acmar Momentumid iH qM M qcm i AqdtqDefinitionsnM q j Fjqj 1nidqjH mjdtj 1qiqjDifficulty with applying this to systems of particles: to calculate Hrequires and d dt for every
Purdue - AAE - 340
O1Examplel ircular disk welded to a &quot;massless&quot; shaft.CShaft rotates freely in frictionless bearings at A and B.(Disk remains in a vertical plane.)Point O offset from cm by distance h.arMomentum(1)(2)(3)(4)gDerive EOMDetermine bearing react
Purdue - AAE - 340
AAE 340 Dynamics and VibrationsProblem Set 8Due: 3/9/12Problem 1: The system below consists of two particles of mass m and 2m. They areconnected by a rigid, massless rod of length L; the rod has a pivot point at C. The pivot isconstrained to move ver
Purdue - AAE - 340
AAE 340 Dynamics and VibrationsProblem Sets Format for SubmissionSubmit a professional looking document; include the following elements:1. Statement of the problem in the formGiven:Find:This is not necessarily just repeating the problem statement. R
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
01316 8924 1 2 7 3 449 72 6 8929 3 3 7 3 92 989 027 3 9
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
Purdue - AAE - 340
A1Particle KinematicsLaw of Motion :F=d( mv ) = m Adtmass constantTo use the equation, must be able to mathematically represent both sides of theequationRHSKinematics: describing motion mathematically r , v , Ar = r opv = e v oped r op= ev
Purdue - AAE - 340
B1Fundamental Vibrations ProblemgAssumptions:particle P of mass msmooth surfacelinear springviscous dampingdashpot provides force proportional to speed;always acts in direction opposing motionMotion imparted to system by external force f (t )fo
Purdue - AAE - 340
E1Example: Single Particle SystemA &quot;massless&quot; rigid rod swings in a vertical plane about a frictionlesspivot point C. At the same time, the shaft CK rotates as indicated below.A particle of mass m is attached at the end of the rod; angles and define
Purdue - AAE - 340
increase complexity of model(a/c and s/c are not really particles)System of ParticlesClassify system as comprised of particles m1, m2 , m3 ,mnClassify forces(1) Internal forces - forces between particles in the systemf jkforce exerted on particle
Purdue - AAE - 340
increase complexity of model(a/c and s/c are not really particles)System of ParticlesUseful definition : Center of MassnMRcm mj R jj 1Motion of the system : Try System FBDDerive EOMF M AicmUseful but limited - solution would producetime his
Purdue - AAE - 340
I1Systems of Particles: Integrals of the MotionI. Work and EnergyOperate on Law of MotionWhich one?F mj Aij(a)cm(b)all forces on mjF M Aiexternal forces on system(a) Single ParticleFiv m ApiipiipdvmdtiFivpvpd1 imvdt 2
Purdue - AAE - 340
Intro1IntroductionNewton's Principia (1686) is composed of threebooks:1. De motu corporum (On the motion of bodies)Volume 1 - mathematical explanation of calculus,basic dynamical definitions and implications2. De motu corporum (On the motion of bod
Purdue - AAE - 340
J1Systems of Particles: ObservationsWe have developed tools for use in analysis of problems that includemodels more complex than single particles, that is, a system that ismodeled as a general collection of n particles (no restrictions on model)For s
Purdue - AAE - 340
K1Degrees of FreedomThe number of degrees of freedom (DOF) associated with a system isequal to the number of coordinates used to describe its configurationminus the number of independent constraint equations.Note: No. of EOM = No. of DOFExample: 3 n
Purdue - AAE - 340
L1Vector TransformationsExpand the set of mathematical tools to &quot;organize&quot; or describe anydegrees of freedom represented by anglesunit vector relationships and write them in matrix formuse matrices to describe orientationExample:Rod (Rigid Body)6
Purdue - AAE - 340
N1Inertia Matrixl I q is very important s consider it more carefullybar MomentumObservations:1. Base point / coordinatesEach element of I q is a scalar BUT it is calculated frombcomponents of a position vector with a specified base pointI11 2
Purdue - AAE - 340
N12Inertia Matrixl4. Eigenvalues / EigenvectorsGiven: I q in terms of some set of unit vectorsar MomentumaDefinitions:Direction parallel to unit vectors for which the inertia matrix forpoint q is diagonal (that is, all products of inertia are ze
Purdue - AAE - 340
N18Inertia Matrix: ExamplelGiven: a rectangular box ofconstant density ( m 12 kg).Determine principal momentsand directions for point O atthe center of one edge, that is,ar Momentum I cm eApproach:1. Write I q for some convenient point/vector
Purdue - AAE - 340
P1ExamplelThin, rectangular plate rotates aboutthe vertical axis at rate garMomentumAlso rotates about pin at point Owithout friction(i) Derive EOM(ii) Solve for any reaction forcesand/or moments(iii) Any integrals of the motion?Note: = con
Purdue - AAE - 340
A~ e r v o m ~ bm a i n t a i n s n cons)an+ s pin raterge d isK U I ' ~ #r esped Yo .the massless sh&amp;P recession rate ( 8 ) m aintained c o n s W bb4K e . N lcta~ion 3 l e 8 I Swb erive E o M and f ind e x p r e ~ r o r ,e x t e r n a l -tDrgue
Purdue - AAE - 340
Purdue - AAE - 340
340 Office Hours Spring 2012MTWTHFHowellBosanacHowell7:308:309:3010:30Howell11:3012:301:302:30Bosanac3:304:30Prof Howell office hours: MWF 10-12Bosanac office hours: T 2:00-4:00 Th 10:00-12:00Unavailable
Purdue - AAE - 340