Developing Algorithms
แนะนำใหม่
9:10
อัลกอริทึมและการเขียนโปรแกรม
จินตนาการสมุดโทรศัพท์ที่มีชื่อนับล้าน และคุณต้องหาหนึ่งชื่อ. ตรวจสอบทีละชื่อ และคุณสามารถอยู่ตรงนั้นทั้งวัน. มีวิธีหาได้ในเวลาประมาณ…
บรรยายภาษาอังกฤษ · สลับคำบรรยายภาษาอังกฤษและภาษาจีนได้
ในบทเรียนนี้
| English | ความหมาย |
|---|---|
| algorithm/ˈælɡərɪθəm/ | อัลกอริทึม |
| finite/ˈfaɪnaɪt/ | มีจำกัด |
| sequencing/ˈsiːkwənsɪŋ/ | การเรียงลำดับ |
| flowchart/ˈfləʊtʃɑːt/ | แผนภาพไหล |
| natural language/ˈnætʃərəl ˈlæŋɡwɪdʒ/ | ภาษาธรรมชาติ |
| same result/seɪm rɪˈzʌlt/ | ผลลัพธ์เดียวกัน |
| refine/rɪˈfaɪn/ | ปรับปรุง |
| efficient/ɪˈfɪʃənt/ | มีประสิทธิภาพ |
อัลกอริทึมคืออะไร?
- Algorithm (อัลกอริทึม) คือชุดคำสั่งแบบขั้นบันไดที่เป็น finite (จำกัด) เพื่อทำงานให้สำเร็จ.
- "Finite" หมายความว่ามันจบลงหลังจากจำนวนขั้นตอนที่จำกัดเสมอ.
- สูตรอาหาร, เส้นทางไปโรงเรียน, และวิธีการเรียงลำดับ ล้วนเป็น algorithms.
- ทุกโปรแกรมสร้างจาก algorithms.
An algorithm is:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
"Finite" means it always ends after a limited number of steps.
โครงสร้างพื้นฐานสามอย่าง
- ทุก algorithm สร้างจากสามโครงสร้างพื้นฐาน:
- sequencing: ทำขั้นตอนทีละขั้นตอนตามลำดับ;
- selection: เลือกเส้นทางระหว่างทางเลือก;
- iteration: ทำซ้ำขั้นตอน.

Flowchart แสดงอัลกอริทึมโดยใช้สัญลักษณ์มาตรฐาน

Sequencing, selection, or iteration?
Every algorithm is built from three structures: sequencing (steps in order), selection (choosing a path), and iteration (repeating steps).
Which are the three building blocks of algorithms? (Select all that apply)
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Sequencing, selection, and iteration build every algorithm.
A flowchart, pseudocode, and natural language can all express:
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
All three describe the same steps differently.
Two different algorithms can never produce the same correct result.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
False. Different algorithms can solve the same problem correctly; one may simply be faster than the other.
วิธีแสดงออก
- คุณสามารถแสดง algorithm เป็น pseudocode (รหัสจำลอง), flowchart (แผนภาพ流程图) หรือใน natural language (ภาษาธรรมชาติ) แบบธรรมดา.
- ทั้งสามวิธีอธิบายขั้นตอน เดียวกัน ในรูปแบบที่แตกต่างกัน.
- Algorithms ต่างๆ สามารถให้ ผลลัพธ์เดียวกัน — อย่างหนึ่งสั้นแต่ช้า, อีกอย่างยาวแต่เร็ว.
- ไม่มีใคร "ถูกต้องมากกว่า" ถ้าทั้งสองให้คำตอบที่ถูกต้อง.
The "largest of three" algorithm runs on a=4, b=9, c=6. What does it output?
ความยาก 2/5 · 140 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Start 4; 9 > 4 → 9; 6 > 9 is false → stays 9.
Improving an algorithm step by step to be correct, clear, and efficient is called ______.
ความยาก 1/5 · 100 เหรียญ + บอนัสน้อยๆ เมื่อทำสำเร็จครั้งแรกในวันนี้
Refining follows testing, making the algorithm better each pass.
ปรับปรุงเพื่อประสิทธิภาพ
- เรา refine (ปรับปรุง) algorithm เพื่อให้มันถูกต้อง ชัดเจน และมี efficiency (ประสิทธิภาพ).
- Refining หมายความว่าปรับปรุงมันทีละขั้นตอนหลังการทดสอบ.
ค่ามากที่สุดในสามค่า. largest ← a; IF b > largest: largest ← b; IF c > largest: largest ← c; DISPLAY largest. สำหรับ a=4, b=9, c=6: เริ่ม 4; 9 > 4 → ค่ามากที่สุด 9; 6 > 9 เป็น false → ยังคงเป็น 9. ผลลัพธ์ 9. นี้ใช้ sequencing และ selection.
An algorithm is a finite set of steps, built from three structures: sequencing, selection, and iteration. You can express it as pseudocode, a flowchart, or natural language. Different algorithms can give the same result, so we refine them to be correct, clear, and efficient.
เกิดปัญหาอะไรขึ้น? เฉพาะทีมเว็บไซต์เท่านั้นที่เห็นข้อมูลนี้