CSS 342 Data Structures, Algorithms, and Discrete Mathematics I

Slides:



Advertisements
Similar presentations
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Advertisements

Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
Lecture 3 Feb 4 summary of last week’s topics and review questions (handout) Today’s goals: Chapter 1 overview (sections 1.4 to 1.6) c++ classes constructors,
Software Engineering and Design Principles Chapter 1.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
Class 0: Review and Perspective. cis 335 Fall 2001 Barry Cohen Class info n Barry Cohen n n Office hours: W 3:15-4:40.
Chapter 1 Principles of Programming and Software Engineering.
CSCE 110 PROGRAMMING FUNDAMENTALS WITH C++
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Elements of a C++ program 1. Review Algorithms describe how to solve a problem Structured English (pseudo-code) Programs form that can be translated into.
CSCA48 Course Summary.
CSS 342 DATA STRUCTURES, ALGORITHMS, AND DISCRETE MATHEMATICS I LECTURE CARRANO CH1, C++ INTERLUDE 1.
Rossella Lau Lecture 1, DCO10105, Semester B, DCO10105 Object-Oriented Programming and Design  Lecture 1: Introduction What this course is about:
CSS 332 PROGRAMMING ISSUES WITH OBJECT-ORIENTED LANGUAGES LECTURE
CMSC 2021 CMSC 202 Computer Science II for Majors Fall 2002 Mr. Frey (0101 – 0104) Mr. Raouf (0201 – 0204)
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
1 Object-Oriented Programming Using C++ CLASS 1. 2 Review of Syllabus Catalog Description –An introduction to object oriented programming techniques using.
Data Structures Using C++1 Chapter 1 Software Engineering Principles and C++ Classes.
Chapter 4: Subprograms Functions for Problem Solving Mr. Dave Clausen La Cañada High School.
CSS 342 DATA STRUCTURES, ALGORITHMS, AND DISCRETE MATHEMATICS I LECTURE CARRANO CH 2, APPENDIX E.
1 CSC 427: Data Structures and Algorithm Analysis Fall 2006 See online syllabus (also available through Blackboard): Course goals:
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
1 Today’s Objectives  Announcements Homework #3 is due on Monday, 10-Jul, however you can earn 10 bonus points for this HW if you turn it in on Wednesday,
CMSC 2021 CMSC 202 Computer Science II for Majors Spring 2003 Mr. Frey (0101 – 0104) Mr. Raouf (0201 – 0204)
General Computer Science for Engineers CISC 106 Lecture 12 James Atlas Computer and Information Sciences 08/03/2009.
Dr. Sajib Datta CSE Spring 2016 INTERMEDIATE PROGRAMMING.
1 CSE Programming in C++. 2 Overview Sign roster list Syllabus and Course Policies Introduction to C++ About Lab 1 Fill Questionnaire.
Data Structures and Algorithms in Java AlaaEddin 2012.
CSS 342 DATA STRUCTURES, ALGORITHMS, AND DISCRETE MATHEMATICS I LECTURE CARRANO CHAPTER 11.
T01. Outline and concepts Promising future comes from the dedication.
Lecture 1 Data Structures Aamir Zia. Introduction Course outline Rules and regulations Course contents Good Programming Practices Data Types and Data.
Principles of Programming & Software Engineering
Bill Tucker Austin Community College COSC 1315
CSCE 210 Data Structures and Algorithms
CSC 427: Data Structures and Algorithm Analysis
CSC 222: Object-Oriented Programming
CSC 222: Object-Oriented Programming
CSC 222: Computer Programming II
CSc 020: Programming Concepts and Methodology II
GC211Data Structure Lecture2 Sara Alhajjam.
Data Abstraction: The Walls
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
CSC 421: Algorithm Design & Analysis
Principles of Programming and Software Engineering
CSC 222: Object-Oriented Programming
About the Presentations
Lecture 2 of Computer Science II
Object-Orientated Programming
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
CSE1320 INTERMEDIATE PROGRAMMING
Lecture 1: Welcome to CSE 373
CSE1320 INTERMEDIATE PROGRAMMING
CS139 – Fall 2010 How far we have come
CS 2308 Final Exam Review.
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
Introduction to Data Structures
CSE1320 INTERMEDIATE PROGRAMMING
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
CSS 342 Data Structures, Algorithms, and Discrete Mathematics I
CSE1320 INTERMEDIATE PROGRAMMING
Data Structures and Algorithms for Information Processing
Review CSE116 2/21/2019 B.Ramamurthy.
From C to C++: Summary of weeks 1 - 4
Principles of Imperative Computation
Standard Template Library
Standard Template Library
An Introduction to STL.
Presentation transcript:

CSS 342 Data Structures, Algorithms, and Discrete Mathematics I 9/29/2016. Lecture 1. CarrANO Ch 1, Appendix A.

CSS342 FAQ I know Java, do I need to know C++ to take this course? I missed the C++ bootcamp, will this be a problem? Is the Rosen book required for this course? How much math is required for this class? Should I take CSS332 as well? Is this class a lot work? Any advice on success?

Intro: Who am I? Email: dimpsey@uw.edu Class page and syllabus: http://courses.Washington.edu/css342/dimpsey We will use Canvas for Announcements Assignments Grades Discussions Office Hours

Course Objectives: Why are you here? Design, implement, debug, and test Objected-Oriented Programs (OOP) Learn C++ Course uses C++ to reach goals Course is not focused on teaching C++ but we will teach aspects of it In particular: objects, allocation/deallocation, pointers, operator overloading, constructors, templates, STL Understand key data structures utilized in programming stack, list, array, queue, binary search tree Introduce key algorithms and algorithmic techniques Recursion, Sorting, Searching Discrete math as the underpinnings of Computer Science Formally analyze complexity of algorithms: Big O space and time Induction Propositional logic

Course Objectives Designing and coding industry quality applications Problem Solving Designing and coding industry quality applications

Assignments / Tests / Grades Programs: 5 Some written exercises which are not turned in Tests Quizzes: 1 Midterm Final Grades 65% Tests 35% Programs

Programs IDEs Canvas will be used to collect labs Use any IDE you like to develop In class I will use Microsoft 2015 Community edition Canvas will be used to collect labs Each lab will have specific and detailed instructions on what to turn in READ THESE CAREFULLY Start labs early Ask questions early

Labs Design Style Correctness Efficiency Program Grading Design Style Correctness Efficiency Grading will be done using either Linux Lab systems VS 2015

Available resources Tour: http://courses.Washington.edu/css342/dimpsey Tour: Canvas

Quick in-class program Write a program which takes in two numbers from the console and outputs the largest

Why Object Oriented Programming (OOP)? Abstraction Encapsulation Hierarchy Polymorphism

Why C++? Supports OOP fundamentals Elegant Efficient Some nice features Type Safety Operator Overloading Provides system understanding Memory (stack/heap), OS, threads, etc.. Usage of pointers / memory allocation/deallocation Low level functionality

Why C++?

Abstraction

Design first Design modules before coding Interface specified: functions that are to be called Implementation is secondary Relationship between modules Include pre-conditions and post-conditions Modular design Re-use Loosely Coupled

Computer Scientist of the week John Von Neumann! Innovations in Set theory, Geometry, Quantum Mechanics, Economics, Statistics Founded Game Theory Monte Carlo Method EDVAC: data and program both in same address space ENIAC: First computer to use a stored program Von Neumann Architecture! Manhattan Project MAD: Mutually Assured Destruction Merge Sort Algorithm

Interface Design Simple Complete Cohesive Descriptive Intuitive Minimal No Public Data Amenable to loosely couple

Abstraction Specify Contract / Interface for class first ADT Separate Implementation from use of class Specify Contract / Interface for class first ADT Abstract Data Type Can be specified using Uniform Modeling Language (UML) UML does not use language specific syntax

UML Class Diagram ClassName __dataFieldName1: dataType constructorName(arg1: argType) methodName1(arg1: argType) : returnType methodName2(arg1: argType) : returnType

Data Abstraction Data Abstraction Objects A collection of data and a set of well-defined operations The data can be reused without knowing the internal data representation and structure. Objects Instances of such abstracted data structure = the first-class objects

Enforcing Abstraction in C++ Modules map to C++ classes Objects == instances myClassName myObject; Class is made of two files C++ Headers file contain interface and data definition (.h) Code files contain implementation (.cpp) In this class we will not use UML much as the .h file does an excellent job of describing the contract

Problem Design an interface for a class representing a push/pop stack

class IntStack { public: bool Pop(); int Top(); bool Push(int number); int Size(); int Peek(); };

Programming Style / Guidelines Very important! Code is read much more than written You are writing code for others not yourself You often inherit others code Consumer should not have to rely on comments to understand code Will be an important component in grade for class Good code follows prescribed style rules

Programming Guidelines We’ll use some ideas from Google C++ guidelines as well http://google-styleguide.googlecode.com/svn/trunk/cppguide.html#General_Naming_Rules We’ll use some ideas from .NET Framework Design Guidelines Framework Design Guidelines, Conventions, Idioms, and Patterns for Reusable .NET libraries, Krzysztof Cwalina, Brad Abrams We will keep to a few simple rules This will impact grade of programs

Naming Definitions PascalCasing: RedTop, FirstInLine, BigScaryMonster camelCasing: blueBallThingy, sock, theItem, lastInLine Do use PascalCasing for class names, namespaces, public functions Do use camelCasing for parameters, assessors (getValue, setValue…), private functions Do use CAPS_CAPS for const const int CARDS_IN_DECK = 52 Do choose easy readable identifier names Do favor readability over brevity Do not use underscores, hyphens, or other non-alphanumeric characters (except for const where underscore is acceptable)

Spacing/lines Do keep opening and closing braces on their own lines Do use a single space after a comma between parameters Do not use spaces after or before brackets b[13] or before flow control statement Do indent each block even if braces are not used void foo(char a, int b) { while(x < y) x = 13; }

Comments Do comment functions appropriately using // before the function Use in-line comments sparingly Use comments to describe something not obvious to someone reading the code // This function is based on the zipterian algorithm. int void Zip(string firstName) { }

Problem 2 Design an interface for a class representing a deck of playing cards

Bell Rang

#include "Card.h" #include "Hand.h" const int CARDS_IN_DECK = 52; class Deck { public: Deck(); ~Deck(); Card DealSingleCard(); Hand DealHand(int number); void Shuffle(); void Cut(); int CountCardsRemaining(); void ReturnHand(Hand theHand); void ReturnCard(Card theCard); int CountValuesRemaining(int val); int CountSuitsRemaing(Suit suit); bool isEmpty(); bool isComplete(); private: Card deck[CARDS_IN_DECK]; };

Interface Design Checklist Constructors Setters/Getters Actions (verbs) Operator Overloads Private Data Types

Preview Assignment One

C++ Fundamentals LET’S CODE

IO: Console #include <iostream> using namespace std; { int age; cout << "hello world. How old are you (in years)?\n"; cin >> age; cout << "that is " << (365 * age) << " days."; }

string http://www.cprogramming.com/tutorial/string.html Mutable; Copied not shared. string firstName = "jimmy"; string lastName("hoffa"); string fullName; fullName = firstName + " " + lastName; cout << fullName << endl; cout << "First and last letters are:" << fullName[0] << " " << fullName[fullName.length() - 1] << endl; if (fullName == "jimmy hoffa") { cout << "Found !!!! "; } else cout << "oh where oh where have you gone";

Call by Value, Reference, and Constant Reference struct Rectangle { int length; int width; }; int Area(Rectangle rect) int Area(Rectangle &rect) int Area(const Rectangle &rect) { int temp; temp = rect.length; rect.length = 35; return(temp * rect.width); } int main() { int result; Rectangle r = { 3, 3 }; result = Area(r); cout << "length = " << r.length << endl; cout << "width = " << r.width << endl; cout << "Area = " << result << endl; return 0; }

In class code Write a function which takes two integers and “swaps” them

Call by Value, Reference, and Constant Reference Arrays, Pointers, and Structures Call by Value, Reference, and Constant Reference Which of swap functions is appropriate? void swap(string a, string b) { string tmp = a; a = b; b = tmp; } void swap(string &a, string &b) { string tmp = a; a = b; b = tmp; } void swap(const string &a, const string &b) { string tmp = a; a = b; b = tmp; } Which of findMax functions is appropriate? int findMax(vector<int> a) { int max = a[0]; int i; for (i=1; i < a.size(); i++) if (a[i] > max) max = a[i]; return max; } int findMax(vector<int> &a) { int max = a[0]; int i; for (i=1; i < a.size(); i++) if (a[i] > max) max = a[i]; return max; } int findMax(const vector<int> &a) { int max = a[0]; int i; for (i=1; i < a.size(); i++) if (a[i] > max) max = a[i]; return max; } CSS342: Introduction