# CS245 Data Structures and Algorithms

Last updated: January 21, 2007

Spring 2007
Monday and Wednesday: 9:40-11:25pm HRN 530 (mac lab)

Instructor: Terence Parr

Office hours: MTWR 1-3pm, any time door is open, or by appointment
TA: ?
Final exam: 3:30pm May 14, 2007

## Abstract

The purpose of this course is to teach you about data structures and algorithms that operate on them. You will learn the mathematical tools necessary to evaluate the time and space requirements of various algorithms. There will be a mixture of theory and practical implementation during this course. Data structures and algorithms are the foundation upon which we build all software.

## Student Learning Outcomes

At the end of this course, the student will have the following skills and knowledge.

• be able to build all of the common data structures.
• be able to analyze the time and space complexity for many common algorithms.
• be able to compare and contrast two data structures.
• be familiar with the common sorting algorithms
• be comfortable with recursive algorithms.

## Syllabus

We will cover the following topics, time permitting:

Analysis of Algorithms

• Rate of growth: O(n), o(n), Omega(n), omega(n), Theta(n)
• Time vs. Space

Lists, Stacks, Queues

Trees

• Binary
• Search trees
• Heaps
• Huffman coding
• AVL trees

Sorting

• Insertion Sort / Selection Sort
• Merge Sort / Quicksort
• Heapsort
• Bucket Sort

Hash tables

• Hash functions, open/closed hashing
• Perfect hashing, alternative implementations

Graphs

• Dijkstra's Algorithm
• Minimum spanning trees
• Depth first search
• Traveling salesman
• Longest common substring?

Dynamic programming

Find element

## Worksheets

How fast does rain fall?

## Projects

Project 1 -- Lists (Due Feb 12)
Project 2 -- Hashtables (Due Mar 5)
Project 3 -- Expression Tree Interpretation and Compilation (Due Mar 26)
Project 4 -- Graphs (Due Apr 16)
Project 5 (Due May 7)

There are no late projects.

I will deduct 10% if your program is not executable exactly in the fashion mentioned in the project; that is, class name and jar must be exactly right. For you PC folks, note that case is significant for class names and file names on linux! All projects will be graded and must run under linux.

## Instruction Format

Class periods of 1hr 45min each in 15 weeks. Class will often be broken down into lectures (often followed by a lab) with a 10 minute break in between to service coffee and/or junk food requirements. Instructor-student interaction during lecture is encouraged and discussion groups will be formed to solve problems and debate programming philosophy. "Pop quizzes" may appear during any class, usually at the beginning.

 10% Labs/Quizzes/Class participation 15% Exam 1 15% Exam 2 10% Homework 50% Projects (10% each)

Please note that class participation is part of your grade. You must learn to interact with other developers and come up with solutions.

In general, I will read all papers, projects, quizzes etc... two times. Once to evaluate the average and a second time to assign scores. In the first pass, I also come up with a scoring strategy for each question.

I consider an "A" grade to be above and beyond what most students have achieved. A "B" grade is an average grade or what you could call "competence" in a business setting. A "C" grade means that you either did not or could not put forth the effort to achieve competence. An "F" grade implies you did very little work or had great difficulty with the class compared to other students.

Unless you are sick or have a family emergency, I will not change deadlines for projects nor exam times. For example, I will not giveyou a special final exam just because you want to fly home early. Consult the university academic calendar before making travel plans.

## Book

Clifford A. Shaffer: A Practical Introduction to Data Structures and Algorithm Analysis, Java Edition 1/e ISBN 0-13-660911-2

## CS245 Mailing List

To post, email cs245@cs.usfca.edu.

## Miscellaneous

Attendance is part of your grade. Even if you know this subject well, I will be providing a number of anecdotes from industry and other goodies during my lectures. Anything I say in class is fair game for an exam. Tardiness. All classes begin precisely at 9:40pm and will restart after the 10 minute break exactly on time.

Academic honesty. You must abide by the copyright laws of the United States and academic honesty policies of USF. If told you may for a particular project, use any code from the net that you find as long as it does not violate the software's license. You may not borrow code from other current or previous students. All suspicious activity will be investigated and, if warranted, passed to the Dean of Sciences for action.

From Professor Brooks' page on collaboration:

Collaboration: In general, I expect students to behave responsibly and do their own work. I'm willing to assume this is the case until proven wrong. More specifically, it is OK to talk with each other about the general parameters or approach of the assignment. It is NOT OK to share source code, to do part of an assignment for another person, or to directly copy another person't work. If you are unsure as to whether something is considered fair game or not, please ask me and we can discuss it.

A few examples: "On question 4, are we supposed to implement a priority queue using a heap?" This is fine; it's a clarification of the assignment. Feel free to talk about this sort of thing with your classmates.

"I don't understand how big-O works! Can you explain it to me?" Also fine; you're talking about the course material generally; I think students should help each other with this sort of thing - you're great resources for each other.

"Question 3 is really hard. How did you do it?" Now we're getting into a gray area. If you're talking in generalities here ("I broke the problem into three cases and solved each case separately") that's fine; you're not telling the other person exactly how to do the assignment, you're just discussing approaches. If you're talking specifics ("Here's the code for tree traversal.") then we're moving into unacceptable territory. The question to ask is: does the person I'm talking to still need to think for themselves in order to solve the problem, or have I just given them the entire answer? I strongly recommend erring on the conservative side here; if you're unsure whether you're sharing too much, tell the question-asker that they should talk to me. I'm always happy to help people with problems.

"Can I just look at/use/copy your code?" Definitely not acceptable. Keep in mind that both participants are cheating here; the person who is copying and the person who is allowing their friends to copy. Students that I feel are cheating in this manner (this is cheating) will not be treated nicely.

Also note that using code that you get off the web, from a friend, etc. and turning it in as your own is considered plagiarism, just as if you did it in a paper. This will result in (at least) a zero for that assignment. This includes 'finding' code in the trash, or using your friend's code as a template. Let me make it very clear that it is very easy to detect this sort of cheating (there is software to do it) and, if you are suspected of this sort of activity, the burden of proof will be on you to prove that you did not cheat. The best way to avoid trouble is to write your own programs by yourself, and not to share your code with others.