Presentation is loading. Please wait.

Presentation is loading. Please wait.

Data Structures & Algorithms Lecturers : Boontee Kruatrachue Room no. 913 Kritawan Siriboon Room no. 913 Lecturers : Boontee Kruatrachue Room no. 913 Kritawan.

Similar presentations


Presentation on theme: "Data Structures & Algorithms Lecturers : Boontee Kruatrachue Room no. 913 Kritawan Siriboon Room no. 913 Lecturers : Boontee Kruatrachue Room no. 913 Kritawan."— Presentation transcript:

1 Data Structures & Algorithms Lecturers : Boontee Kruatrachue Room no. 913 Kritawan Siriboon Room no. 913 Lecturers : Boontee Kruatrachue Room no. 913 Kritawan Siriboon Room no. 913 Text : Data Structures & Algorithm Analysis in C, C++,… Mark Allen Weiss, Addison Wesley

2 Text Text : Data Structures & Algorithm Analysis in C Mark Allen Weiss, Addison Wesley http://fife.swufe.edu.cn/BILab/lectu res/ds/Data_Structures_and_Algori thm_Analysis_in_C.pdf

3 1. Algorithm State how to solve problem step by step. Ex: Finding a fake coin out of n real gold coins. Given * a two arm scale. * the fake coin is lighter.

4 Algo.1 :Two coins at a time Best Case Worst Case Average Case 1 n/2 How many times you weight?

5 Algo 2 : Half Cutting Best Case Worst Case ½ ½ Time Remaining 1 2 d = n d = log 2 n = n/2 1 = n/2 2 = n/2 3... = n/2 d 2 n/4 3 n/8...... d 1 n/2 1 How many times you weight?

6 2. Data Structure Structures of all data : how to keep related data in memory. Ex. The Eight Queen Problem.

7 The Eight Queen Problem Puting eight Queens on 8 x 8 chessboard such that none of them is able to capture any other using the standard chess queen’s move. Q Q Q Q Q Q Q Q

8 The Eight Queen Solutions It has 92 distinct solutions. If solutions that only differ by symmetry operatons (rotations & reflections) of the board are counted as one, the puzzle has 12 unique solutions.

9 The Eight Queen Problem Data Structures 31625740 col 0 1 2 3 4 5 6 7 Row Coloumn 0 3 1 1 2 6 3 2 4 5 5 7 6 4 7 0 row 0123456701234567 Q Q Q Q Q Q Q Q 0 1 2 3 4 5 6 7 2-D array1-D array

10 2-D array & 1-D array x A 0 1 2 3 4 5 6 7 0123456701234567 B x 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 … A[1][5] B[13] B[13] : BaseAdd + 13 * sizeof(int) A[1][5] : BaseAdd + ( (1*8 ) + (5) )*sizeof(int) Column size

11 Data Structures & Algorithms Data Structures  abstract data type: linked list, stack, queue, trees, heap, graph. Algorithms : recursion, complexity (algorithm analysis), hashing, searching, sorting.


Download ppt "Data Structures & Algorithms Lecturers : Boontee Kruatrachue Room no. 913 Kritawan Siriboon Room no. 913 Lecturers : Boontee Kruatrachue Room no. 913 Kritawan."

Similar presentations


Ads by Google