Design and Analysis of Algorithm Lecturer Shahid Imran

  • Slides: 15
Download presentation
Design and Analysis of Algorithm Lecturer: Shahid Imran

Design and Analysis of Algorithm Lecturer: Shahid Imran

Course Outline • Introduction; Asymptotic notations; Recursion and recurrence relations; • Divide-and-conquer approach; Sorting;

Course Outline • Introduction; Asymptotic notations; Recursion and recurrence relations; • Divide-and-conquer approach; Sorting; Search trees; Heaps; Hashing; Greedy approach; • Dynamic programming; Graph algorithms; Shortest paths; Network flow; Disjoint Sets; • Polynomial and matrix calculations; String matching; NP complete problems; • Approximation algorithms. • Recommended Book: Introduction to Algorithms /2 E, T. H. Cormen

Origin of Algorithm • The word Algorithm comes from the name of the Muslim

Origin of Algorithm • The word Algorithm comes from the name of the Muslim author Abu Ja’far Mohammad ibn Musa Al-Khowarizmi.

Definition • An algorithm is any well-defined computational procedure that takes some values, or

Definition • An algorithm is any well-defined computational procedure that takes some values, or set of values, as input and produces some value, or set of values, as output. • An algorithm is thus a sequence of computational steps that transform the input into output.

Before we start • Data Structure • • • Data Structure is way to

Before we start • Data Structure • • • Data Structure is way to process and manipulate data through set of operations Refer to Temporary and manipulation of data i. e. Variable and Array • Database • • Refer to permanent and manipulation of data i. e MS-Access, My. SQL

A Simple Program main () { int a, b, c; a=10; b=20; c=a+b; cout<<“Sum

A Simple Program main () { int a, b, c; a=10; b=20; c=a+b; cout<<“Sum is=“<<c; }

Types of Data Structures According to presentation of data 1. Linear Data Structure 2.

Types of Data Structures According to presentation of data 1. Linear Data Structure 2. Non-Liner Data Structure 1. Sequential Data Structures 1. Array 2. Queue 3. Stack 2. Pointer Data Structure (Linked List) 1. Tree 2. Graph

Types of Data Structures • According to Memory Representation • Logical Data Structure Map

Types of Data Structures • According to Memory Representation • Logical Data Structure Map data according to partition structure of memory • i. e. One dimensional Array • Physical Data Structure Cannot Map data easily according to partition structure of memory • 2 dimensional array, Tree • A special methods is needed to convert physical data structure to logical data structure

Common Operations on all Data Structures • Insert • Delete • Sort • Search

Common Operations on all Data Structures • Insert • Delete • Sort • Search • Merage • Traversing (Scanning)

Array • Linear & Sequential • Array is combination of homogenous elements with •

Array • Linear & Sequential • Array is combination of homogenous elements with • • N Consecutive index numbers (such as 1, 2, 3, 4…. ) Successive memory locations (102, 104, 106, …) • Two types of Array are commonly used • • 1 Dimensional (1 -D) 2 Dimensional (2 -D) • Dope Vector methods is used to convert 2 -D Array into 1 -D.

Stack • It is linear and sequential • Work on following Principles • LIFO

Stack • It is linear and sequential • Work on following Principles • LIFO (Last in First Out) FILO (First in Last Out) • Two conditions are • Overflow • underflow

Queue • It is linear and sequential • Work on following Principles • FIFO

Queue • It is linear and sequential • Work on following Principles • FIFO (First in First Out) LILO (Last in Last Out) • Two conditions are • • Overflow Underflow • • • Circular Priority Double Ended • Types of Queue

Linked List • Linear & Pointer • Each element of linked list represented through

Linked List • Linear & Pointer • Each element of linked list represented through a node which have 2, 3, or more parts depends upon the type of Linked List • Types of Linked List • One Way (Single) • Two Way (Double)

Tree • Non-Linear Data Structure • Each element of Tree represented through a node

Tree • Non-Linear Data Structure • Each element of Tree represented through a node which have 2, 3, or more parts depends upon the type of Tree • Types of Tree • General Tree • Binary Tree • B+ Tree • Balance & unbalance Tree

Graph • Non-Linear Data Structure • Each element of Graph represented through a node

Graph • Non-Linear Data Structure • Each element of Graph represented through a node • Types of Graph • Connected Graph • Weighted Graph