Sie sind auf Seite 1von 28

DATA STRUCTURES AND

ALGORITHMS(CSC-221)
Instructor: Engr. Naveera Sami
1) Basic Data Structures

2) Abstract Data types

LESSON 3) Representation of Algorithms


PLAN :
4) Efficiency

5) Arrays
6) Stacks

7) Queues

LESSON
8) Linked Lists
PLAN :
9) Graphs

10) Searching And Sorting


Credit Hours: 2+2
DATA
STRUCTUR
ES: Course material will be
uploaded on Dropbox
1) Within 10 mins after the start
of class, attendance will be taken.

2) Follow the Dress code from


RULES: Student Handbook

3) Use of Cell phones is PROHIBITED IN


CLASS
DATA STRUCTURES AND
ALGORITHM ANALYSIS BY
TEXT
MARK ALLEN WEISS 4TH
BOOK: EDITION (LATEST)
REFERENC HTTPS://WWW.CS.PRINCETON
E BOOK: .EDU/COURSES/ARCHIVE/SPR
11/COS217/LECTURES/08DSA
LG.PDF
DATA: is a set of values of qualitative
or quantitative variables
DATA
STRUCTUR
STRUCTURE: the arrangement of and
E: relations between the parts or
elements
Data structure is a particular way of
organizing data in a computer so that
DATA it can be used efficiently
STRUCTUR
E: Data structure is a particular way of
storing and organizing information in
a computer so that it can be retrieved
and used most productively.
Data structures are important for the
following reasons:

1. Data structures are used in almost every


program or software system.
NEED FOR
DATA 2. Specific data structures are essential
STRUCTUR ingredients of many efficient algorithms,
and make possible the management of huge
ES: amounts of data, such as large integrated
collection of databases.

3. Some programming languages emphasize


data structures, rather than algorithms, as
the key organizing factor in software design.
1. It contains data items that can be
elementary item, group item or another data
CHARACTERIS structure.
TICS OF DATA
STRUCTURES: 2. It has a set of operations that can be
performed on data items. Such as searching,
insertion etc.

3. It describes the rules of how the data items


are related to each other.
Many algorithms apply directly to a specific data
structures. When working with certain data
structures you need to know how to insert new
data, search for a specified item, and deleting a
specific item.
DATA
STRUCTUR Commonly used algorithms include are useful for:

E AND Searching for a particular data item (or record).

ALGORITH Sorting the data. There are many ways to sort


data.Simple sorting, Advanced sorting
MS: Iterating through all the items in a data
structure.(Visiting each item in turn so as to
display it or perform some other action on these
items)
Building data structures and algorithms requires
communicating instructions to a computer, and an
excellent way to perform such communication is
using a high-level computer language, such as C+
+.
Basic C++
Programm C++ evolved from the programming language C,
and has, over time, undergone further evolution
ing and development from its original definition.
Elements
It has incorporated many features that were not
part of C, such as symbolic constants, in-line
function substitution, reference types, parametric
polymorphism through templates, and exceptions
(which are discussed later).
C++ adds several enhancements over
C (which motivates the name C++),
with the principal enhancement being
the object-oriented concept of a class.
Basic C++
Programm A class is a user-defined type that
ing encapsulates many important
mechanisms such as guaranteed
Elements initialization, implicit type conversion,
control of memory management,
operator overloading, and
polymorphism.
A class also has the ability to hide
its underlying data. This allows a
class to conceal its implementation
details and allows users to
Basic C++ conceptualize the class in terms of
a well-defined interface.
Programm
ing Classes enable programmers to
Elements break an application up into small,
manageable pieces, or objects. The
resulting programs are easier to
understand and easier to maintain.
1) Encapsulation: Encapsulation is an Object Oriented
OBJECT Programming concept that binds together the data
and functions that manipulate the data, and that
ORIENTED keeps both safe from outside interference and
CONCEPTS: misuse. Data encapsulation led to the important OOP
concept ofdata hiding.
OBJECT Inheritance: Derive quality and characteristics from
ORIENTED parents or ancestors. Like you inherit features of your
parents.
CONCEPTS:
3) Polymorphism: The wordpolymorphismmeans
having many forms. Typically,polymorphism occurs
OBJECT when there is a hierarchy of classes and they are
related by inheritance.
ORIENTED C++ polymorphismmeans that a call to a member
CONCEPTS: function will cause a different function to be executed
depending on the type of object that invokes the
function.
PSEUDOCOD Pseudocodeis an informal high-level description of
the operating principle of a computer program or
E: other algorithm
1. Pre-conditions should always be enforced
2. Post-conditions represent the result of applying
PSEUDOCOD algorithm a to data structure d

E: 3. The type of parameters is inferred


4. All primitive language constructs are explicitly
begun and ended
If an algorithm has a return type it will often be
PSEUDOCOD presented in the post-condition, but where the return
type is sufficiently obvious it may be omitted for the
E sake of brevity.
Most algorithms in this book require parameters, and
because we assign no explicit type to those
parameters the type is inferred from the contexts in
which it is used, and the operations performed upon
it.
PSEUDOCOD Additionally, the name of the parameter usually acts
E: as the biggest clue to its type. For instance n is a
pseudo-name for a number and so you can assume
unless otherwise stated that n translates to an integer
that has the same number of bits as a WORD on a 32
bit machine, similarly l is a pseudo-name for a list
where a list is a resizeable array (e.g. a vector).
The last major point of reference is that we always
explicitly end a language construct.
For instance if we wish to close the scope of a for loop
we will explicitly state end for rather than leaving the
PSEUDOCOD interpretation of when scopes are closed to the
reader. While implicit scope closure works well in
E: simple code,in complex cases it can lead to
ambiguity.
The pseudocode style that we use within this book is
rather straightforward.
All algorithms start with a simple algorithm signature
1) algorithm AlgorithmName(arg1, arg2, ..., argN)
2) ...
n) end AlgorithmName
Immediately after the algorithm signature we list any
Pre or Post conditions.
1) algorithm AlgorithmName(n)
2) Pre: n is the value to compute the factorial of
3) n >= 0
4) Post: the factorial of n has been computed
5) // ...
n) end AlgorithmName
The example above des
The example above describes an algorithm by the
name of AlgorithmName, which takes a single
numeric parameter n. The pre and post conditions
follow the algorithm signature; you should always
enforce the pre-conditions of an algorithm when
porting them to your language of choice.
Normally what is listed as a pre-conidition is critical to
the algorithms operation. This may cover things like
the actual parameter not being null, or that the
collection passed in must contain at least n items.
The post-condition mainly describes the effect of the
algorithms operation.
An example of a post-condition might be
The list has been sorted in ascending order"

Das könnte Ihnen auch gefallen