Data Structures Algorithms Using Python Lecturers Kritawan Siriboon

Data Structures & Algorithms Using Python Lecturers : รศ. ดร. บญธร เครอตราช Kritawan Siriboon Boontee Kruatrachue รศ. กฤตวน ศรบรณ KMITL Room no. 913 01076249 Data Structures & Algorithms : Tree 21

Main Course Material : www. ce. kmitl. ac. th • www. ce. kmitl. ac. th • click : Subject Data Structures and Algorithms and Lab รศ. ดร. บญธร เครอตราช รศ. กฤตวน ศรบรณ KMITL 01076249 Data Structures & Algorithms : Introduction 2

Additional Text Book • ใชเนอหาตาม lecture slide • หากอยากอาน text เพมเตม search : Data Structures, Algorithms, using pythonเชน Free Online Book : http: //interactivepython. org/courselib/static/pythonds/index. html https: //www. amazon. com/Problem-Solving-Structures-Algorithms. Python/dp/1541128257/ref=sr_1_5? ie=UTF 8&qid=1483445752&s=books &sr=1 -5 Paperback: 438 pages Publisher: Franklin, Beedle & Associates; 2 nd edition (August 22, 2011) Product Dimensions: 7. 5 x 0. 9 x 9. 2 inches • • รศ. ดร. บญธร https: //www. amazon. com/Problem-Solving-Algorithms-Structures. Python/dp/1590282574/ref=pd_bxgy_14_img_2? _encoding=UTF 8&pd_rd _i=1590282574&pd_rd_r=6 TRCTXQRF 26 DB 6 NQFHDW&pd_rd_w=b. Ba. UI& pd_rd_wg=r. KP 7 Z&psc=1&ref. RID=6 TRCTXQRF 26 DB 6 NQFHDW ISBN-13: 978 -1590282571 ISBN-10: 1590282574 เครอตราช รศ. กฤตวน ศรบรณ KMITL 01076249 Data Structures & Algorithms : Introduction 3

Additional Text Book “Data Structures & Algorithms in Python” Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser, Free Online Book : it-ebooks. info/book/2467/ รศ. ดร. บญธร เครอตราช รศ. กฤตวน ศรบรณ KMITL 01076249 Data Structures & Algorithms : Introduction 4


Algorithm 1 : Two coins at a time ชงทละ 2 เหรยญ Algorith m? ชงก คร ง ? • Best Case ดทสด 1 • Worst Case แยทสด n/2 • Average Case เฉลย รศ. ดร. บญธร เครอตราช รศ. กฤตวน ศรบรณ KMITL n/2 01076249 Data Structures & Algorithms : Introduction 6

Algorithm 2 : Cutting Half ชงก ครง 1 Worst Case log 2 n ครงท เหลอ 1 2 3. d 1 แบงครงชง Algorithm ? เศษ ? รศ. ดร. บญธร เครอตราช รศ. กฤตวน ศรบรณ ? Best Case KMITL n/2 =n/21 n = d ครง 2 2 *2 *2. . *2 =n/2 n/4 n/8 =n/23 d =. . . . log 2 n 2 d = =n/2 d nd = log 2 n 01076249 Data Structures & Algorithms : Introduction 7 1


The Eight Queen Problem Data Structures Data Structure 1 : C : 2 D array, Pythhon : list of list 0 1 2 3 4 5 7 col Q 0 (0, 3) row Q 1 (1, 1) (2, 6) Q 3 (3, 2) Q 4 (6, 5) Q 5 (5, 7) Q 6 1 6 2 5 7 4 0 1 2 3 4 5 6 (0, 3) (1, 1) (2, 6) (3, 2) (6, 5) (5, 7) (6, 4) Q (7, 0) #Python list of list board = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0], [0, 0, 0, 0, 0]] board[0][3] = 1 board[1][1] = 1 #. . . l = [[1, 2, 3], [4, 5, 6]] for ele 1 in l: for ele 2 in ele 1: print(ele 2) รศ. ดร. บญธร 3 0 7 (7, 0) Q 2 7 6 Data Structure 2 : C : 1 D array, Python : list เครอตราช รศ. กฤตวน ศรบรณ KMITL [1, 2, 3] [4, 5, 6] #Python list b = [-1, -1, -1] b[0] = 3 b[1] = 1 b[2] = 6 b[3] = 2 b[4] = 5 b[5] = 7 b[6] = 4 b[7] = 0 for ele in b: print(ele) 1 2 3 4 5 6 01076249 Data Structures & Algorithms : Introduction 9 3 1 6 2 5 7 4 0 b = [-1]*8

Data Structures & Algorithms : 1. Data Structures : Abstract Data Types : Linked List, Stack, Queue, Trees, Heap, Graph. 2. Algorithms : Recursion, Complexity (Algorithm Analysis) , Hashing, Searching, Sorting. รศ. ดร. บญธร เครอตราช รศ. กฤตวน ศรบรณ KMITL 01076249 Data Structures & Algorithms : Introduction 10
- Slides: 10