• 沒有找到結果。

Motivations of Data Structures and Algorithms

N/A
N/A
Protected

Academic year: 2022

Share "Motivations of Data Structures and Algorithms"

Copied!
25
0
0

加載中.... (立即查看全文)

全文

(1)

Motivations of Data Structures and Algorithms

Hsuan-Tien Lin

Dept. of CSIE, NTU

March 3, 2020

(2)

Introduction of Algorithms

(3)

Introduction of Algorithms

What is Algorithm?

descriptions to get something done

correctly/efficiently by computer

(4)

Introduction of Algorithms

Five Criteria of Algorithm

input, output, definiteness, finiteness, effectiveness

H.-T. Lin (NTU CSIE) Motivations of DSA 3/24

(5)

Introduction of Algorithms

getMinIndex with Sequential Search Algorithm

returns index to minimum element within array

(6)

Introduction of Algorithms

Correctness Proof of Algorithm

e.g. loop invariance by mathematical induction

—discrete math helps!

H.-T. Lin (NTU CSIE) Motivations of DSA 5/24

(7)

Introduction of Algorithms

Efficiency of Algorithm

knockout tournament for getMinIndex: not much faster overall,

but possibly faster if done in parallel

(8)

Expressing Algorithms with Pseudo Code

(9)

Expressing Algorithms with Pseudo Code

Pseudo Code for getMinIndex

pseudo code: “spoken language” of programming

(10)

Expressing Algorithms with Pseudo Code

Bad Pseudo Code: Too Detailed

goal of pseudo code: communicate efficiently

H.-T. Lin (NTU CSIE) Motivations of DSA 9/24

(11)

Expressing Algorithms with Pseudo Code

Bad Pseudo Code: Too Mysterious

goal of pseudo code: communicate correctly

(12)

Expressing Algorithms with Pseudo Code

Bad Pseudo Code: Too Abstract

goal of pseudo code: communicate effectively

H.-T. Lin (NTU CSIE) Motivations of DSA 11/24

(13)

Expressing Algorithms with Pseudo Code

Good Pseudo Code of SelSort

no “formal definition” and depends on the speaker/listener

(14)

Introduction of Data Structures

(15)

Introduction of Data Structures

What is Data Structure?

scheme of organizing data

within computer

(16)

Introduction of Data Structures

How to Organize 200 Exam Sheets?

different use cases

=⇒ different organization scheme (data structure)

H.-T. Lin (NTU CSIE) Motivations of DSA 15/24

(17)

Introduction of Data Structures

Good Algorithm Needs Proper Data Structure

if having data structure such that getMinIndex faster,

=⇒ SelSort also faster (we will see)

algorithm :: data structure ∼ recipe :: kitchen structure

(18)

Introduction of Data Structures

Good Data Structure Needs Proper Accessing Algorithms: get, insert

rule of thumb for speed: often-get ⇔ “nearby”

H.-T. Lin (NTU CSIE) Motivations of DSA 17/24

(19)

Introduction of Data Structures

Good Data Structure Needs Proper Maintenance Algorithms: construct, update, remove

hidden “cost” of data structure: maintenance effort

(20)

Why Data Structures and Algorithms?

(21)

Why Data Structures and Algorithms?

Why Data Structures and Algorithms?

use storage/computation resources properly =⇒ good program

(22)

Why Data Structures and Algorithms?

Proper Use: Tradeoff of Different Factors

understand tradeoff =⇒ good program

H.-T. Lin (NTU CSIE) Motivations of DSA 21/24

(23)

Why Data Structures and Algorithms?

Different Tradeoff on Different Platforms

important to learn other CS subjects

(24)

Why Data Structures and Algorithms?

Programming 6= Coding

programming :: building house ∼ coding :: construction work

H.-T. Lin (NTU CSIE) Motivations of DSA 23/24

(25)

Why Data Structures and Algorithms?

C Programming versus DSA

moving from coding to designing

參考文獻

相關文件

The research proposes a data oriented approach for choosing the type of clustering algorithms and a new cluster validity index for choosing their input parameters.. The

In the past researches, all kinds of the clustering algorithms are proposed for dealing with high dimensional data in large data sets.. Nevertheless, almost all of

● size() 回傳 queue

important to not just have intuition (building), but know definition (building block).. More on

“Big data is high-volume, high-velocity and high-variety information assets that demand cost-effective, innovative forms of information processing for enhanced?. insight and

Know how to implement the data structure using computer programs... What are we

• Recorded video will be available on NTU COOL after the class..

—we cannot teach all, but with reading you can learn all 3-6: 3 hour teaching, 6 hour reading/writing after class as important as writing assignments:. some may show up