340 likes | 534 Views
CS 240: Data Structures. Tuesday, May 29 th Introduction. Welcome. First, I want to find out some stuff about each of you: Name, Major, Year Preferred Email (you are responsible for your binghamton.edu address, but I’ll send things to an alternatve address if you want)
E N D
CS 240: Data Structures Tuesday, May 29th Introduction
Welcome • First, I want to find out some stuff about each of you: • Name, Major, Year • Preferred Email (you are responsible for your binghamton.edu address, but I’ll send things to an alternatve address if you want) • Previous CS, Math, or EECE courses.
Some Group Work • Get in groups, or don’t get in groups • I’ll ask each group for a response • Come up with a few ideas for the following:
Group Work • What do you think this course is about? • What do you want this course to be about? • What do you want to be able to accomplish after this course? • What have you gotten from your previous CS courses (140, 210, 211, 220)? • What are the responsibilities of a student? • What are the responsibilities of an instructor?
Syllabus • This course meets M, T, R from 4-6pm. • On Monday, we meet in LNG103, ignore what BUSI says! • My office hours are T, R from 1:00-2:30 in EBN13. Appointments can be made for other times. • My email is: jloew@cs.binghamton.edu • Office phone: 777-7613 (email is preferred) • AIM: delbin1 (I’m not on often so don’t rely on AIM. Let me know you are from class if you decide to use this). • Website: http://bingweb.binghamton.edu/~cs240
Syllabus • Textbook: • “Objects, Abstraction, Data Structures and Design Using C++”, Elliot B. Koffman and Paul A.T. Wolfgang. Wiley 2005. • Available at the school bookstore, Mando Books, etc. • An electronic edition is available from wiley.com
Syllabus • Recommended: • For those who want a good C++ resource. • “Absolute C++”, Walter Savitch. Addison-Wesley 2007. • I am not sure if the school bookstore or Mando Books ordered this text.
Syllabus • Additional Resources: • Microsoft Academic Alliance: • http://msdn04.e-academy.com/elms/Storefront/Home.aspx?campus=binghamton_watson
Syllabus • Complier: • In this class we use g++ on the Bingsuns machines. • Bingsuns can be accessed from most locations with an internet connection. • The first homework assignment will require you to connect to Bingsuns from an external machine.
Grades • Homework/Labs/Quizzes 24% • Projects 22% • Presentations/Defenses 12% • Exam 1 14% • Exam 2 14% • Final Examination 14%
Academic Honesty • Don’t cheat. I’d prefer to leave it at that. • The syllabus goes into a little more detail.
Attendance • Attendance is required. • Let me know if some problem comes up and we can make arrangements. • If you miss a class, I assume that you caught up on the material on your own. • Generally, there are no makeup exams/quizzes or presentation times. • Makeups will never be identical to the original and can be of any format.
Blackboard • Blackboard will be used to track grades, submit some assignments and post questions (if desired). • Make sure your grades match what is on Blackboard. • A “0” indicates that I did not receive your assignment. It is your responsibility to resolve this within 2 weeks of the assignment being returned to class. • After the 2 week period, grades for an assignment are considered final.
Lab Sections • Lab classes are held in LNG103. • These will reinforce some of the topics we discuss in class and give students a chance to implement ideas and learn some coding constructs.
Communication • Email: jloew@cs.binghamton.edu • Generally, if I don’t respond with 24 hours I didn’t get your email.
Grading Disputes • Regrade request must be made in writing and within 2 weeks of return of the assignment. • Assignments submitted late may be graded more harshly than non-late assignments and are considered differently in the regrading process. • However, assignments should be handed in on time.
Submissions • Hard copies are required for all submissions. These are handed in during class or in the dropbox. • Some submissions will require submission on blackboard, ftp, or other electronic forum. • Coding assignments must be on your H: drive. They may be examined during lab.
Coding Policies • For most of the course, we will not use many of the existing abstractions provided as part of C++. • Most of the assignments can be completed with knowledge of only a handful of coding structures.
Coding • I tend to be very strict when grading code • Even if code works, it can still be wrong! • Although I will grade code very harshly, revisions and resubmission are part of the software process and are expected for the majority of assignments.
Any questions about the syllabus? • I’ll give you a few minutes to discuss with other students if you want.
Introduction to C++ • First, we’ll cover some key differences between C++ and Java
Java Intrepreted Generally portable import C++ Compiled Source may be portable #include
Java (Hello.java) public class Hello { public static void main(String args []) { System.out.println(“Hello!”); } } javac Hello.java java Hello C++ (Hello.cpp) #include<iostream> using namespace std; int main() { cout << “Hello!” <<endl; return 0; } g++ Hello.cpp –o Hello.exe ./Hello.exe Hello World Examples
C++ vs Java • There are other differences that we will talk about as they come up. • It isn’t terribly useful for us to laundry list all the differences. They’ll make sense when we get there.
Functions • In C++, functions do not require a class as a wrapper. int addTwoToInt(int input) { return (input+2); } • Simple enough, it adds 2 to our input:
Includes commonly used C++ components Allows us to use cout instead of std::cout Function prototype. Keeps all the function names in one neat location #include<iostream> using namespace std; int addTwoToInt(int input); int main() { int number = 5; addTwoToInt(number); cout << number << endl; cout << addTwoToInt(number) <<endl; return 0; } int addTwoToInt(int input) { return (input+2); } Entry Point Variable: Number Calls our function Prints: 5 Prints: 7 Exits main(), returns 0 (success) Function Definition Function operation and return statement
Commenting Functions int addTwoToInt(int input) { return (input+2); } • How do we describe a function?
Commenting Functions // Takes in 1 int (input) // Returns int (input + 2) // No side effects - optional if nothing happens // No special conditions - optional if none int addTwoToInt(int input) { return (input+2); }
When should I write a function? • If you ever copy/paste, consider a function. • This is in contrast to what you may have been told in CS140 (copy/paste of a template leads to more efficient programming). • It leads to ugly procedural code. • Functions can also be used to separate code into more managable portions (and reduce side effects).
Procedural Programming • We write functions to “Decompose” a problem. • Many problems are too large to simply write code to solve. • Even if they aren’t too large, procedural programming can lead to code reuse and easier debugging.
We have a list of numbers and want to convert them to binary. How do we decompose this? Repeat until done Get numbers Choose a number Convert to binary
Implementation Repeat until done #include<iostream> using namespace std; int main() { while(areNumbersLeft() == True) { int nextnumber = getnextnumber(); int converted = convertToBinary(nextnumber); } return 0; } Get numbers Choose a number Convert to binary
First Assignment • Should be online. • Next class we will go over the reading assignment.