meljun cortes algorithm review of data structures

25
Review of Data Structures Design and Analysis of Algorithms * Property of STI Page 1 of 25 Definition of Data Structure Common data structures used in algorithm design. Linear Data Structure Graph Data Structure Trees Data Structure

Upload: meljun-cortes-mbampa

Post on 17-Jul-2016

220 views

Category:

Documents


3 download

DESCRIPTION

Meljun Cortes Algorithm Review of Data Structures

TRANSCRIPT

Page 1: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 1 of 25

Definition of Data Structure

Common data structures used in algorithm

design.

Linear Data Structure

Graph Data Structure

Trees Data Structure

Page 2: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 2 of 25

way of organizing the data considering not only the

items stored but also their relationship from each

other

a combination of elements each of which is either

a data type or another data structure

Page 3: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 3 of 25

a set of associations or relationships

involving the combined elements of:

Atomic data

• data you choose to consider as a single, non-

decomposable entity

– int, floating points, and char

Composite data

• can be broken out into subfields that have

meaning

– Telephone number : 0 63 2 2475000

Data type

• a set of data and the operations that can be

performed on the data

Structure

• a set of rules that hold the data together

Page 4: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 4 of 25

Linear Data Structure

Graphs Data Structure

Trees Data Structure

Page 5: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 5 of 25

represented by a list in which each element

has a unique successor

two most common list data structures:

array

linked list

Page 6: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 6 of 25

Array

a data structure that may contain fixed

number of components all of the same data

type

individual variables in the array are called

elements of the array that can be accessed

through an index

• Index

– also called a subscript of the array that

references the location of the variable relative

to the first element of the array.

Page 7: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 7 of 25

Application using array data structure:

manipulation of sting

• Strings are important for:

– processing textual data

– defining computer languages

– compiling programs

– studying abstract computational models

Array of

characters

Array of

jackets

Page 8: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 8 of 25

Limitations of array data structure:

size has to be known at compilation time

data in the array are separated in computer

memory by the same distance which means

that inserting an item inside the array requires

shifting other data

Page 9: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 9 of 25

Linked List

an ordered collection of data in which each

element contains the location of the next

element. The element in a linked list is called

a node.

data

holds the useful information

the data to be processed

link (pointer)

used to chain the data to be processed

contains a pointer that identifies the next

element in the list

Page 10: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 10 of 25

Types of Linked List

Singly Linked List

• each node, except the last node, contains a

single pointer to the next element

Doubly Linked List

• every node, except for the first and last,

contains pointers to both its successor and its

predecessor

Page 11: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 11 of 25

Types of Linked List

Circularly Linked List

• the last node’s link points to the first node of

the list

Page 12: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 12 of 25

Special Types of List

Stack

• a linear list in which all addition and deletions

are restricted to one end

• uses the LIFO (Last in, First out) algorithm

Page 13: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 13 of 25

Special Types of List

Stack

• Stack Operations

– Push

– Pop

Queue

• a linear list in which data can be inserted at

one end, called the rear, and deleted from the

other end, called front

• uses the FIFO (First in, First out) algorithm

Stack of book

Page 14: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 14 of 25

Special Types of List

Queue

• Queue Operations

– Enqueue

– Dequeue

Page 15: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 15 of 25

a collection of nodes and line segments

Types of Graph Data Structure:

Directed Graph (Digraph)

• each line has a direction to its successor

• lines are called arcs

• the flow along the arcs between two vertices

can follow only the indicated direction

Page 16: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 16 of 25

Types of Graph Data Structure:

Undirected Graph

• no direction in any of the lines

• the flow between two vertices can go in either

direction

Page 17: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 17 of 25

Graph Representation

Adjacency matrix

• graph with n vertices is an n by n Boolean

matrix with one row and one column for each of

the graphs vertices

Adjacency list

• contains all the vertices adjacent to the vertex

in a graph, an edge directly connects them

Page 18: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 18 of 25

Adjacency matrix representation:

Page 19: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 19 of 25

Adjacency list representation:

Page 20: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 20 of 25

Path

a sequence of vertices in which each variety is

adjacent to the next one

• {A, C, D}

• {A, B, C ,D}

Cycle

A sequence of vertices in which each variety

is adjacent to the next one but should start

and end with same vertex

• {A, B ,C, A}

Page 21: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 21 of 25

Tree data structure

Nodes

• a finite set of elements

Branches

• and a finite set of directed lines

Trees Terminologies:

Degree

• number of branches associated with a node

Indegree

• branch directed toward the node

Outdegree

• branch directed away from the node

Root

• first node of the tree provided that the tree is

not empty

Leaf

• any node with an outdegree of zero

Page 22: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 22 of 25

Trees Terminologies Continuation

Internal node

• node that is not a root or a leaf because it is

found at the middle portion of a tree

Parent node

• node with successor nodes

Child node

• node with a predecessor

Sibling

• node with the same parent

Ancestor

• node in the path from the root to the node

Descendent

• any node in the path below the parent node.

Path

• sequence of nodes in which each node is

adjacent to the next one

Level

• node’s distance from the root.

Page 23: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 23 of 25

Trees Terminologies Continuation:

Height

• level of the leaf in the longest path from the

root plus 1

Subtree

• connected structure below the root

Parent nodes: A, B, F

Children nodes: B, C, D, E, F, G, H

Sibling nodes: {B,E, F} , {C,D}, {G,H}

Leaf nodes: C, D, G, H

Internal nodes: B, F

Page 24: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 24 of 25

Types of tree data structure

General tree

Binary tree

Binary search tree

AVL (Adelson-Velskii Landis) tree

Heap tree

Page 25: Meljun Cortes Algorithm Review of Data Structures

Review of Data Structures

Design and Analysis of Algorithms

* Property of STI

Page 25 of 25

Research for the following:

Definition of algorithm analysis

Definition of different asymptotic notations

o Big-O notation

o Big-Omega notation

o Bi-Theta notation

Basic efficiency classes for algorithm

analysis

Note: The research work should be in a printed

copy compiled in a folder with a title page.