130 likes | 204 Views
CS 311 Data Structures. Instructor. Name : Vana Doufexi Office : 2-229, Ford Building Email : vdoufexi@cs.northwestern.edu Office hours: By appointment (email me). Resources. class webpage : http://www.cs.northwestern.edu/academics/courses/311 Use it to
E N D
Instructor • Name : Vana Doufexi • Office : 2-229, Ford Building • Email : vdoufexi@cs.northwestern.edu • Office hours: By appointment (email me)
Resources • class webpage : http://www.cs.northwestern.edu/academics/courses/311 • Use it to • download class notes, handouts and assignments • look up your grades • access online tutorials and references • look up course policies on • grading • late homework • collaboration
Resources • class newsgroup : • The class newsgroup is cs.311 at news.cs.northwestern.edu • Use it to • discuss class material, • discuss the assignments (but NEVER post solutions)
Problem Solving • Problem solving = • Understanding the problem • Designing a solution • Implementing the solution • What exactly is a solution?
Problem Solving • An algorithm is a computational method for solving a problem. • It is a sequence of steps that take us from the input to the output. • An algorithm must be • Correct • It should provide a correct solution according to the specifications. • Finite • It should terminate. • General • It should work for every instance of a problem • Efficient • It should use few resources (such as time or memory).
Problem Solving • Any algorithm we come up with will have to manipulate data in some way • The way we choose to organize our data directly affects the efficiency of our algorithm • Solution = algorithm + data organization • Both components are strongly interconnected.
What this class is about • Classic data structures. • Design, implementation and use • How to choose or devise the appropriate data structures for a problem. • Classic algorithms and how the choice of data structure affects their efficiency. • More C++ programming experience. • Programming in the Linux/Unix environment
Problem Solving • Key characteristic: Abstraction • Oftentimes, different real-world problems can be modeled using the same underlying idea • Examples: Runtime storage, Undo operation.In both cases we have a sequence of data items (activation records, actions) and we can only add and remove items from one end of the sequence. • We can design a data organization scheme that retains the general characteristics of this "data and operations" model (without any dependences on the type of data or method of implementation). • This is called data abstraction. • Big advantage: code reuse. We can use the same scheme for both problems.
Problem Solving • Key characteristic: Encapsulation • The way the data is organized and the operations that can be performed on it are implemented should be hidden. • Its properties are separated from the implementation • Data can be manipulated in a controlled way, only through an interface. The internal details are hidden. • In-class example: library reserve desk • This is called encapsulation. • Big advantage: The code has higher maintainability. The internal organization/implementation can be modified/improved without changing the interface. • Big advantage: Outside objects cannot interfere with the internal organization, inadvertently corrupting it.
Problem Solving • Key characteristic: Information hiding • A solution typically consists of different modules that interact with one another. • Information hiding is the idea of concealing details from other modules that do not need to know those details.
Data organization • Major components: • The data • The operations allowed on it • These make up an Abstract Data Type • A Data Structure is a construct that implements a particular ADT. • Example: An indexed-list ADT.
Data organization Make it more abstract by not assuming a type • Example: An indexed-list ADT. • DATA: • An indexed sequence of items of some type • The lower index • The upper index • OPERATIONS: • Access item at position (index) i • Add an item at position i • Remove an item at position i • Change the bounds Make it more abstract by not assuming it's 0 Note that there is no mention of how this might be implemented.