1 / 62

CSC201 การวิเคราะห์และออกแบบขั้นตอนวิธี Analysis and Design of Algorithms

CSC201 การวิเคราะห์และออกแบบขั้นตอนวิธี Analysis and Design of Algorithms. Asst.Prof . Dr.Surasak Mungsing E-mail: Surasak.mu@spu.ac.th. CSC201 Analysis and Design of Algorithms. Lecturer : Aaat.Prof . Dr.Surasak Mungsing surasak.mu@spu.ac.th http://www.spu.ac.th/teacher/surasak.mu

zack
Download Presentation

CSC201 การวิเคราะห์และออกแบบขั้นตอนวิธี Analysis and Design of Algorithms

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC201การวิเคราะห์และออกแบบขั้นตอนวิธี Analysis and Design of Algorithms Asst.Prof. Dr.SurasakMungsing E-mail: Surasak.mu@spu.ac.th

  2. CSC201 Analysis and Design of Algorithms Lecturer: Aaat.Prof. Dr.SurasakMungsing surasak.mu@spu.ac.th http://www.spu.ac.th/teacher/surasak.mu Contact:12th Floor, Building 11 Office Hour: TBA

  3. Course Description การวิเคราะห์ทางทฤษฎีของขั้นตอนวิธี การเลือกโครงสร้างข้อมูลที่เหมาะสม ขั้นตอนวิธีเรียกซ้ำ การวิเคราะห์ชั้นความซับซ้อน การเรียงลำดับและการค้นหา การวิเคราะห์ความต้องการของเนื้อที่และเวลาที่ต้องการของขั้นตอนวิธี การคำนวณได้และการตัดสินใจได้ของปัญหาที่ยากต่อการแก้ไข เช่นที่พบในปัญญาประดิษฐ์ แนะนำขั้นตอนวิธีแบบขนาน

  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. 2010. (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 Final Exam 40 % Mid-Term Exam 20 % Quiz 20 % H/W & Exercise 10% Participation 10 % Total100 %

  7. Grading

  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, andQueue data structures

  9. Outline(Cont.) • Analysis of Algorithms using Trees data structure • Applications of Decision Tree Shortest Pathand 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 Programming, 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 1week 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. CSE221/NMT221/ICT221 การวิเคราะห์และออกแบบขั้นตอนวิธี

  12. Review: Data Structures

  13. firstNode null a b c d e • size = number of elements The Class Chain UseChainNode next (datatype ChainNode) element (datatype Object)

  14. firstNode null a b c d e The Method get public Object get(int index) { checkIndex(index); // move to desired node ChainNode currentNode = firstNode; for (int i = 0; i < index; i++) currentNode = currentNode.next; return currentNode.element; }

  15. firstNode Removing An Element null a b c d e remove(0) firstNode = firstNode.next;

  16. firstNode remove(2) null a b c d e beforeNode determine beforeNode and change pointer. beforeNode.next = beforeNode.next.next;

  17. f firstNode One-Step add(0,’f’) null a b c d e newNode firstNode = new ChainNode(‘f’, firstNode);

  18. c firstNode newNode f Two-Step add(3,’f’) null a b c d e beforeNode beforeNode = firstNode.next.next; beforeNode.next = new ChainNode(‘f’, beforeNode.next);

  19. firstNode Circular List a b c d e

  20. firstNode lastNode Doubly Linked List null null a b c d e

  21. headerNode Doubly Linked Circular List With Header Node a b c d e

  22. firstNode Doubly Linked Circular List a b c d e

  23. Stacks • Linear list. • One end is called top. • Other end is called bottom. • Additions to and removals from the top end only.

  24. F E E D D C C B B A A Stack Of Cups top top bottom bottom 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 MatchingParentheses • (((a+b)*c+d-e)/(f+g)-(h+j)*(k-l))/(m-n) • The result is pairs of position(u,v) where the open parenthesis at uis correctly matched with the close parenthesis at v • (2,6) (1,13) (15,19) (21,25) (27,31) (0,32) (34,38) • (a+b))*((c+d) • (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. 4 3 1 A B C Tower of Hanoi 64discs 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 2

  27. 3 2 1 B C Towers Of Hanoi/Brahma • towers of Hanoi with 3 discs A

  28. 2 1 3 B C • towers of Hanoi with 3 discs A

  29. 1 2 3 B C • towers of Hanoi with 3 discs A

  30. 3 1 2 B C • towers of Hanoi with 3 discs A

  31. 3 2 1 B C • towers of Hanoi with 3 discs A

  32. 3 2 1 B C • towers of Hanoi with 3 discs A

  33. 2 3 1 B C Towers Of Hanoi/Brahma • towers of Hanoi with 3 discs A

  34. 3 2 1 B C • towers of Hanoi with 3 discs A • พำๆรพำห 7 moves

  35. 1 A B C Recursive Solution • Towerof Hanoi with n > 0 discs to be moved from towerA 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. 1 B C • ย้ายแผ่นทองคำด้านบนจาก A ไปยัง C A

  37. 1 B C • ย้ายแผ่นที่อยู่ด้ายบนจำนวน n-1 จาก B ไปยัง C โดยใช้ A ช่วย A

  38. 1 B C • moves(n) = 0 เมื่อ n = 0 • moves(n) = 2*moves(n-1) + 1 = 2n-1 เมื่อ n > 0 A

  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. Bus Stop Queue at the bus station front rear rear

  41. Bus Stop Queue at the bus station front rear

  42. Bus Stop Queue at the bus station front rear rear

  43. Bus Stop Queue at the bus station front rear rear

  44. queue[] [2] [3] [1] [4] [0] [5] Queue implemented with array • Use 1-dimentional array to represent a queue • Can be viewed as a circular queue

  45. [2] [3] A B rear front C [1] [4] [0] [5] Add an element into queue • Requires two pointers, front and rear

  46. [2] [3] A B front C [1] [4] [0] [5] rear Add an element into queue • move rear pointer clockwise 1 position • then assign a value to the array pointed by the rear pointer D queue[rear]

  47. [2] [3] A B rear front C [1] [4] [0] [5] Current queue status

  48. [2] [3] front A B rear C [1] [4] [0] [5] Remove an element from queue • Move front pointer clockwise 1 position • then move the value out from queue queue[front]

  49. [2] [3] rear front C [1] [4] B A [0] [5] Empty the queue

More Related