Presentation is loading. Please wait.

Presentation is loading. Please wait.

Instructor: Dr. Michael Geiger Spring 2017 Lecture 12: Exam 1 Preview

Similar presentations


Presentation on theme: "Instructor: Dr. Michael Geiger Spring 2017 Lecture 12: Exam 1 Preview"— Presentation transcript:

1 Instructor: Dr. Michael Geiger Spring 2017 Lecture 12: Exam 1 Preview
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2017 Lecture 12: Exam 1 Preview

2 Data Structures: Exam 1 Preview
Lecture outline Announcements/reminders Program 2 due Tuesday, 2/21 10% bonus on initial score if submitted by today May need CLOCKS_PER_SEC / (double), not int Exam 1: Friday, 2/17 Will be allowed one double-sided 8.5” x 11” note sheet No electronic devices Next week: lecture Tuesday, not Monday Today’s lecture: Exam 1 Preview General exam notes Review of material 5/29/2019 Data Structures: Exam 1 Preview

3 ECE Application Programming: Exam 1 Preview
Exam 1 notes Allowed one 8.5” x 11” double-sided sheet of notes No other notes, electronic devices (calculator, phone) Exam will last 50 minutes We’ll start at 1:00—please be on time!! Covers all lectures through Lec. 11 No questions on Basic C++ structure (namespaces, <iostream>, etc.) File organization (.h/.cpp files for structs/classes) Abstract data types Question types Multiple choice (classes) Code reading (input/output) Problem solving (algorithmic complexity) Code writing (complete 1 of 2 parts; both for extra credit) (C-style structures, functions) 5/29/2019 ECE Application Programming: Exam 1 Preview

4 Data Structures: Exam 1 Preview
Review: Basic I/O Output (cout) streams Can output multiple values in same statement cout << "x= " << x << ", y=" << y << endl; Recall endl ≈ '\n' + flush output stream Input (cin) streams Use cin to read values into variables E.g., cin >> x; Skips whitespace characters Can cause problems if input doesn’t match variable type 5/29/2019 Data Structures: Exam 1 Preview

5 Review: Output manipulators
setprecision: change number of digits displayed to the right of the decimal point fixed: fixed format (no scientific notation) showpoint: force decimal point (and trailing zeros) to be shown Default behavior (without showpoint) is to not show trailing zeros Default precision (with showpoint) is 6 Reset with noshowpoint 5/29/2019 Data Structures: Exam 1 Preview

6 Review: Characters and input
Input (cin) streams Use cin to read values into variables E.g., cin >> x; Skips whitespace characters Input value must be compatible with type of x Reading n characters: cin.get(buffer, n); Reading 1 character: cin.get(ch); Reading an entire line (at most m characters): cin.getline(buffer, m) May need cin.ignore(x) to skip characters 5/29/2019 Data Structures: Exam 1 Preview

7 Review: Structures in C++
User-defined collections of data; example: struct StudentInfo { char first[50]; char middle; char last[50]; unsigned int ID; double GPA; }; Can define variables of that type Scalar: StudentInfo student1; Array: StudentInfo classList[10]; Pointer: StudentInfo *sPtr; Access members using Dot operator: student1.middle = ‘J’; Arrow (if pointers): sPtr->GPA = 3.5; Passed to functions by address or reference 5/29/2019 Data Structures: Exam 1 Preview

8 Review: Nested structures
Structures can contain other structures: struct Name { char first[50]; // First name char middle; // Middle initial char last[50]; // Last name }; struct SINew { Name sname; // Student name unsigned int ID; // ID # double GPA; // Grade point Will need multiple dot operators to access field within nested structure Given SINew s1; s1.sname  Name structure within s1 s1.sname.middle  middle initial of name within s1 5/29/2019 Data Structures: Exam 1 Preview

9 Data Structures: Exam 1 Preview
Review: Functions Used to break programs into smaller pieces Useful when code sequences repeated Functions have: An optional return value A name Optional arguments Must be prototyped or written completely prior to use C++ supports three forms of argument passing Pass by value (also supported in C) Pass by address (also supported in C) Pass by reference 5/29/2019 Data Structures: Exam 1 Preview

10 Review: Function examples
All examples below are function prototypes Contain information about how to call function Return type, name, and argument list Only arg types required, but good practice to list names No details on operation of function (definition) int f1(); double f2(int x, int y); void f3(int *p1, int *p2); void f4(int &r1, int &r2); f3() arguments passed by address Explicit pointer—call requires addresses: f3(&x, &y); f4()arguments passed by reference Aliases—call does not require addresses: f4(x, y); f4() does have ability to modify input arguments 5/29/2019 Data Structures: Exam 1 Preview

11 Review: Algorithmic complexity
Typically try to approximate worst-case computing time Measure time as T(n), function of n Count number of times each step in algorithm executes Use big O notation—O(f(n))—to express order of magnitude Choose slowest growing function that provides upper bound on execution time Look at largest exponent in T(n) term Ignore constants, multipliers 5/29/2019 Data Structures: Exam 1 Preview

12 Data Structures: Exam 1 Preview
Review: Classes Classes allow programmer to define their own types Objects: instances of a class Each class typically contains Data members: attributes for each object Each object has own copy of data members Member functions: Tasks specific to class Data/functions can be public or private Private members only accessible within member functions Often accessed through “set”, “get” functions Private functions also known as helper functions 5/29/2019 Data Structures: Exam 1 Preview

13 Review: Class Declaration
Basic syntax class ClassName { public: Declarations of public members private: Declarations of private members }; Class definition in .h file Function definitions in .cpp file Must specify class name with definition: ClassName::FunctionName() { ... } 5/29/2019 Data Structures: Exam 1 Preview

14 Data Structures: Exam 1 Preview
Review: Constructors Functions used to initialize an object’s data when it is created Must be defined with the same name as the class: e.g. GradeBook::GradeBook() No return type Default constructor has no parameters Parameterized constructor takes 1+ arguments Constructors often examples of overloaded functions Functions with same name, different argument list 5/29/2019 Data Structures: Exam 1 Preview

15 Data Structures: Exam 1 Preview
Final notes Next time: Exam 1—PLEASE BE ON TIME Reminders: Program 2 due Tuesday, 2/21 10% bonus on initial score if submitted by today Exam 1: Friday, 2/17 Will be allowed one double-sided 8.5” x 11” note sheet No electronic devices Next week: lecture Tuesday, not Monday 5/29/2019 Data Structures: Exam 1 Preview


Download ppt "Instructor: Dr. Michael Geiger Spring 2017 Lecture 12: Exam 1 Preview"

Similar presentations


Ads by Google