Skip to Content
深入理解運算原理|從簡單的機器到無所不能的程式
book

深入理解運算原理|從簡單的機器到無所不能的程式

by Tom Stuart
November 2017
Beginner to intermediate
344 pages
7h 2m
Chinese
GoTop Information, Inc.
Content preview from 深入理解運算原理|從簡單的機器到無所不能的程式
第4章
只想加入運算能力
我們在第 3 章研究有限自動機,這種虛構的機器剝除了真實電腦的複雜,並將它簡化到
最簡單的可能形式。我們深入探索了這些機器的行為,並也觀察了它們的用途;我們還
發現,儘管有不尋常的執行方法,非決定論有限自動機並不比更為傳統的決定論有限自
動機具備更多的功能。
就算加入像是非決定論和自由移動等奇特功能,我們也無法讓有限自動機更具威力。
而這雖然讓我們機器的計算能力有所提升,但卻也停滯在所有這些簡單機器共同的計算
能力。
如果不對機器運作方式做些激烈的改變,我們無法更加提升機器的能力。
所以這所有的機器實際上具有多大的威力?嗯,不多。它們僅限於非常特定的應用(接
受或拒絕整組字元),甚至在比這個還更小的範圍裡,依然很容易出現沒有機器能夠識
別的語言。
舉例來說,試著考慮設計這樣的有限狀態機:能夠讀取起始括號(左括號)和結束括號
(右括號)的字串,並且只有在這些括號前後
對稱
,才接受該字串,也就是如果結束括
號能與字串裡的前一個起始括號配對
1
一般來說,解決這個問題的策略是一次讀取 1 個字元,並在讀取字元的同時,將用來表
示目前巢狀層級的數值記錄下來:讀取起始括號增加巢狀層級,讀取結束括號減少巢狀
層級。只要巢狀層級為零,我們就知道截至目前已經讀取了對稱的括號(因為巢狀層級
1 這和接受僅包含數量相等的起始、結束括號的字串並不完全相同。字串 '()' ')(' 都只包含一個起始、結
束括號,但只有 '()' 才對稱。
110
|
4
已經先上升再下降到完全相同的數量),而且如果我們試著將巢狀層級減少到零以下, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

JSON實務手冊

JSON實務手冊

Tom Marrs

Publisher Resources

ISBN: 9789864766000