Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 18

DATA STRUCTURES AND

ALGORITHM
RISHELLE L. LLANTO
AN OVERVIEW
This course begins with the identification
of the data and the operations needed to model
and solve a problem. The data are then
structured to represent relationships among
them. The resulting data structure is
manipulated to carry out the operations through
an algorithm.
ABSTRACT DATA TYPE
Computational problems deal with a variety
of data and the operations on these data. Data are
the information gathered to express knowledge
about a world or an environment. They are
manipulated by operations to discuss, explain, and
calculate things about this environment.
An abstract data type(ADT) is a model or
description of a type of data. It identifies the
components and properties of a type of data, as
well as the operations performed on the data of
this type.
3 STAGES OF ADT
• Specification – this is an identification of the data’s components,
properties, relationships among its components, and the
operations performed on the data in a problem. It only identifies
what involved in the problem and not how to solve the problem.
• Representation – this is a design on how to store instances of
the ADT. This design aims to show relationships among the
components of the data in storage. The result is called a data
structure. This design often uses or builds upon primitive data
types or predefined data structures available in a programming
environment.
• Implementation – this is a procedural description of how each
operation is carried out using the data structure. Each
procedural description is an algorithm. Algorithms can be
written using pseudocode or a specific programming language.
An ADT is specified from the point of view of
the user. Its representation and implementation are
decided by the person implementing the ADT.

For Example:
Consider the problem of determining the
topnotcher in a class. The ADT specification can
consist of a list of n students arranged
alphabetically, their average grades, and the
operation of determining the student with the
higher average grade.
ADTs can be implemented in many kinds of
programming languages. However, object-
oriented programming languages such as C++
and Java are the most suitable. ADT are naturally
implemented as classes.
ADTs model sets of data. Some sets of data
are static, they change infrequently or do not
change at all. These include the letters of the
English alphabet, the books in the Bible and the
months in a calendar year. However, some sets are
dynamic. Enrolled students in a class, available
merchandise in a store, and free memory space are
some examples. Sets with dynamic data must be
able to support addition and deletion of elements
and changes of information in its elements.
The relationships among the data, the way
data are processed, and the method data items
are added, deleted, and changed must be
considered when modeling dynamic sets of data
as abstract data types. These ADTs include
stacks, queues, linked lists, trees, graph, and
hash tables.
DATA STRUCTURES
Data structures show relationships among
the data items using primitive structures or
other data structures available in a
programming environment to facilitate
operations of the ADTs.
The design of the data structure is very
important. It dictates how much space is
required to store the ADT. It directly influences
the efficiency of the algorithms that use them.
Data structures are programmed using features of
programming languages. Simple data structures are
programmed using primitive data types while complex
data structures use composite or user-defined data types.
A programming language can provide primitive
data types like Boolean, integer, character and float.
These are data structures of abstract data types. The
programming language imposes policies on how
instances of each data type are stored and accessed in
memory. The programming language may also provide
composite data types such as arrays, strings, structs, and
classes.
ALGORITHM
A computational problem is solved by performing a
finite set of instructions called an algorithm. An algorithm
is a well-defined procedure that processed input values to
generate desired output values to solve a problem. The
input, output and intermediate computations are
represented with the use of data structures.
There was an astronomer and mathematician
named Abu Ja’Far Muhammad ibn Musa al-Khwarizmi
from 780-850A.D. who wrote books including procedures
of performing mathematical operations discovered by
Europeans denoted from his name and call it
“algorithm”.
PROPERTIES OF GOOD ALGORITHM
• Has input – has instance of the problem to be solved.
• Has output – produce results to solve the given instance of the problem
• Definite – each step is unambiguous. There is only one way to interpret
each step that is precisely specified
• Effective – each step executes as expected in a finite amount of time.
• Finite – terminated after producing the output in a finite number of
steps.
• Correct – produces the desired output corresponding to the given input
• General – correctly solves the problem for all valid problem instances
• Efficient – solves the problem with less resources such as time and
space.
An algorithm can be expressed using a natural
language such as English. Most recipe steps in cookbooks
are often written in English. However, natural languages
have ambiguities. Efforts to remove ambiguities result in
rambling sentences. An algorithm may also be described
and implemented using programming languages such as
C. The resulting programming statements are very
precise. However, they must adhere to very strict syntax
and semantics which are technical and sometimes hard to
read. It can be difficult to determine what they are trying
to accomplish when simply looking at the code.
An algorithm is often written in
pseudocode before it is implemented in a
specific programming language. Pseudocodes
combine English with basic programming
language constructs. They employ whatever
method is expressive, clear and concise. They
allow a narrative-like but well-defined
description of the steps. Pseudocodes focus on
solving problem. Thus, error handling is often
simplified or ignored.
Algorithms are then combined to form
bigger algorithms. An algorithm may invoke one
or more predefined algorithms to perform a
subtask or to solve a subproblem. Data
structures, together with algorithms, form
programs. Algorithms are implemented as
methods or procedures in a programming
language.
SET
SET is a collection of different things
(distinguishable/distinct objects) represented as
a unit. The objects in a set are called elements
or members. If an object x is a member of a set
S, we write x ϵ S. On the other hand, if x not a
member of S, we write x ϵ S. a set cannot
contain the same object more than once, and its
elements are not ordered.
Set Cardinality
The number of elements in a set is called
Cardinality or Size of the Set, denoted as |S| or
sometimes n(S).

S = ϵ(1,2,3,4,5,6)
|S| = 6
Subset

You might also like