Instructor: Dr. Michael Geiger Spring 2019 Lecture 13: Exam 1 Preview

Slides:



Advertisements
Similar presentations
How to Program in C++ CHAPTER 3: INPUT & OUTPUT INSTRUCTOR: MOHAMMAD MOJADDAM.
Advertisements

C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 3: Input/Output.
Chapter 3: Input/Output
CS 117 Spring 2002 Review for Exam 3 arrays strings files classes.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 6: Continuing with output formatting.
C++ Programming: Program Design Including Data Structures, Fifth Edition Chapter 3: Input/Output.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 26: Exam 2 Preview.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Fall 2012 Lecture 8: File I/O; Introduction to classes.
C++ Programming: From Problem Analysis to Program Design, Fourth Edition Chapter 3: Input/Output.
I/O and Data Formatting Introduction to Class Concepts INFSY 307 Spring 2003 Lecture 3.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Spring 2013 Lecture 5: Continuing with C++ I/O Basics.
Chapter 3: Input/Output
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
ECE 264 Object-Oriented Software Development Instructor: Dr. Honggang Wang Fall 2012 Lecture 13: Exam 1 Preview.
Chapter 3: Input/Output. Objectives In this chapter, you will: – Learn what a stream is and examine input and output streams – Explore how to read data.
ECE Application Programming
ECE Application Programming
Topic 2 Input/Output.
ECE Application Programming
ECE Application Programming
CPS120: Introduction to Computer Science
ECE Application Programming
CMSC202 Computer Science II for Majors Lecture 08 – Overloaded Constructors Dr. Katherine Gibson Based on slides by Chris Marron at UMBC.
EECE.2160 ECE Application Programming
Chapter 2 part #3 C++ Input / Output
Standard Input/Output Streams
EECE.2160 ECE Application Programming
Chapter 3: Input/Output
Chapter 3 Input output.
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
Chapter 2 part #3 C++ Input / Output
Algorithmic complexity
Instructor: Dr. Michael Geiger Spring 2019 Lecture 4: Functions in C++
EECE.2160 ECE Application Programming
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
EECE.2160 ECE Application Programming
Instructor: Dr. Michael Geiger Spring 2017 Lecture 12: Exam 1 Preview
EECE.2160 ECE Application Programming
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
EECE.2160 ECE Application Programming
Instructor: Dr. Michael Geiger Spring 2019 Lecture 23: Exam 2 Preview
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019
Instructor: Dr. Michael Geiger Spring 2019 Lecture 6: Strings
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2017
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
EECE.2160 ECE Application Programming
Presentation transcript:

Instructor: Dr. Michael Geiger Spring 2019 Lecture 13: Exam 1 Preview EECE.3220 Data Structures Instructor: Dr. Michael Geiger Spring 2019 Lecture 13: Exam 1 Preview

Data Structures: Exam 1 Preview Lecture outline Announcements/reminders Late HW 1 submissions due by end of day Solution to be posted Saturday morning Program 2 to be posted; due date TBD Exam 1: Monday, 2/25, 3-5 PM, Ball 214 Will be allowed two double-sided 8.5” x 11” note sheets No electronic devices Today’s lecture: Exam 1 Preview General exam notes Review of material 5/6/2019 Data Structures: Exam 1 Preview

Data Structures: Exam 1 Preview Exam 1 notes Allowed two 8.5” x 11” double-sided sheets of notes No other notes, electronic devices (calculator, phone) Exam will last two hours We’ll start at 3:00—please be on time!! Covers all lectures through Lec. 12 No questions on Basic C++ structure (namespaces, <iostream>, etc.) File organization (.h/.cpp files for structs/classes) Abstract data types Exam sections (1+ questions in each) Input/output C style structures Functions Strings Algorithmic complexity Classes 5/6/2019 Data Structures: Exam 1 Preview

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/6/2019 Data Structures: Exam 1 Preview

Data Structures: Exam 1 Preview Review: File I/O File stream objects Must include <fstream> ifstream (input) or ofstream (output) Have methods for file open/close File I/O syntax similar to standard I/O Replace cin/cout with appropriate stream object Same operators used: << >> 5/6/2019 Data Structures: Exam 1 Preview

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/6/2019 Data Structures: Exam 1 Preview

Review: Output manipulators (cont) showpoint does not imply fixed format Could be fixed point, could be scientific notation Scientific notation used if precision < # digits before decimal point Default behavior: precision = sig. figures After fixed: precision = digits after point Clearing fixed flag: defaultfloat There aren’t just two options … … but we’re not going to discuss the other ones 5/6/2019 Data Structures: Exam 1 Preview

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/6/2019 Data Structures: Exam 1 Preview

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/6/2019 Data Structures: Exam 1 Preview

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/6/2019 Data Structures: Exam 1 Preview

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/6/2019 Data Structures: Exam 1 Preview

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/6/2019 Data Structures: Exam 1 Preview

Data Structures: Exam 1 Preview Review: Strings String data type found in <string> library Concepts to work with strings Relational operators: ==, !=, <, >, <=, >= Character-by-character comparison using ASCII Concatenation: +, += Choosing single character: [], at() at() provides boundary checking Substrings: substr() function If s1 = “ECE 264”  s1.substr(0,3) = “ECE”  3 chars starting at position 0 s1.substr(4) = “264”  all chars from position 4 to end of string Checking string length: length(), empty() functions 5/6/2019 Data Structures: Exam 1 Preview

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/6/2019 Data Structures: Exam 1 Preview

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/6/2019 Data Structures: Exam 1 Preview

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/6/2019 Data Structures: Exam 1 Preview

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/6/2019 Data Structures: Exam 1 Preview

Data Structures: Exam 1 Preview Final notes Next time: Exam 1—PLEASE BE ON TIME Reminders: Late HW 1 submissions due by end of day Solution to be posted Saturday morning Program 2 to be posted; due date TBD Exam 1: Monday, 2/25, 3-5 PM, Ball 214 Will be allowed two double-sided 8.5” x 11” note sheets No electronic devices 5/6/2019 Data Structures: Exam 1 Preview