Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
師大資工系ACM-ICPC讀書會:肆、鏈結串列與二元樹
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Maplewing
December 06, 2013
Programming
180
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
師大資工系ACM-ICPC讀書會:肆、鏈結串列與二元樹
師大資工系ACM-ICPC讀書會:肆、鏈結串列與二元樹
Maplewing
December 06, 2013
More Decks by Maplewing
See All by Maplewing
資訊實務應用讀書會 第七堂課:jQuery
sinmaplewing
0
2.1k
師大資工系ACM-ICPC讀書會:參、堆疊與佇列
sinmaplewing
0
280
師大資工系ACM-ICPC讀書會:貳、排序搜尋與數學基礎
sinmaplewing
0
220
資訊實務應用讀書會 第六堂課:Basic CSS
sinmaplewing
0
1.8k
師大資工系ACM-ICPC讀書會:壹、字串處理與大數運算
sinmaplewing
0
170
師大資工系ACM-ICPC讀書會:零、比賽介紹、解題系統介紹
sinmaplewing
0
260
資訊實務應用讀書會 第四堂課(支線):Linux
sinmaplewing
0
1.9k
資訊實務應用讀書會 第一堂課:Basic HTML
sinmaplewing
1
2.2k
Other Decks in Programming
See All in Programming
Next.js: The final boss of Web Performance
guaca
0
280
作れる、でも消せるか?──安全に「枯らして消す」機能削除術 / Drain, Then Delete
chobishiba
2
800
ジョジョの世界をXRで再現する
mofurune
0
170
Railsバージョンを4倍にした話
optim
0
460
IBM Bob でAI駆動開発『QC-Playbook』
ichirokano2
0
110
contenteditable と日本語入力に向き合う
colorful12
0
200
コードで差別化できない時代の ソフトウェアエンジニアリング / Software Engineering in an Era Where Code Doesn’t Differentiate
kishida
2
180
Atomic Design, Enforced: Scaling Mobile Design Systems (next.app devCon / droidCon Berlin 2026)
steliosf
PRO
0
170
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
5.2k
當我們開始不讀 Code - AI Agent 時代,Code Review 與 Clean Code 還剩下什麼?
jame2408
1
260
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
750
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
1.1k
Featured
See All Featured
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
500
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
1
930
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
850
What the history of the web can teach us about the future of AI
inesmontani
PRO
2
740
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
35
3.8k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
400
Design in an AI World
tapps
1
350
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
254
22k
HDC tutorial
michielstock
2
960
Art, The Web, and Tiny UX
lynnandtonic
304
22k
Discover your Explorer Soul
emna__ayadi
2
1.3k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
1
280
Transcript
肆、鏈結串列與二元樹 師大資工系 灆洢 取自於<提升程式設計的邏輯思考力> 6.2 & 6.3
鏈結串列
struct node{ int value; node *next; }; 單向鏈結串列 Singly Linked
List 22 12 32
插入新節點 22 12 32 5 node node.next newnode newnode.next =
node.next; node.next = newnode;
刪除節點 22 12 32 node node.next node.next.next node *delnode =
node.next; node.next = node.next.next; delete delnode;
struct node{ int value; node *prev, *next; }; 雙向鏈結串列 Doubly
Linked List 22 12 32
• List containers are implemented as doubly-linked lists. C++ STL:
list
•127 •101 •133 •10152 •673 •442 作業 •11111 •11234 •540
•10050
二元樹
• 任兩點之間都相通,並且沒有環的圖。 • 來源:演算法筆記 樹 Tree
二元樹 Binary Tree
• 陣列 • 以0為root • 往編號n之左子樹:2*(n+1) - 1 • 往編號n之右子樹:2*(n+1)
• 往父節點:floor((n-1)/2) • 鏈結串列 • struct node { int data; node *left, *right; }; 儲存方式
需要用queue 廣度優先搜尋 BFS: Breadth-first search
深度優先搜尋 DFS: Depth-first search 需要用recursion或stack
樹的走訪:前序、中序、後序
function Preorder(node){ if(!node.left && !node.right){ print(node.value); return; } print(node.value); Preorder(node.left);
Preorder(node.right); } Ans: F,B,A,D,C,E,G,I,H 前序
function Inorder(node){ if(!node.left && !node.right){ print(node.value); return; } Preorder(node.left); print(node.value);
Preorder(node.right); } Ans: ABCDEFGHI 中序
function Postorder(node){ if(!node.left && !node.right){ print(node.value); return; } Preorder(node.left); Preorder(node.right);
print(node.value); } Ans: ACEDBHIGF 後序
• 給予前序與中序,如何找出後序? • 前:DBACEGF 中:ABCDEFG • 後:ACBFGED 問題:二元樹重建
作業 •112 •548 •297 •712 •699 •327 •839 •10562
謝謝聆聽 資料取自於<提升程式設計的邏輯思考力> 6.2 & 6.3