Download CS 110 Introduction to computer programming

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Stream processing wikipedia , lookup

Multidimensional empirical mode decomposition wikipedia , lookup

Data-intensive computing wikipedia , lookup

Abstraction (computer science) wikipedia , lookup

K-nearest neighbors algorithm wikipedia , lookup

Corecursion wikipedia , lookup

Transcript
CS 311
Data Structures
1
Instructor
Name : Vana Doufexi
 Office : 2-229, Ford Building
 Email : [email protected]
 Office hours: By appointment (email me)

2
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
3
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)
4
Problem Solving

Problem solving =
– Understanding the problem
– Designing a solution
– Implementing the solution

What exactly is a solution?
5
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).
6
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.
7
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

8
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.
9
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.
10
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.
11
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.
12
Data organization

Example: An indexed-list ADT.
– DATA:
Make it more
abstract by not
assuming a type
• An indexed sequence of items of some type
Make it more abstract
• The lower index by not assuming it's 0
• 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
Note that there is no mention of how this might be implemented. 13