These notes are for CSCI 2530, Introduction to Data Structures. Please see the course syllabus for details about the course and how you will be graded.
Here are some important points from the syllabus concerning programming assignments.
I expect you to test your software. If your software does not compile without errors, you cannot have tested it even once. Therefore, a submission that does not compile without errors will get a grade of 0, regardless of how close it is to compiling without errors. It is not my responsibility to fix errors in your software.
Teamwork is important, and there will be opportunities for you to work in teams in later courses. But teams are only effective when everyone on the team is competent and can contribute without constant supervision. That competence needs to be learned by working alone. You are expected to do your own work in this course.
Putting your name on someone else's work is plagiarism. Putting your name on work that is half yours and half somebody else's is plagiarism. If I believe that your work is plagiarized, you will receive a grade of −50% for that assignment. If the assignment is worth 300 points, your grade will be −150. Remember that you are expected to do your own work. If two students submit work that could not possibly have been written independently, I will consider both submissions to be plagiarized.
You can appeal that decision if you believe that you worked alone. Just come to my office and talk to me about it.
By the way, getting something from the internet and slapping your name on it is a very bad idea. I have Google too. You are better off not submitting an assignment than resorting to plagiarism.
There are some courses where you will receive at least a C just for showing up to class every day. This is not one of those courses. Historically, the DFW (D, F or withdraw) rate in this course has been near 50%. If that trend continues, only about half of you will pass with a C or better. What can you do to improve your chances?
Start early on programming assignments, and plan on finishing early. Students who start and finish early will give themselves a good chance to do well in this course. Students who habitually start late on assignments should give serious consideration to dropping this course now.
If you get stuck, do not give up. Ask questions. Give yourself time to ask questions by starting early and trying to finish early.
Attend class. If you find yourself confused, don't stop coming to class. Ask questions. Come to office hours. There are also tutors available at the Pirate Academic Success Center. If you find yourself not attending class, drop this course.
The key to learning anything is repetition. Read the notes. Work the exercises in the notes. After a few days or a week, reread the notes. You will get as much from a second reading as from the first reading. If you do not like to read and figure you will just attend class, drop this course right away.
This course is broken into three parts.
Part 1: Elementary C++ and fundamentals of software development
Elementary C++ is very similar to Java. (C++ was introduced in the 1980s and Java was introduced in the 1990s. Java was designed to look like C++ in many respects.)
This is not a course on C++, and we will make no attempt to cover all of C++. Our goal is to cover only as much of C++ as we need in order to cover data structures and algorithms.
This is not a course on object-oriented programming, and we will not use the object-oriented features of C++. Object-oriented programming is covered in the course that comes after this one, CSCI 2540.
Most students come into this course with a novice's ability to design and implement computer programs. That is not your fault. It is just the way things are. Even students with an unusually high amount of experience tend not to have been adequately taught how to develop software. A novice's approach is adequate for very small computer programs, but utterly fails for the kinds of software that you will produce in this course.
I have found that it is senseless to teach data structures and algorithms without also covering fundamental methods of software development, since without studying that students are not prepared to solve the programming assignments. Therefore, an important component of this course is how to design software in an organized and disciplined way.
You will need to resolve to put what we cover into practice. Each student has a discipline adoption delay, the number of failures to solve an assignment it takes before the student makes a commitment to using discipline. Students with a short discipline adoption delay usually do well in this course. Those with a long discipline adoption delay can expect to do poorly.
Part 2. The memory and memory addresses
A computer processor works at the machine language level, performing simple instructions one after another. But very few people write software directly in machine language. There is too much detail to keep track of.
Much of the application programming work that you do in other courses or in workplace environments is done in higher level languages, such as Java, that are two levels above machine language. They hide a lot of the details of how computers work from view, making the programmer's task more logical. They cover over some pitfalls. Most of those languages offer error checking to help you find and fix errors.
Most system programming is done in languages such as C that are just one level above machine language. Some of the uglier details of machine language are taken out of your hands, but the actual nature of the processor and memory are exposed for you to exploit as you see fit. Software for small computers, including for game consoles, as well as software that needs to work very efficiently, is frequently written at this level since it allows more efficient use of time and memory resources.
Because it treats the memory in the foreground rather than in the background, C is suitable for developing an understanding of data structures. You will see fundamental ideas of data structures without a lot of machinery between you and the data structures that obscure what is going on.
C++ is an extension of C. We will stay mainly in the C subset, using just a few features of C++.
Part 3. Fundamental data structures and algorithms
Data structures and algorithms are so closely intertwined that it is difficult to study one without the other. We will concentrate on a few fundamental data structures, including the following.
There is another aspect of data structures called data abstraction, which is concerned with how to package data structures up so that they are easy to use. We will cover the most fundamental idea of data abstraction, abstract data types. CSCI 2540 covers more on data abstraction.
Different instructors often take different approaches to teaching the same course. Here are some of the guiding principles that I use in this course.
Most programming languages have libraries, collections of tools that ease software construction. For example, Java has an extensive library it calls the Java Application Program Interface, or API. (In fact, Java has more than one API.) C++ has the Standard Template Library (STL). Some instructors concentrate on how to use a library.
For this course, I prefer to take a do-it-yourself approach. We will use a few small libraries, but will not use the STL except for a tiny part of it. (Type string is part of the STL, and we will not use it.) Here are some of my reasons for that.
If you concentrate on learning how to use a library, you find that the library becomes a crutch. If you need to do something that the library does not provide for, you are at a loss for how to proceed.
Here is a true anecdote to help make the point.
I once had a student
doing some programming work for me. I asked him to write a
small module to carry out a clearly specified task. A week later,
he came back to me and said that he had scoured the library,
and could not find a tool that performed that task. He
suggested that we wait for the next release of the library,
since it might have the tool that I asked him to create.
Really!
|
Students who learn in a do-it-yourself environment can easily adapt to using a library.
The principles of do-it-yourself computer programming are well established and have a long shelf life. Libraries, on the other hand, are constantly changing. Effort put into learning a library will need to be repeated every few years. Operating systems for small devices such as smart phones and tablet computers currently have APIs that change frequently. You study one of those APIs because you want to use it now.
You cannot fully appreciate data structures and algorithms without building them yourself.
There is a collection of coding standards for this course that everyone is expected to follow in all submitted work. Some of the standards are intended to help you avoid pitfalls that can lead to extra work time. Some of the standards are there to make programs easier to understand without the need to reverse-engineer them, and to make submissions easier for me to grade.
If you fail to follow the coding standards in your submitted work, you will lose points, the amount depending on which standards you violated and on to what extent you violated them.
Each assignment is designed to focus on a particular set of competencies. Some of the standards ensure that you do not work around what an assignment is intended to get you to do. If you ignore the requirements stated in a programming assignment, you can get a score of 0. Read each assignment all the way through and follow the instructions.
You are not required to follow the coding standards on exams. There is more leniency there.
Everybody makes mistakes. You can be sure that you will make a lot of mistakes writing computer software. Everybody does. I prefer to have an atmosphere where everyone accepts that, and where there is no stigma associated with making a mistake. Just let it wash off you like water off the back of a duck.
The key is, when you make a mistake, try to fix it. Ways to fix mistakes fall under the heading of software development and implementation principles, and we will see several important techniques.
Not all students will be happy with how I teach this course. Some of you have learned a different way of doing things, and will resent me for telling you to do things my way. Some of you will be annoyed when I point out your mistakes.
But I cannot have a separate course philosophy for each student. Therefore, the coding standards apply to all, even to those who don't like them. You will need to learn to follow the instructions for programming assignments, even if you prefer to do something else.
It is crucial for you to read the notes, either before or after each lecture. Just be sure that you keep up with the course. Students who do not read the notes will do poorly in this course. When reading these notes:
But reading the notes is not enough. It is essential that you work the exercises. You can no more learn to write software just by reading about it than you can learn to ride a bicycle by watching movies of other people riding. Students who do not work the exercises in the notes will do poorly in this course.
Repetition is crucial for learning anything well. Go back and review sections that you read earlier. You will get a lot out of a second reading. (Did you notice that this is a repetition of something said earlier on this page?)
What score do you receive on an assignment that does not compile without fatal errors? Answer
What grade do you get if you submit a plagiarized assignment? Answer
What grade do you get if you work with a friend and you both submit the same thing? Answer
If a friend is having trouble with an assignment, should you share your solution with him/her just to give him/her an idea of how to proceed? Answer
What should you do if you get stuck and cannot make progress? Answer
Can you use the C++ Standard Template Library in this course? Answer
Who is required to follow the coding standards? Answer
If you think that you can improve on an assignment, should you do that for extra credit? Answer