0% found this document useful (0 votes)
17 views

Lecture 1

Database Notes leacture 1

Uploaded by

Hassan ali Sayed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Lecture 1

Database Notes leacture 1

Uploaded by

Hassan ali Sayed
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 21

Design and Analysis of Algorithms

Dr. Shamshad
Lakho

1
Books
Thomas H. Corman, Charles E. Leiserson,
Ronald L. Rivest and Clifford Stein,
“Introduction to Algorithms”, Latest Edition.
Jon Kleinberg, Eva Tardos, “Algorithm
Design”, Latest Edition.
Robert Sedgewick, Kevin Wayne,
“Algorithms”, Latest Edition.
Course Outline
Data Structure (Recap)
Introduction of Algorithms and its notation
Basics algorithms and its analysis
Asymptotic notations
Recursion and recurrence relations
Divide-and-conquer approach
Sorting; Search trees
Hashing

3
Course Outline (Cont !!!)
Binary Search Tree
Graph algorithms; Shortest paths; Network
flow; Disjoint Sets; Polynomial and matrix
calculations;
Greedy approach
Dynamic programming
String matching algorithms
Amortized analysis
NP complete problems

4
Design and Analysis of
Algorithms
An Algorithm is a sequence of steps to solve a
problem.
Design and Analysis of Algorithm is very
important for designing algorithm to solve
different types of problems in the branch of
computer science and information technology.

Prerequisites for the Course


Basic knowledge of programming and
mathematics
Knowledge of data structures and algorithms

5
Data Structure Recap

6
Algorithm
An algorithm is a set of steps of operations to
solve a problem performing calculation, data
processing, and automated reasoning tasks.
An algorithm is an efficient method that can be
expressed within finite amount of time and space.
An algorithm is the best way to represent the
solution of a particular problem in a very simple
and efficient way.
If we have an algorithm for a specific problem,
then we can implement it in any programming
language, meaning that the algorithm is
independent from any programming languages.
Algorithm Design
 The important aspects of algorithm design include
creating an efficient algorithm to solve a problem in
an efficient way using minimum time and space.
 To solve a problem, different approaches can be
followed. Some of them can be efficient with respect
to time consumption, whereas other approaches may
be memory efficient.
 However, one has to keep in mind that both time
consumption and memory usage cannot be optimized
simultaneously.
 If we require an algorithm to run in lesser time, we
have to invest in more memory and if we require an
algorithm to run with lesser memory, we need to have
more time.
Data Structure Recap

The term data refer to collection of facts or


figures
There are two ways to process and
manipulate data.
Data Structure
 Refer to temporary and manipulation of data
 E.g. Variables and array of a procedural language
Database
 Refer to Permanent storage and manipulation of data
 E.g. MS Access, Foxpro etc
Data structure is way to process and manipulate
data through set of operations

9
Data Structure Recap

Consider following C language


program
Execute first time:
Output will 8
Main()
{
int a, b, c;
Execute second and
a=3;
other times.
b=5 Again Output will 8
// OR cin>>a>>b;
c=a+b;
cout<<“Sum=“<<c;
} What concluded here
10
Data Structure Recap

Type of Data Structures according to the


presentation of data (i.e. How data is
presented)
1.Linear Data Structure
1. Sequential Data Structures
1. Array
2. Queue
3. Stack
2. Pointer Data Structure (Linked List)
2.Non Linear Data Structure
1. Tree
2. Graphs

11
Data Structure Recap

Type of Data Structures according to memory


representation
1.Logical Data Structure
1. Map data according to partition structure of memory
2. E.g. One Dimensional Array
2.Physical Data Structures
1. Can not map data easily according to partition structure
of memory
2. E.g Two Dimensional Array, Tree etc
3. A special method is needed to convert physical Data
Structure into Logical, such as dope vector is used to
convert 2-D into 1-D.

12
Data Structure Recap

Common operation for all Data Structure are.


 Insert ( Insert new item/element into a data structure)
 Delete (Remove an item from Data Structure)
 Sort (Use to arrange all items in either ascending or
descending order)
 Search (Use to locate an element/item of a data
structure)
 Merge (Use to combine the elements of more than one
similarly data structure
 Traversing (Scanning or visit of each element for view
etc)

13
Data Structure Recap

 Array
 Linear and sequential
 Array is combination of homogenous element with
 N Consecutive index numbers (Such as 1,2,3,4, . . .)
 Successive memory location (such as 102, 104, 106 . . . )
 Successive memory location depend on the size of data types,
such as in C language size of integer data type is 2 bytes)
 Two types of array are commonly used.
 One Dimensional (1-D) ( Only logical data structure)
 Two Dimensional (2-D) (Physical Data structure)
 Dope Vector method is used to convert 2-D into 1-D

14
Data Structure Recap

 Stack Data Structure


 Linear and sequential
 Work on following principles
 LIFO (Last In First Out) OR Total
 FILO (First In Last Out) Size=
 Two Conditions are N=5
 Overflow (It will occur when stack is full and you try to insert new
element)
 Underflow (It will occur when stack is empty and you try to delete an
element)

Two Operations:
 Push (to insert an element into a stack, top++)
 Pop (to delete an element from a stack, top--)

15
Data Structure Recap
 Queue Data Structure
 Linear and sequential
 Work on following principles
 FIFO (First In First Out) OR
 LILO (Last In Last Out)
 Two Conditions are
 Overflow (It will occur when Queue is full and you try to insert new element) when
rear=N
 Underflow (It will occur when Queue is empty and you try to delete an element)
when front=0/-1
 Type of Queues are
 Circular Queue
 Priority Queue
 Double Ended Queue

16
Data Structure Recap

 Linked List Data Structure


 Linear and Pointer
 Each element of linked list represented through a node
which have two , three or more parts depends on types of
linked list
 There are two parts of node info that is the information
contained in node and Link that is the address of the next
node
 Type of Linked List are
Inf Lin
 One way linked List
 Two Way linked List (Doubly Linked List)
o k

17
Data Structure Recap

 Tree Data Structure (Acycle Data Structure)


 Non Linear Data Structure
 Each element of tree is represented through a node which
have two , three or more parts depends on types of tree
 Type of Tree are
 General Tree (if has more than 0.1 or more than 1 then it is general
tree)
 Binary Tree (everey node has max 0,1 or 2 children not more than 2
 B+ Tree
 Balance and Unbalance Tree

 Internal node

Indegree
outdegree
18
Data Structure Recap

 Graph Data Structure


 Non Linear Data Structure
 Each element of graph represented through a node
 Type of Graph are
 Connected/directed Graph
 Weighted Graph (assign weigh to every edge depend on problem
like cost, distance etc)

19
Summary
 Data structure is way for storing and manipulation of data
 Two main categories or types of data structure are linear and non
linear data structure.
 In case of memory representation, data structure are of two types
logical and physical data structure.
 Insert, Delete, Merge, Sort and search are common operations for all
types of data structure.
 Array, Stack and Queue are linear and sequential data structures.
 Linked List is linear and pointer based data structure.
 Tree and graphs are non linear data structures

20
What to be Next

In Next lecture, we will discuss algorithms, its


characteristics and convention.

21

You might also like