CSE 221/ICT221 ???????????????????????????????? Analysis and Design of Algorithms - PowerPoint PPT Presentation

Loading...

PPT – CSE 221/ICT221 ???????????????????????????????? Analysis and Design of Algorithms PowerPoint presentation | free to download - id: 6f6bb1-MmVkZ



Loading


The Adobe Flash plugin is needed to view this content

Get the plugin now

View by Category
About This Presentation
Title:

CSE 221/ICT221 ???????????????????????????????? Analysis and Design of Algorithms

Description:

CSE 221/ICT221 Analysis and Design of Algorithms – PowerPoint PPT presentation

Number of Views:104
Avg rating:3.0/5.0
Slides: 63
Provided by: ict150
Learn more at: http://csits.spu.ac.th
Category:

less

Write a Comment
User Comments (0)
Transcript and Presenter's Notes

Title: CSE 221/ICT221 ???????????????????????????????? Analysis and Design of Algorithms


1
CSE 221/ICT221 ????????????????????????????????
Analysis and Design of Algorithms
  • Asst.Prof. Dr.Surasak Mungsing
  • E-mail Surasak.mu_at_spu.ac.th

2
CSE 221/ICT221 Analysis and Design of Algorithms
  • Lecturer Asst.Prof. Dr.Surasak Mungsing
  • surasak.mu_at_spu.ac.th
  • http//www.spu.ac.th/teacher/surasak.
    mu
  • Contact 12th Floor, Building 11
  • Office Hour TBA

3
Course Description
  • ??????????????????????????????????
    ?????????????????????????????????
    ??????????????????? ???????????????????????????
    ???????????????????????? ?????????????????????????
    ????????????????????????????????????????
    ??????????????????????????????????????????????????
    ??? ???????????????????????? ?????????????????????
    ??
  • (Prerequisite CSE102 and MAT231 or
  • together with MAT231 for Vocational Students)

4
Objective
  • Understanding of theory and applications of
    algorithms for computer-based problem solving
  • Concept development for computer-based problem
    solving
  • Skill improvement for design of computer-based
    problem solving

5
?????????????????????????
  • Books
  • Mark Allen Weiss. Data Structures and Algorithm
    Analysis in Java, International Edition.
    Addison-Wesley. 2007.
  • (www.cs.fiu.edu/weiss )
  • R.T.C. Lee, S.S. Tseng, R.C. Chang, Y.T.
    Tsai. Introduction to the Design and Analysis of
    Algorithms, A Strategic Approach. McGraw-Hill
    Education (Asia). 2005

6
Evaluation
  • Theory
  • Final Exam 30
  • Mid-Term Exam 20
  • Quiz 10
  • Exercise 10
  • Participation 5
  • Lab
  • Reports 15
  • Quiz 10
  • Total 100

75
25
7
Grading
Score Grade
80-100 A
75-79 B
70-74 B
65-69 C
60-64 C
55-59 D
50-54 D
0-49 F
8
Outline
  • Course Introduction and review of Data Structures
  • Complexity theory and necessary mathematical
    background
  • Algorithms and algorithm analysis

Week 1-7
  • Time complexity of algorithms in form of Big-Oh
  • Time complexity analysis of sorting algorithms
    (Part I)
  • Time complexity analysis of sorting algorithms
    (Part II)
  • Time complexity Analysis of Algorithms using
  • List, tack, and Queue data structures

9
Outline(Cont.)
  • Analysis of Algorithms using Trees data
    structure

Applications of Decision Tree
Shortest Path and Minimum Spanning Tree
Week 8 -11
Time complexity analysis for searching in graph
Algorithm design using Greedy and Divide
and Conquer techniques (e-Learning)
Algorithm design using Dynamic Progra mming,
and Backtracking techniques (e-Learning)
P and NP Problem (e-Learning)
10
Mutual Agreement
  • Attendant checking for each lecture
  • Postpone lectures will informed at least 1 week
    in advance
  • Makeup class will be announced in next class
  • Late class is not more than 20 minutes, otherwise
    there will be no class and requires a makeup
    class
  • Class attendance must be at least 80 to be
    eligible for final examination
  • All documents can be downloaded at
  • http//www.spu.ac.th/teacher/surasak.mu/

11
(No Transcript)
12
Review Data Structures
13
The Class Chain
Use ChainNode
  • next (datatype ChainNode)

element (datatype Object)
14
The Method get
  • public Object get(int index)
  • checkIndex(index)
  • // move to desired node
  • ChainNode currentNode firstNode
  • for (int i 0 i lt index i)
  • currentNode currentNode.next
  • return currentNode.element

15
Removing An Element
  • remove(0)
  • firstNode firstNode.next

16
remove(2)
  • determine beforeNode and change pointer.

beforeNode.next beforeNode.next.next
17
One-Step add(0,f)
newNode
  • firstNode new ChainNode(f, firstNode)

18
Two-Step add(3,f)
beforeNode firstNode.next.next beforeNode.next
new ChainNode(f, beforeNode.next)
19
Circular List
firstNode
a
b
c
d
e
20
Doubly Linked List
21
Doubly Linked Circular List With Header Node
22
Doubly Linked Circular List
23
Stacks
  • Linear list.
  • One end is called top.
  • Other end is called bottom.
  • Additions to and removals from the top end only.

24
Stack Of Cups
Picture is really a stack of cups and
saucers LIFO last in first out. The first cup
that is removed from a stack of cups is the Last
one that was added to the stack. Other examples
of LIFO lists in real life stack of trays in a
cafeteria paper stack in a printer or copy
machine newspaper stack at a news stand.
25
Checking Matching Parentheses
  • (((ab)cd-e)/(fg)-(hj)(k-l))/(m-n)
  • The result is pairs of position(u,v) where the
    open parenthesis at u is correctly matched with
    the close parenthesis at v
  • (2,6) (1,13) (15,19) (21,25) (27,31) (0,32)
    (34,38)
  • (ab))((cd)
  • (0,4)
  • The close parenthesis at position 5 does not have
    an open parenthesis as its pairs
  • (8,12)
  • the open parenthesis at position 7 does not have
    a close parenthesis as its pairs

26
Tower of Hanoi
2
  • 64 discs are to be moved from tower A to
    tower C on the condition that larger disc cannot
    be placed on top of the smaller one

27
Towers Of Hanoi/Brahma
A
  • towers of Hanoi with 3 discs

28
A
  • towers of Hanoi with 3 discs

29
A
  • towers of Hanoi with 3 discs

30
A
  • towers of Hanoi with 3 discs

31
A
  • towers of Hanoi with 3 discs

32
A
  • towers of Hanoi with 3 discs

33
Towers Of Hanoi/Brahma
A
  • towers of Hanoi with 3 discs

34
A
  • towers of Hanoi with 3 discs
  • ??????? 7 moves

35
Recursive Solution
  • Towerof Hanoi with n gt 0 discs to be moved from
    tower A to tower C with the help of tower B
  • Move n-1 discs from tower A to tower B with the
    help of tower C

36
A
  • ?????????????????????? A ????? C

37
A
  • ?????????????????????????? n-1 ??? B ????? C
    ?????? A ????

38
A
  • moves(n) 0 ????? n 0
  • moves(n) 2moves(n-1) 1 2n-1 ????? n gt 0

39
Moves required
  • moves(64) 1.8 1019 (approximately) required
  • At the rate of a billion moves/second it would
    take 570 years to complete the task of moving 64
    disks.
  • At the rate of 1 disk a minute (the disks are,
    after all, rather heavy), will take about 3.4
    1013 years or 34,000,000,000,000 years

40
(No Transcript)
41
Queue at the bus station
front
rear
rear
42
Queue at the bus station
front
rear
43
Queue at the bus station
front
rear
rear
44
Queue at the bus station
front
rear
rear
45
Queue implemented with array
  • Use 1-dimentional array to represent a queue
  • Can be viewed as a circular queue

46
Add an element into queue
  • Requires two pointers, front and rear

47
Add an element into queue
  • move rear pointer clockwise 1 position
  • then assign a value to the array pointed by the
    rear pointer

D
queuerear
48
Current queue status

49
Remove an element from queue
  • Move front pointer clockwise 1 position
  • then move the value out from queue

queuefront
50
Empty the queue
51
Empty the queue
front
52
Empty the queue
front
53
Empty the queue
front
  • Continuously remove elements from queue causes
    the queue to be empty ? front rear.
  • The queue is also empty when created
  • ? Starts with front rear 0.

54
Make the queue full
By keep adding an element to the queue
55
Make the queue full
By keep adding an element to the queue
D
C
A
B
56
Make the queue full
By keep adding an element to the queue
rear
D
E
C
A
B
57
Make the queue full
By keep adding an element to the queue
D
E
C
F
A
B
rear
  • When continuously adding elements to queue, it is
    finally full so front rear.
  • How do you know whether the queue is empty or
    full when front rear ?

58
How do we know whether the queue is empty or full
when front rear ?
  • Assign a variable, size, to keep number of
    element in queue
  • Increase queue size by 1 each time when when
    adding an element to queue (size)
  • Reduce queue size by 1 each time when remove an
    element from queue (size--)
  • Queue is empty when queue size 0 (size0)

59
Tree in computer science
  • Tree is a set with at least 1 member t
  • one of the tree member is called root
  • other members(if any) are subtree(s)

60
Binary Tree
  • is a tree that may be an empty tree (a tree with
    no member)
  • A non-empty binary tree has root
  • Remaining member (if any) ??????????????(?????)
    ?????????????? may be the root 0f at most 2
    binary subtrees, called Left sub-tree and Right
    sub-tree

61
An expression implemented by a binary tree
  • (a b) (c d) / (e f)

62
(No Transcript)
About PowerShow.com