fbpx
วิกิพีเดีย

ขั้นตอนวิธีของเบรนท์

ขั้นตอนวิธีของเบรนท์ (อังกฤษ: Brent's algorithm) เรียกอีกชื่อหนึ่งว่า "The Teleporting Turtle Algorithm" ได้รับการคิดค้นขึ้นโดย Richard Peirce Brent ในปี 1980 เพื่อใช้ในการตรวจสอบการมีวงรอบ (cycle) ในปัญหาที่มีลักษณะเป็นรายการโยงเดี่ยว ตัวอย่างเช่น ฟังก์ชันวนซ้ำ การแยกตัวประกอบ ตัวสร้างเลขสุ่มเทียม และปัญหาอื่นๆ อีกมากมาย

ขั้นตอนวิธีของเบรนท์ มีหลักการทำงานคล้ายๆ กับขั้นตอนวิธีตรวจสอบการมีวงรอบของฟลอยด์ (Floyd's Tortoise and the Hare algorithm) ข้อได้เปรียบของขั้นตอนวิธีของเบรนท์คือจะใช้เวลาการทำงานน้อยกว่าและสามารถหาความยาวของวงรอบได้โดยตรง ไม่จำเป็นต้องไล่ค้นหาในลำดับย่อยอีกครั้ง

ตัวอย่างการใช้งาน

จากรูป หากเริ่มเดินจากจุด 2 จะมีเส้นทางการเดินดังนี้ 2 → 0 → 6 → 3 → 1 → 6 → 3 → ... พบว่าการวนซ้ำนี้มีวงรอบ เนื่องจากมีการเดินทางซ้ำในเส้นทางเดิม คือ 6 → 3 → 1 ซึ่งขั้นตอนวิธีของเบรนท์มีความสามารถในการตรวจสอบการมีวงจรเช่นนี้ได้นั่นเอง

การอธิบายขั้นตอนวิธี

การทำงานของขั้นตอนวิธีของเบรนท์ เริ่มต้นโดยการกำหนดตัววนซ้ำ 2 ตัวคือ กระต่าย และ เต่า ยืนอยู่ที่จุดเริ่มต้น หลังจากนั้นให้ กระต่าย เดินไปทีละก้าวตามเส้นทาง และจะทำการเคลื่อนย้าย เต่า มาตำแหน่งเดียวกับ กระต่าย เมื่อถึงเวลาที่กำหนด

  • โดยหาก กระต่าย เดินไปได้ถึงจุดจบของรายการโยง นั่นแสดงว่า ไม่มีวงรอบ
  • แต่หาก กระต่าย เดินไปเจอ เต่า แสดงว่า มีวงรอบ

Flow Chart :

รหัสเทียมแสดงการทำงาน

tortoise = begin_point hare = begin_point  steps_count = 0 steps_limit = 2  loop forever:  if hare == end_point: return 'No Cycle Found'   hare = hare.next  steps_count += 1   if hare == tortoise: return 'Cycle Found'   if steps_count == steps_limit:  steps_count = 0  steps_limit *= 2  // Teleport the tortoise to hare's position  tortoise = hare 

การวิเคราะห์ความซับซ้อนเชิงเวลา

สำหรับขั้นตอนวิธีของเบรนท์นั้น จะมีประสิทธิภาพในการทำงานเท่ากับขั้นตอนวิธีตรวจสอบการมีวงรอบของฟลอยด์ (Floyd's Tortoise and the Hare algorithm) คือ O(λ+μ) โดย μ คือ ความยาวของทางเดินจากจุดเริ่มต้น ไปยังวงรอบ (Cycle) ที่มี λ จุดยอด แต่ในความเป็นจริงแล้ว ขั้นตอนวิธีตรวจสอบการมีวงรอบของเบรนท์ ใช้เวลาในการทำงานเฉลี่ยเร็วกว่าขั้นตอนวิธีตรวจสอบการมีวงรอบของฟลอยด์ประมาณ 36% ซึ่งมีผลทำให้ประสิทธิภาพการทำงานของ "ขั้นตอนวิธีโรห์ของพอลลาร์ด" (Pollard rho algorithm) เพิ่มขึ้นประมาณ 24% อีกด้วย


ขั้นตอนวิธีที่เกี่ยวข้อง


อ้างอิง

  1. Brent's cycle detection algorithm: Algorithmic cryptanalysis, Antoine Joux, Chapman & Hall/CRC Taylor & Francis Group, 2009, P.266
  2. http://lab.iisec.ac.jp/labs/tanaka/publications/pdf/conference/conference-86-02.pdf
  3. Brent, R. P. (1980), "An improved Monte Carlo factorization algorithm" (PDF), BIT, 20 (2): 176–184, doi:10.1007/BF01933190.

นตอนว, ของเบรนท, งกฤษ, brent, algorithm, เร, ยกอ, กช, อหน, งว, teleporting, turtle, algorithm, ได, บการค, ดค, นข, นโดย, richard, peirce, brent, ในป, 1980, เพ, อใช, ในการตรวจสอบการม, วงรอบ, cycle, ในป, ญหาท, กษณะเป, นรายการโยงเด, ยว, วอย, างเช, งก, นวนซ, การแยก. khntxnwithikhxngebrnth 1 xngkvs Brent s algorithm eriykxikchuxhnungwa The Teleporting Turtle Algorithm idrbkarkhidkhnkhunody Richard Peirce Brent inpi 1980 ephuxichinkartrwcsxbkarmiwngrxb 2 cycle inpyhathimilksnaepnraykaroyngediyw twxyangechn fngkchnwnsa karaeyktwprakxb twsrangelkhsumethiym aelapyhaxun xikmakmaykhntxnwithikhxngebrnth mihlkkarthangankhlay kbkhntxnwithitrwcsxbkarmiwngrxbkhxngflxyd Floyd s Tortoise and the Hare algorithm khxidepriybkhxngkhntxnwithikhxngebrnthkhuxcaichewlakarthangannxykwaaelasamarthhakhwamyawkhxngwngrxbidodytrng imcaepntxngilkhnhainladbyxyxikkhrng enuxha 1 twxyangkarichngan 2 karxthibaykhntxnwithi 2 1 Flow Chart 3 rhsethiymaesdngkarthangan 4 karwiekhraahkhwamsbsxnechingewla 5 khntxnwithithiekiywkhxng 6 xangxingtwxyangkarichngan aekikhcakrup hakerimedincakcud 2 camiesnthangkaredindngni 2 0 6 3 1 6 3 phbwakarwnsanimiwngrxb enuxngcakmikaredinthangsainesnthangedim khux 6 3 1 sungkhntxnwithikhxngebrnthmikhwamsamarthinkartrwcsxbkarmiwngcrechnniidnnexng karxthibaykhntxnwithi aekikhkarthangankhxngkhntxnwithikhxngebrnth 3 erimtnodykarkahndtwwnsa 2 twkhux kratay aela eta yunxyuthicuderimtn hlngcaknnih kratay edinipthilakawtamesnthang aelacathakarekhluxnyay eta mataaehnngediywkb kratay emuxthungewlathikahnd odyhak kratay edinipidthungcudcbkhxngraykaroyng nnaesdngwa immiwngrxb aethak kratay edinipecx eta aesdngwa miwngrxbFlow Chart aekikh rhsethiymaesdngkarthangan aekikhtortoise begin point hare begin point steps count 0 steps limit 2 loop forever if hare end point return No Cycle Found hare hare next steps count 1 if hare tortoise return Cycle Found if steps count steps limit steps count 0 steps limit 2 Teleport the tortoise to hare s position tortoise harekarwiekhraahkhwamsbsxnechingewla aekikhsahrbkhntxnwithikhxngebrnthnn camiprasiththiphaphinkarthanganethakbkhntxnwithitrwcsxbkarmiwngrxbkhxngflxyd Floyd s Tortoise and the Hare algorithm khux O l m ody m khux khwamyawkhxngthangedincakcuderimtn ipyngwngrxb Cycle thimi l cudyxd aetinkhwamepncringaelw khntxnwithitrwcsxbkarmiwngrxbkhxngebrnth ichewlainkarthanganechliyerwkwakhntxnwithitrwcsxbkarmiwngrxbkhxngflxydpraman 36 sungmiphlthaihprasiththiphaphkarthangankhxng khntxnwithiorhkhxngphxllard Pollard rho algorithm ephimkhunpraman 24 xikdwykhntxnwithithiekiywkhxng aekikhkhntxnwithitrwcsxbkarmiwngrxbkhxngflxyd Floyd s cycle finding algorithm khntxnwithiorhkhxngphxllard Pollard rho algorithm xangxing aekikh Brent s cycle detection algorithm Algorithmic cryptanalysis Antoine Joux Chapman amp Hall CRC Taylor amp Francis Group 2009 P 266 http lab iisec ac jp labs tanaka publications pdf conference conference 86 02 pdf Brent R P 1980 An improved Monte Carlo factorization algorithm PDF BIT 20 2 176 184 doi 10 1007 BF01933190 ekhathungcak https th wikipedia org w index php title khntxnwithikhxngebrnth amp oldid 4605852, wikipedia, วิกิ หนังสือ, หนังสือ, ห้องสมุด,

บทความ

, อ่าน, ดาวน์โหลด, ฟรี, ดาวน์โหลดฟรี, mp3, วิดีโอ, mp4, 3gp, jpg, jpeg, gif, png, รูปภาพ, เพลง, เพลง, หนัง, หนังสือ, เกม, เกม