Suche senden
Hochladen
PFDS 11.2 catenable double ended queue
•
0 gefällt mir
•
679 views
昌平 村山
Folgen
SimpleCatenableDeque までです。
Weniger lesen
Mehr lesen
Technologie
Melden
Teilen
Melden
Teilen
1 von 23
Jetzt herunterladen
Downloaden Sie, um offline zu lesen
Empfohlen
PFDS 10.2.1 lists with efficient catenation
PFDS 10.2.1 lists with efficient catenation
昌平 村山
Gaej Jdo
Gaej Jdo
katsu.taira
JastAdd & JastAddJ クリックチュートリアル
JastAdd & JastAddJ クリックチュートリアル
Fuminobu Takeyama
Entity Framework
Entity Framework
Nakashima Yujiro
夜子まま塾講義6(androidでhello world)
夜子まま塾講義6(androidでhello world)
Masafumi Terazono
XP寺子屋第9回「シンプル・プログラミング」
XP寺子屋第9回「シンプル・プログラミング」
takepu
PFDS 10.2.2 heaps with efficient merging
PFDS 10.2.2 heaps with efficient merging
昌平 村山
Lec3
Lec3
Nikhil Chilwant
Empfohlen
PFDS 10.2.1 lists with efficient catenation
PFDS 10.2.1 lists with efficient catenation
昌平 村山
Gaej Jdo
Gaej Jdo
katsu.taira
JastAdd & JastAddJ クリックチュートリアル
JastAdd & JastAddJ クリックチュートリアル
Fuminobu Takeyama
Entity Framework
Entity Framework
Nakashima Yujiro
夜子まま塾講義6(androidでhello world)
夜子まま塾講義6(androidでhello world)
Masafumi Terazono
XP寺子屋第9回「シンプル・プログラミング」
XP寺子屋第9回「シンプル・プログラミング」
takepu
PFDS 10.2.2 heaps with efficient merging
PFDS 10.2.2 heaps with efficient merging
昌平 村山
Lec3
Lec3
Nikhil Chilwant
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
CRI Japan, Inc.
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
atsushi061452
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
CRI Japan, Inc.
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
Hiroshi Tomioka
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
iPride Co., Ltd.
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
iPride Co., Ltd.
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NTT DATA Technology & Innovation
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Hiroshi Tomioka
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
iPride Co., Ltd.
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
Toru Tamaki
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
Toru Tamaki
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
Weitere ähnliche Inhalte
Kürzlich hochgeladen
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
CRI Japan, Inc.
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
atsushi061452
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
CRI Japan, Inc.
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
Hiroshi Tomioka
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
iPride Co., Ltd.
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
iPride Co., Ltd.
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NTT DATA Technology & Innovation
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Hiroshi Tomioka
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
iPride Co., Ltd.
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
Toru Tamaki
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
Toru Tamaki
Kürzlich hochgeladen
(11)
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
LoRaWAN スマート距離検出デバイスDS20L日本語マニュアル
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
論文紹介: The Surprising Effectiveness of PPO in Cooperative Multi-Agent Games
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
LoRaWANスマート距離検出センサー DS20L カタログ LiDARデバイス
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
業務で生成AIを活用したい人のための生成AI入門講座(社外公開版:キンドリルジャパン社内勉強会:2024年4月発表)
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その32024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
Amazon SES を勉強してみる その22024/04/26の勉強会で発表されたものです。
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
NewSQLの可用性構成パターン(OCHaCafe Season 8 #4 発表資料)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
Observabilityは従来型の監視と何が違うのか(キンドリルジャパン社内勉強会:2022年10月27日発表)
新人研修 後半 2024/04/26の勉強会で発表されたものです。
新人研修 後半 2024/04/26の勉強会で発表されたものです。
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Video-GroundingDINO: Towards Open-Vocabulary Spatio-Temporal Video Groun...
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
論文紹介:Selective Structured State-Spaces for Long-Form Video Understanding
Empfohlen
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
Skeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
Introduction to Data Science
Introduction to Data Science
Christy Abraham Joy
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
Vit Horky
The six step guide to practical project management
The six step guide to practical project management
MindGenius
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
Empfohlen
(20)
2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
Skeleton Culture Code
Skeleton Culture Code
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Getting into the tech field. what next
Getting into the tech field. what next
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
How to have difficult conversations
How to have difficult conversations
Introduction to Data Science
Introduction to Data Science
Time Management & Productivity - Best Practices
Time Management & Productivity - Best Practices
The six step guide to practical project management
The six step guide to practical project management
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
PFDS 11.2 catenable double ended queue
1.
PFDS #12
11.2 Catenable Double-Ended Queue @yuga 2012-12-01 Copyright © 2012 yuga 1
2.
動機
Queueを効率よく連結したい できればO(1)で Copyright © 2012 yuga 2
3.
Catenable Deque
連結可能なDequeのシグネチャ CATENABLEDEQUE : module type CATENABLEDEQUE = sig type ‘a cat val empty : ‘a cat val isEmpty : ‘a cat -> bool val snoc : ‘a cat * ‘a -> ‘a cat val head : ‘a cat -> ‘a val tail : ‘a cat -> ‘a cat val cons : ‘a * ‘a cat -> ‘a cat val last : ‘a cat -> ‘a val init : ‘a cat -> ‘a cat val (++) : ‘a cat -> ‘a cat -> ‘a cat end Copyright © 2012 yuga 3
4.
Catenable Deque
連結可能なDequeのシグネチャ CATENABLEDEQUE : module type CATENABLEDEQUE = sig type ‘a cat include module DEQUE with type ‘a queue := ‘a cat val (++) : ‘a cat -> ‘a cat -> ‘a cat end Copyright © 2012 yuga 4
5.
解決の方針
DequeをDequeにいれる (Structural Abstraction) BootStrapped type SimpleCatenableDeque (初級編) ImplicitCatenableDeque (上級編) Primitive type これまでに登場したDeque (ただしImplicitCatenableDequeの実装には Dequeの要素数を返すsize関数の実装が必要) ※すべての関数がO(1)時間で実行可能であること。 (実時間/償却時間いずれでもよい) Copyright © 2012 yuga 5
6.
SimpleCatenableDequeの実装
データ構造 SHALLOW … 単体のDeque DEEP … 連結したDeque front – middle – rearの3パーツ構成 frontとrearは必ず2個以上の要素を持つ module SimpleCatenableDeque (D : DEQUE) : CATENABLEDEQUE = struct type ‘a cat = SHALLOW of ‘a D.queue | DEEP of ‘a D.queue (* front *) * ‘a D.queue cat susp (* middle *) * ‘a D.queue (* rear *) … Copyright © 2012 yuga 6
7.
図解: 実装 (cons)
consやsnocは直接PrimitiveのDequeに要素を入れる。 0 1 2 SHALLOW ‘a D.queue 0 1 2 3 4 DEEP front middle rear Copyright © 2012 yuga 7
8.
実装 (++)
5パターンある。DEEPのmiddleについては再帰的に行う。 1. どちらかが2未満の要素を持つSHALLOW同士の連結 2. どちらも2以上の要素をもつSHALLOW同士の連結 3. DEEPと2未満の要素を持つSHALLOWの連結 4. DEEPと2以上の要素を持つSHALLOWの連結 5. DEEP同士の連結 a. middle:どちらかが2未満の要素を持つSHALLOW同士の連結 b. middle:どちらも2以上の要素をもつSHALLOW同士の連結 c. middle:DEEPと2未満の要素を持つSHALLOWの連結 d. middle:DEEPと2以上の要素を持つSHALLOWの連結 e. middle:DEEP同士の連結 i. middle:… … T(m+n) = T((m – (4 + c))/2) + T((n – (4 + d))/2) + O(1) = O(min (log(m), log(n))) Copyright © 2012 yuga 8
9.
図解: 実装 (++)
1. どちらかが2未満の要素を持つSHALLOW同士の連結 1 2 ++ 3 SHALLOW ‘a D.queue 1 2 3 Copyright © 2012 yuga 9
10.
図解: 実装 (++)
2. どちらも2以上の要素をもつSHALLOW同士の連結 1 2 ++ 3 4 1 2 3 4 DEEP front middle rear Copyright © 2012 yuga 10
11.
図解: 実装 (++)
++ 3. DEEPと2未満の要素を持つSHALLOWの連結 1 2 3 4 ++ 5 1 2 3 4 5 Copyright © 2012 yuga 11
12.
図解: 実装 (++)
5a. DEEPと2以上の要素を持つSHALLOWの連結 1 2 3 4 ++ 5 6 1 2 3 4 5 6 Copyright © 2012 yuga 12
13.
図解: 実装 (++)
5a. DEEP同士の連結( middle:どちらかが2未満の要素を持つSHALLOW同士の連結) 1 2 3 4 ++ 5 6 7 8 3 4 ++ 5 6 3 4 1 2 7 8 5 6 Copyright © 2012 yuga 13
14.
図解: 実装 (++)
5b. DEEP同士の連結(middle:どちらも2以上の要素をもつSHALLOW同士の連結) ++ 3 4 11 12 1 2 7 8 9 10 15 16 5 6 13 14 3 4 9 10 5 6 ++ 11 12 7 8 13 14 3 4 9 10 1 2 5 6 11 12 15 16 7 8 13 14 14 Copyright © 2012 yuga
15.
図解: 実装 (++)
5e. DEEP同士の連結(middle:DEEP同士の連結) 3 4 9 10 19 20 25 26 1 2 5 7 6 8 11 13 12 14 15 16 ++ 17 18 21 23 22 24 27 29 28 30 31 32 3 4 9 10 17 18 25 26 ++ 5 6 11 12 19 20 27 28 7 8 13 14 21 22 29 30 15 16 23 24 9 10 17 18 11 12 19 20 13 14 ++ 21 22 15 16 23 24 15 Copyright © 2012 yuga
16.
実装 (tail)
SHALLOWはそのまま。DEEPは先頭を除去後、frontの要素数が2 以上になるならそのまま、そうでないならSHALLOWにする。 1. SHALLOWをtail 2. DEEP(frontが3個以上)をtail 3. DEEP(frontが2個、middleが0個)をtail 4. DEEP(frontが2個、middleが1個以上)をtail Copyright © 2012 yuga 16
17.
図解: 実装 (tail)
1. SHALLOWをtail 1 2 3 1 2 3 Copyright © 2012 yuga 17
18.
図解: 実装 (tail)
2. DEEP(frontが3個以上)をtail 2 3 4 5 6 7 8 2 3 4 5 6 7 8 Copyright © 2012 yuga 18
19.
図解: 実装 (tail)
3. DEEP(frontが2個、middleが0個)をtail 1 2 3 4 1 2 3 4 1 1 2 3 Copyright © 2012 yuga 19
20.
図解: 実装 (tail)
4. DEEP(frontが2個、middleが1個以上)をtail 3 4 1 2 7 8 5 6 3 4 1 2 7 8 5 6 2 1 7 8 3 4 5 6 1 2 3 4 5 6 7 8 Copyright © 2012 yuga 20
21.
Exercise 11.3: tailが償却実行時間O(1)か?
DEEPに、middleのsuspensionを作成するとき、そのmiddleに1 debitを割り当てる。 次にmiddleを操作するときまでに返却しなければならない。 Debit Invariant: 0 if frontが2個 DEEPのdebit数の上限 = 1 if frontが3個以上 tail時に繰り下がり処理のため middleを操作することになるから Copyright © 2012 yuga 21
22.
Exercise 11.3: tailが償却実行時間O(1)か?
振り返り(9.2.3 Lazy Representation) 3個以上 2個 繰り下がりを再帰的に行うこ とでdebitは発生するが、返却 が必要なdebitはO(1) Copyright © 2012 yuga 22
23.
Exercise 11.3: tailが償却実行時間O(1)か?
1. SHALLOWをtail SHALLOWには既存debitが存在しない。 SHALLOWのtail操作では新規debitは発生しない。 2. DEEP(frontが3個以上)をtail tail前はfrontが3個以上なので、middleにdebitが1割り当てられている。 middleを操作しないので新規debitは発生しない。 tail操作後、frontが2個になる場合: – debitの許容数は-1。 – したがって合計1debitを返却する。 3. DEEP(frontが2個、middleが0個)をtail tail前はfrontが2個なので、middleに割り当てられたdebitは0。 middleを破棄するので新規debitは発生しない。 tail後、SHALLOWになりdebit許容数が-1。 4. DEEP(frontが2個、middleが1個以上)をtail tail前はfrontが2なので、middleに割り当てられたdebitは0。 middleの操作でsuspensionを作成しているので、middleに新規debitが1発生する。 tail後はfrontは3個以上なので、debit許容数は+1 したがってO(1) Copyright © 2012 yuga 23
Jetzt herunterladen