SlideShare une entreprise Scribd logo
1  sur  42
2.3.5

        twitter.com/jun0683
0




           a               e
        b c d          f       g
                               h

(a:(b,c,d),e:(f,g,:(h)))
RLINK :

DLINK :
A=(b,c,d)                          LIST=(A,a,(A,A))

  b we might expectA=(c,d) ways to representthe same basic within
   As
                 , ,These are many variations on List structures theme
a computer memory.
                     there
                           are usually
according to which binary trees are used to represent general forests of trees:
                 8ay, is used to point to the next element of a List, and another
  LIST            3                                      ->                   b
one field
     ‘
field DLINI may be used to point to the first element of a sub-List. By a natural
extension of the memory representation described in Section 2.3.2, we would
represent the List (5) as follows:


                          b (atom)           c                 e

                                                                    -
                                                                    -
                             g
                                                                              (6)



                                                   -
                                                   -
a       b (atom)   c
                       -
                       -
          9

                           (7)



    -
    -                  -
                       -
Memory          &raight linkage              Circular linkagc               Doublc linkagc

   ……
location

   ……
           INFO     DLINK    RLINK     INFO      DLINK
                                                  L…
                                                   m
                                                           RLINK     INFO
                                                                            h
                                                                            [
                                                                                      o
                                                                                      om
                                                                                             RLINK



                                                                ……                    om
                                        (t
            b                                          m              ’6V   W
                                        b
                                                                                      o
   mw
            c
            e                     A
                                  m
                                        c
                                        t
                                                   O%
                                                   Om           m
                                                                      FU
                                                                            ( mm
                                                                            {
                                                                            h
                                                                                ”     O mm
                                                                                      O
                                                                                               m
                                                                                               m (8)
            -f                          -f                            -f
   m                   m                           I   m                    l m       O%
            g                     A      g         l %                g     l %       om
            -d                    m      -d        Lm  a              -d    h m
                                                                              J       l %      m
                                  A                o%                       {         0%
   m                              A                ka           m           h         1m       m
            -                                     ’m                        h          I
   m        h                     mm               om           mm
                                                                      h
                                                                            ( m        I %
            J                     A                0m
                                                    w           m           { m       l %
                                        3                             J



Here “LLINK" is used for a pointe1' to the left in a doubly linked 1'epresentation.
MIX
         a) 1

                S       T         REF         RLINK
         b)2
                S       T        LLINK RLINK
                            INFO
s(   )  :
t(   )  : t=0                    ,t=1
          t>1
REF     :
L,RLINK :
INFO    :                   .(                        ,
                    ,                   ..)
!




!
(reference counter)
    (                      )

               (       )

(         ?)

    (garbage collection)
1

            2

(   )           0
A

                    NODE(1),NODE(2),...,NODE(M)
      m




A1.
                             (
          )              1

K=1           //K
A2.
K1=K+1           //K1 , K
if(NODE(K) !=        || NODE(K) !=           )
   A3.
else
   if(NODE(ALINK(K)) !=         )//
         NODE(ALINK(K)) =
         if(NODE(ALINK(K)) !=            )
                K1 = min(K1,ALINK(K))
         if(NODE(BLINK(K)) !=        )
                K1 = min(K1,BLINK(K))
A3.
K=K1

if(k<=M)

       A2

else
A
1               m

K               m

K K1            m

    K K1        m

         K K1   m
B



STACK[1],.....



B1.
T
      STACK[1].....,STACK[T]
B2.
/ T
 /    STACK   TOP   ,

if(T=0)

  end
B3.
//stack pop, K

K = STACK[T]

T=T-1
B4.
if(NODE(K) ==    )
   B2
else
   if(NODE(ALINK(K)) !=     )
      NODE(ALINK(K)) =
     T=T+1 //stack push
     STACK[T] = ALINK(K)
  if(NODE(BLINK(K)) !=      )
     NODE(BLINK(K)) =
      T=T+1
      STACK[T] = BLINK(K)
B

                    v                   m

                        v               m

    9           5           v           m

7 7         3 3                 v       m

1   1   1   1   1                   v   m
..

..
C


H
STACK[0],....STACK[H-1]
       X
  T = (T+1)%H
  STACK[T] = X
T=B
  B = (B+1)%H
  K1 = min(K1,STACK[B])
C1.

T = H-1 //TOP

B = H-1 //BOTTOM

K1 = M + 1 //

                   (   % push)
C2.

if(T==B)

  C5
C3

//stack pop

K = STACK[T]

T = (T-1)%H
C4
if(NODE(K) ==      )

   C2

else
   if(NODE(ALINK(K)) !=      )

        NODE(ALINK(K)) =
        ALINK(K)       ( % push)

   if(NODE(BLINK(K)) !=     )

        NODE(BLINK(K)) =

        BLINK(K)       ( % push)

   C2
C5
if( K1 > M ) //                       T=B
                                            B = (B+1)%H

  end                                       K1 = min(K1,STACK[B])


else
  if(NODE(K1) ==     || NODE(K1) !=    )
       K1 = K1 + 1
       C5
  if (NODE(K1) ==    )
       K = K1
       K = K1 + 1
       C4
C
            v                           m
  9     5
                    v                   m
                        v               m
7 7   3 3                   v           m
                                v       m
1 1 1 1 6                           v   m
D

         A,B,C

                 ALINK           BLINK   S,T,REF,RLINK


s(   )  :
t(   )  : t=0             ,t=1
          t>1
REF     :
L,RLINK :
INFO    :            .(                     ,
                 ,               ..)
D1.
//TOP
TOP = NULL
                        P
if(S(P) == 0)
  S(P)=1
  REF(P) = TOP // TOP
  TOP = P
D2.

if(TOP == NULL) //

  end
D3

//TOP          pop

P = TOP

TOP = REF(P)
D4.
P = RLINK(P)
if(P == NULL || T(P) == 0)//
  D2
else
  S(P) = 1
  if(T(P) > 1) //
       S(REF(P)) = 1
  else
       Q = REF(P)
       if(Q != NULL && S(Q) == 0)
             S(Q) = 1
             REF(Q) = TOP
             TOP = Q
             D4
B                                                TOP,Q



                                                                   After      Aftcl'
                                                                   ALINK      BLINK


                                          E4.              E5.
    El.          E2.                     Down              Down              E6. Up
  Tnitinlìzc    Mnrk                     ALINK I Mnrkcd    BLINK I :hrked
                                                 already          alrcady

                       Fig. 38. Flowchart f0 1' AIgorithm E.

E5. [Down BLINK.]     Set Q • BLINK(P). If Q     A and MARK(Q) = 0 , set
    BLINK(P) • T, T • P, P • Q, and go to E2.
E6. [Up.] (This step undoes the link switching made in step E4 or E5; the
    setting of ATOM (T) tells      ALINK(T) or BLINK (T) is to be restored.)
E   (1965   ...-_-)




MARK(1       )

ATOM(                1         )

  0,1

ALINK

BLINK
E1.

T=NULL   //   T   2        NULL   TOP   P


P = P0 //             P0
E2.

MARK(P) = 1 //
E3.

if(ATOM(P) == 1) //   0

  E6
E4.

Q = ALINK(P)

if (Q != NULL && MARK(Q) == 0)

      ATOM(P) = 1

      ALINK(P) = T

      T=P

      p=Q

      E2
E5

Q = BLINK(P)

if(Q != NULL && MARK(Q) == 0)

     BLINK(P) = T

  T=P

     P=Q

     E2
E6
if(T == NULL)
   end
else
  Q=T
  if(ATOM(Q) == 1)   if(ATOM(Q) == 0)
     ATOM(Q) = 0       T = BLINK(Q)
     T = ALINK(Q)
                       BLINK(Q) = P
     ALINK(Q) = P
     P=Q               P=Q
     E5                E6

Contenu connexe

En vedette

프로그램은 왜 실패 하는가
프로그램은 왜 실패 하는가프로그램은 왜 실패 하는가
프로그램은 왜 실패 하는가
홍준 김
 
Holub on Patterns 1장 전
Holub on Patterns 1장 전Holub on Patterns 1장 전
Holub on Patterns 1장 전
홍준 김
 

En vedette (6)

프로그램은 왜 실패 하는가
프로그램은 왜 실패 하는가프로그램은 왜 실패 하는가
프로그램은 왜 실패 하는가
 
Taocp 2.1~2.2
Taocp 2.1~2.2Taocp 2.1~2.2
Taocp 2.1~2.2
 
Holub on Patterns 1장 전
Holub on Patterns 1장 전Holub on Patterns 1장 전
Holub on Patterns 1장 전
 
Taocp 2.3
Taocp 2.3Taocp 2.3
Taocp 2.3
 
Taocp
TaocpTaocp
Taocp
 
5장
5장5장
5장
 

Plus de 홍준 김

1.3장 차수 높은 프로시저(higher order procedure)로 요약하는 방법
1.3장 차수 높은 프로시저(higher order procedure)로 요약하는 방법1.3장 차수 높은 프로시저(higher order procedure)로 요약하는 방법
1.3장 차수 높은 프로시저(higher order procedure)로 요약하는 방법
홍준 김
 
11장 윈도우 스레드 풀 + 12장 파이버
11장 윈도우 스레드 풀 + 12장 파이버11장 윈도우 스레드 풀 + 12장 파이버
11장 윈도우 스레드 풀 + 12장 파이버
홍준 김
 
11장 윈도우 스레드 풀
11장 윈도우 스레드 풀11장 윈도우 스레드 풀
11장 윈도우 스레드 풀
홍준 김
 
Html5&css 3장
Html5&css 3장Html5&css 3장
Html5&css 3장
홍준 김
 
Mongo db문서의생성,갱신,삭제
Mongo db문서의생성,갱신,삭제Mongo db문서의생성,갱신,삭제
Mongo db문서의생성,갱신,삭제
홍준 김
 
ManagingHumans/chap25~29
ManagingHumans/chap25~29ManagingHumans/chap25~29
ManagingHumans/chap25~29
홍준 김
 
2장 상태구도형 에이전트의 디자인
2장 상태구도형 에이전트의 디자인2장 상태구도형 에이전트의 디자인
2장 상태구도형 에이전트의 디자인
홍준 김
 

Plus de 홍준 김 (7)

1.3장 차수 높은 프로시저(higher order procedure)로 요약하는 방법
1.3장 차수 높은 프로시저(higher order procedure)로 요약하는 방법1.3장 차수 높은 프로시저(higher order procedure)로 요약하는 방법
1.3장 차수 높은 프로시저(higher order procedure)로 요약하는 방법
 
11장 윈도우 스레드 풀 + 12장 파이버
11장 윈도우 스레드 풀 + 12장 파이버11장 윈도우 스레드 풀 + 12장 파이버
11장 윈도우 스레드 풀 + 12장 파이버
 
11장 윈도우 스레드 풀
11장 윈도우 스레드 풀11장 윈도우 스레드 풀
11장 윈도우 스레드 풀
 
Html5&css 3장
Html5&css 3장Html5&css 3장
Html5&css 3장
 
Mongo db문서의생성,갱신,삭제
Mongo db문서의생성,갱신,삭제Mongo db문서의생성,갱신,삭제
Mongo db문서의생성,갱신,삭제
 
ManagingHumans/chap25~29
ManagingHumans/chap25~29ManagingHumans/chap25~29
ManagingHumans/chap25~29
 
2장 상태구도형 에이전트의 디자인
2장 상태구도형 에이전트의 디자인2장 상태구도형 에이전트의 디자인
2장 상태구도형 에이전트의 디자인
 

Dernier

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Dernier (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 

Taocp 2.3.5

  • 1. 2.3.5 twitter.com/jun0683
  • 2. 0 a e b c d f g h (a:(b,c,d),e:(f,g,:(h)))
  • 4. A=(b,c,d) LIST=(A,a,(A,A)) b we might expectA=(c,d) ways to representthe same basic within As , ,These are many variations on List structures theme a computer memory. there are usually according to which binary trees are used to represent general forests of trees: 8ay, is used to point to the next element of a List, and another LIST 3 -> b one field ‘ field DLINI may be used to point to the first element of a sub-List. By a natural extension of the memory representation described in Section 2.3.2, we would represent the List (5) as follows: b (atom) c e - - g (6) - -
  • 5. a b (atom) c - - 9 (7) - - - -
  • 6.
  • 7. Memory &raight linkage Circular linkagc Doublc linkagc …… location …… INFO DLINK RLINK INFO DLINK L… m RLINK INFO h [ o om RLINK …… om (t b m ’6V W b o mw c e A m c t O% Om m FU ( mm { h ” O mm O m m (8) -f -f -f m m I m l m O% g A g l % g l % om -d m -d Lm a -d h m J l % m A o% { 0% m A ka m h 1m m - ’m h I m h mm om mm h ( m I % J A 0m w m { m l % 3 J Here “LLINK" is used for a pointe1' to the left in a doubly linked 1'epresentation.
  • 8. MIX a) 1 S T REF RLINK b)2 S T LLINK RLINK INFO s( ) : t( ) : t=0 ,t=1 t>1 REF : L,RLINK : INFO : .( , , ..)
  • 9. ! !
  • 10. (reference counter) ( ) ( ) ( ?) (garbage collection)
  • 11. 1 2 ( ) 0
  • 12. A NODE(1),NODE(2),...,NODE(M) m A1. ( ) 1 K=1 //K
  • 13. A2. K1=K+1 //K1 , K if(NODE(K) != || NODE(K) != ) A3. else if(NODE(ALINK(K)) != )// NODE(ALINK(K)) = if(NODE(ALINK(K)) != ) K1 = min(K1,ALINK(K)) if(NODE(BLINK(K)) != ) K1 = min(K1,BLINK(K))
  • 14. A3. K=K1 if(k<=M) A2 else
  • 15. A 1 m K m K K1 m K K1 m K K1 m
  • 16.
  • 17. B STACK[1],..... B1. T STACK[1].....,STACK[T]
  • 18. B2. / T / STACK TOP , if(T=0) end
  • 19. B3. //stack pop, K K = STACK[T] T=T-1
  • 20. B4. if(NODE(K) == ) B2 else if(NODE(ALINK(K)) != ) NODE(ALINK(K)) = T=T+1 //stack push STACK[T] = ALINK(K) if(NODE(BLINK(K)) != ) NODE(BLINK(K)) = T=T+1 STACK[T] = BLINK(K)
  • 21. B v m v m 9 5 v m 7 7 3 3 v m 1 1 1 1 1 v m
  • 22. .. ..
  • 23. C H STACK[0],....STACK[H-1] X T = (T+1)%H STACK[T] = X T=B B = (B+1)%H K1 = min(K1,STACK[B])
  • 24. C1. T = H-1 //TOP B = H-1 //BOTTOM K1 = M + 1 // ( % push)
  • 26. C3 //stack pop K = STACK[T] T = (T-1)%H
  • 27. C4 if(NODE(K) == ) C2 else if(NODE(ALINK(K)) != ) NODE(ALINK(K)) = ALINK(K) ( % push) if(NODE(BLINK(K)) != ) NODE(BLINK(K)) = BLINK(K) ( % push) C2
  • 28. C5 if( K1 > M ) // T=B B = (B+1)%H end K1 = min(K1,STACK[B]) else if(NODE(K1) == || NODE(K1) != ) K1 = K1 + 1 C5 if (NODE(K1) == ) K = K1 K = K1 + 1 C4
  • 29. C v m 9 5 v m v m 7 7 3 3 v m v m 1 1 1 1 6 v m
  • 30. D A,B,C ALINK BLINK S,T,REF,RLINK s( ) : t( ) : t=0 ,t=1 t>1 REF : L,RLINK : INFO : .( , , ..)
  • 31. D1. //TOP TOP = NULL P if(S(P) == 0) S(P)=1 REF(P) = TOP // TOP TOP = P
  • 33. D3 //TOP pop P = TOP TOP = REF(P)
  • 34. D4. P = RLINK(P) if(P == NULL || T(P) == 0)// D2 else S(P) = 1 if(T(P) > 1) // S(REF(P)) = 1 else Q = REF(P) if(Q != NULL && S(Q) == 0) S(Q) = 1 REF(Q) = TOP TOP = Q D4
  • 35. B TOP,Q After Aftcl' ALINK BLINK E4. E5. El. E2. Down Down E6. Up Tnitinlìzc Mnrk ALINK I Mnrkcd BLINK I :hrked already alrcady Fig. 38. Flowchart f0 1' AIgorithm E. E5. [Down BLINK.] Set Q • BLINK(P). If Q A and MARK(Q) = 0 , set BLINK(P) • T, T • P, P • Q, and go to E2. E6. [Up.] (This step undoes the link switching made in step E4 or E5; the setting of ATOM (T) tells ALINK(T) or BLINK (T) is to be restored.)
  • 36. E (1965 ...-_-) MARK(1 ) ATOM( 1 ) 0,1 ALINK BLINK
  • 37. E1. T=NULL // T 2 NULL TOP P P = P0 // P0
  • 40. E4. Q = ALINK(P) if (Q != NULL && MARK(Q) == 0) ATOM(P) = 1 ALINK(P) = T T=P p=Q E2
  • 41. E5 Q = BLINK(P) if(Q != NULL && MARK(Q) == 0) BLINK(P) = T T=P P=Q E2
  • 42. E6 if(T == NULL) end else Q=T if(ATOM(Q) == 1) if(ATOM(Q) == 0) ATOM(Q) = 0 T = BLINK(Q) T = ALINK(Q) BLINK(Q) = P ALINK(Q) = P P=Q P=Q E5 E6

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n