cs 2050: algorithm design and programming ii (in java) welcome !

50
CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Upload: elizabeth-bell

Post on 02-Jan-2016

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

CS 2050: Algorithm Design and Programming II (in Java)

WELCOME !

Page 2: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

People you should know:

Instructor : Anoop Haridas Office: EBW 347

Hours: M,W 2:30 – 3:30 pm. Email: [email protected].

Course webpage : Coming soon !

Page 3: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Tell us about yourself !

Page 4: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

What’s it about ?

Learn about :

(1) Algorithms

(2) Data structures

Implement these in Java.

Page 5: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

When and where ?

Lectures:

M, W, F E1419 Lafferre Hall.(12:10 to 1:10 p.m.)

Labs:

T, R 124B GCB.(12:10 to 2:10 p.m.)

Page 6: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Main Text

“Data Structures & Other Objects Using JAVA” (3rd Edition), by Michael Main.

Please see :

http://www.mubookstore.com/textbooks.asp

for more information.

Page 7: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Other Sources of Information

There are many other textbooks that provide good explanations of the topics covered in this course.

You may also want to look at material on the internet for alternative explanations of course concepts.

Page 8: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Prerequisites

Each student is assumed to have completed CS 1050 (or its equivalent) with no less than a C- grade.

This course assumes that each student is familiar with the Java programming language.

Java will be used for all assignments, so students unfamiliar with Java should expect to spend some extra time at the beginning of the semester to develop practical proficiency with it.

Page 9: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Topics to be covered

Java classes and information hidingCollection classesLinked listsGeneric programmingStacks and queuesRecursionTreesSearching Sorting

Page 10: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Grading

40% - Programming assignments.

60% - Exams: One or two + Final.

90% or above of the total points guarantees a grade in the A range; above 80% guarantees a grade of B- or above; and so on.

The instructor reserves the right to apply a more generous curve.

Page 11: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Course & Exam Schedule

Will be made available on the course webpage.

Page 12: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Exams & Programming Projects

Exams will be multiple-choice, usually with 20-30 questions.

Exam dates will be announced in lecture and posted on the course web page. The key for each exam will be posted immediately after the test. There will be no makeup exams.

Page 13: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

(contd.)

The programming assignments will be posted in the form of a program specification that describes what is expected, how it will be graded, and when it will be graded.

Questions about an assignment should be asked during the lab periods. Appointments can be made for answering specific questions about concepts or about administrative issues with regard to grading.

Page 14: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

What is expected:

General questions should be asked during the lab periods whenever possible. Only questions that are very specific to a student or his/her program should be asked during office hours or by email.

Students should make every effort to debug their own programs – that’s the real learning process when it comes to programming.

Code should be properly documented.

Page 15: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

About programming assignments

It is assumed that everyone in the class understands Java sufficiently to track down and correct syntax errors.

Submissions that fail to compile may be given a zero without further consideration.

Lab assignments should be started soon enough to avoid problems near the due date.

Page 16: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Dropping this course

As many of you know, there is a university policy that allows students to re-take up to 3 classes and have their new grade substituted for their original one for GPA calculation.If after the first or second exam you feel that you are at significant risk of failing this course, you are in most cases better off dropping the class rather than failing before you re-take it.If you feel like you cannot drop the class because you will drop below full-time, come see me and I can suggest ways of dealing with that problem. If you feel overwhelmed and think that you may do badly in most of your classes, come see me.

Page 17: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Academic Dishonesty

When you turn in an exam or programming assignment, it is assumed to represent your individual effort.

Plagiarism can affect both your grade and your university standing.

Never distribute an electronic copy of your work on a programming assignment. If you work on a copy of your program on one of the computer lab machines, be sure to erase it from the local disk when you're done. Don’t throw away hardcopies of your program in the computer lab.

Page 18: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Special Needs

If you need accommodations because of a disability, if you have emergency information you need to share with the instructor, or if you need special arrangements in case the building must be evacuated, please inform the instructor immediately.

To request academic accommodations (for example, a note taker), students must also register with Disability Services, A038 Brady Commons, 882-4696. It is the campus office responsible for reviewing documents provided by students requesting academic accommodations and for accommodations planning in cooperation with students and instructors, as needed and consistent with course requirements. Another resource is MU’s Adaptive Computing Technology Center, 884-2828.

Page 19: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Short Quiz …

(1) The primary goal of CS-1050 was to teach Java. TRUE or FALSE?

Page 20: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

contd …

(1) The primary goal of CS-1050 was to teach Java. TRUE or FALSE?

FALSE

Page 21: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

contd …

(2)Which of the following statements is true?

(a) An algorithm is another name for a computerprogram.

(b) An algorithm consists of a series of instructionsin a particular programming language.

(c) None of the above are true.

Page 22: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

contd …

(2)Which of the following statements is true?

(a) An algorithm is another name for a computerprogram.

(b) An algorithm consists of a series of instructions in a particular programming language.

(c) None of the above are true.

Page 23: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

contd …

(3)Which of the following statements is true?

(a) Computer science and computer programmingare essentially the same thing.

(b) Computer programming is what computerscientists do.

(c) None of the above are true.

Page 24: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

contd …

3)Which of the following statements is true?

(a) Computer science and computer programmingare essentially the same thing.

(b) Computer programming is what computerscientists do.

(c) None of the above are true.

Saying that programming is what computer scientists do is like saying that word processing is what novelists do.

Page 25: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

What’s the difference ?

"How is developing an algorithm not the same as writing a program?“An algorithm defines the procedural steps for solving a given problem. Programming is the conversion of those steps into lines of code in some computer language.An assignment in 1050 typically describes an algorithm as part of the assignment description, so the assignment is purely a programming exercise.An assignment description in 2050 specifies what a program is supposed to do, but not the algorithm for doing it. The objective of the assignment is not to produce a working piece of code, but rather a good algorithm.

Page 26: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

What you should know from CS1050

1) How variables are used in computer programs.2) How if-else structures are used to implement decisions.3) How loop structures are used to repeat steps of an algorithm.4) How to apply the above knowledge to implement an algorithm.5) Some familiarity with interfaces and objects.

What isn’t so important are the details of a particular programming language, e.g., Java. Learning new programming languages should be relatively straightforward once the basic concepts of programming are understood.

Page 27: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Why CS 2050? A short story…

It was spring of 1999, and four friends were planning to attend interviews with companies that were visiting their campus.

Frank had just re-taken CS 1050 that semester, and he received an A. Carol, Joe, and Miguel had just completed CS 2050.

This was the peak of the dot-com era, and all four friends were immediately hired at different companies.

Page 28: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Coincidentally, it turns out that all four companies were bidding for the same contract from NASA.

The goal of the project was to create a system to allow companies to send requests for specified satellite

photos and have them sent electronically.

NASA funded each of the four companies to develop prototypes for evaluation. Based on the results of the evaluation, some subset of the companies would receive funding to continue development.

Page 29: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Frank's company, Icarus Industries, was desperate for the

NASA project, so the boss wined and dined the appropriate NASA managers, took them golfing, and

gave them Icarus Industries coffee mugs and mouse pads.

As long as Frank could produce a reasonably good prototype, the company would be in good shape to

make it to the next round of development.

Page 30: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Frank's team members were all hired at $100K each straight out of high school, so Frank's two semesters of CS-1050 made him the most experienced programmer.

Because of that experience, the boss of Icarus Industries

gave Frank the job of designing and implementing the critical search and retrieval component of the system.

This module would have to search a sample dataset of 1 million satellite images for the one with the specified I.D. number.

Page 31: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Frank decided that the problem was actually not too hard, it basically just required a simple loop:

for (i = 0; I < NumberOfImages; i++)

{

if (image[i].id == request.id)

requested_image = image[i];

}

return ( requested_image );

Page 32: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

After one day of working on the problem, Frank reported to his boss that he was almost done with his module.

The boss was impressed because he had heard that programmers at the competitor companies had barely even begun doing their algorithm designs.

Frank scoffed, "Gee, the algorithm is simple. Those guys must be a bunch of losers.“

The boss was very pleased with Frank's productivity, and he suggested that Frank devote his time to squeezing every bit of speed out of his code as possible.

Page 33: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Frank looked at his code and determined that there really wasn't much room for improvement, so he decided that the only way to speed it up was to try programming it in a different language.

for (i = 0; i<NumberOfImages; i++){

if (image[i].id == request.id)requested_image = image[i];

}return ( requested_image );

Page 34: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Frank had implemented his algorithm in Java, but hehad heard that C might improve performance.

Frank spent a couple of days learning C, and realizedthat it looked just like Java.

for (i = 0; i<NumberOfImages; i++){

if (image[i].id == request.id)requested_image = image[i];

}return ( requested_image );

Page 35: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

After re-coding his routine in C, Frank discovered thatthe system improved from being able to process 507requests per minute to being able to process 549 requestsper minute.

Frank informed his boss of the 8% improvement, andhis boss was impressed: "Wow, an 8% advantage overour competitors would clinch the project for us. Seewhat else you can do.“

Frank spent a few weeks studying assembler language.Unfortunately, he discovered that it didn't provide anyperformance improvement over his C implementation.

Page 36: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Frank was disappointed that the time he spent on animplementation in assembler language didn't yieldany improvements in speed.However, while looking at his code he suddenly hada brainstorm: He could terminate the loop as soon asthe requested image is found:

for (i = 0; i<NumberOfImages; i++){

if (image[i].id == request.id)return ( image[i] );

}

Page 37: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Frank realized that on average the requested imagewould be found after examining only half of theimages.

His test results revealed a speedup of 45%, whichdwarfed the 8% improvement he had obtained fromre-coding in C.

When Frank told his boss about the 45% improvementin speed, his boss immediately offered him a payraise and a move to a spacious corner office.

Page 38: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Based on the extensive code optimizations he had done,combined with his boss's cozy relationship with theNASA managers, Frank was sure that Icarus Industrieswould have no problem flying through the evaluationprocess.

Frank was looking forward to seeing the reactions ofCarol, Joe, and Miguel when they see how well theIcarus system performs compared to theirs.

Page 39: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

On Monday, NASA engineers received the prototypesdeveloped by the four competing companies. A batteryof tests had been developed, and the Icarus system wastested first.

On Tuesday, the results of the Icarus evaluation wereannounced: The Icarus system was able to processalmost 1000 requests per minute.

Frank smiled because that's exactly the level ofperformance that he expected. Frank's boss tookhim out to dinner to celebrate.

Page 40: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

On Wednesday, the results of the evaluation of Carol's system were announced: It was able to

process over 10,000 requests per minute.

Frank's system: 1000 rpmCarol's system: 10,000 rpm

Frank was shocked. It was impossible, he thought. There must be some sort of mistake. How could her program run ten times faster?

Page 41: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Frank caught Carol as she was leaving the NASAbuilding and asked her how she managed to makeher code so fast. He wondered if she had made useof some sort of special something in the operatingsystem.Carol wasn't sure why her code was ten times fasterthan Frank's, but Frank understood once she explainedher algorithm.Carol had realized that certain images were likely to berequested more often than others, so whenever an imagewas requested, her program moved it nearer to thebeginning of her array so that it would be found morequickly the next time.

Page 42: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Frank explained to his boss that Carol had come up witha really clever algorithm, but it sort of cheated because itmade use of the fact that different images are accessed atdifferent frequencies. Frank even suggested that in somesense the test wasn't fair.

Frank's boss said that the test was fair but that the results weren't necessarily disastrous. He reminded Frank that NASA planned to continue funding more than one of

the competitors, so there was still a good chance thatIcarus Industries could make it through to the nextround of development.

Page 43: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

On Thursday, the results of the evaluation of Joe'ssystem were announced: It was able to process over10 million requests per minute.

Frank's system: 1000 rpmCarol's system: 10,000 rpmJoe's system: 10,000,000 rpm

Frank was flabbergasted. This was truly impossible,he thought. Even if Joe had used the same algorithmas Carol and coded it in C, the performance shouldhave only been 8% faster than Carol's. Somethingwas definitely wrong.

Page 44: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Frank caught Joe outside of the NASA building andasked him how his code could be so fast.

Joe wasn't sure, but he said that he got his binary treecode out of his 2050 book. "Binary what?" asked Frank.

That night Frank read about binary trees and realizedwhy Joe's code was so fast: If the million image I.Dswere stored in the form of a binary tree, then therequested image could be found after checking onlyaround 20 I.Ds.

Frank felt sick.

Page 45: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

On Friday, the results of the evaluation of Miguel'ssystem were announced: It was able to process over100 million requests per minute.

Frank's system: 1000 rpmCarol's system: 10,000 rpmJoe's system: 10,000,000 rpmMiguel's system: 100,000,000 rpm

Frank couldn't believe it. He had spent so much timetrying to make his code as fast as possible, and in theend his code was 100,000 times slower than Miguel's.

Page 46: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Frank learned that Miguel had stored his images insomething called a hash table, but it didn't reallymatter: Icarus Industries was dead.

Frank went back to school, took CS-2050, andeventually realized that the difference betweenprogramming and algorithm design is analogousto the difference between drafting and architecturaldesign:

Having Frank design the retrieval algorithm forIcarus was like having a draftsman design theircorporate building.

Page 47: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

All four of the friends returned to school after the collapseof the dot-com bubble.

Although Frank had started out a semester behind histhree friends, the early demise of Icarus allowed him tofinish his degree before them.

Frank is now designing flight control algorithms for amajor aircraft manufacturer.

Page 48: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Morals of the story …

1) Knowing a programming language is not the samething as knowing how to program.

2) It is the algorithm that matters most, not the choiceof programming language or the fine details of acorrect implementation.

3) Without a background in algorithm design anddata structures, it is impossible for someone tounderstand why such experience is so critical.

4) Many safety-critical systems are only as reliableas the computer algorithms that support them.

Page 49: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

Other lessons …

1) Anyone who hires computer scientists needs tobe able to distinguish between someone who candevelop algorithms from someone who can onlydo simple coding tasks.

2) Anyone who manages a software developmentproject needs to be able to understand andassess the relative merits of different proposedalgorithms for solving a given problem.

3) A few bad programmers can wreck a company.

Page 50: CS 2050: Algorithm Design and Programming II (in Java) WELCOME !

People you should know:

Instructor : Anoop Haridas Office: EBW 347

Hours: M,W 2:30 – 3:30 pm. Email: [email protected].

Course webpage : Coming soon !