Lista Duplamente Encandeada New(p);

34
P Lista Duplamente Encandeada New(p); 0 AA AA LISTA DUPLAMENTE ENCADEADA – INCLUSÃO QUANDO LISTA VAZIA

description

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO QUANDO LISTA VAZIA. P. AA. Lista Duplamente Encandeada New(p);. AA. 0. LISTA DUPLAMENTE ENCADEADA – INCLUSÃO QUANDO LISTA VAZIA. P. AA. Lista Duplamente Encandeada New(p); P^.prox := nil;. AA. 0. Prox =NIL. - PowerPoint PPT Presentation

Transcript of Lista Duplamente Encandeada New(p);

Page 1: Lista Duplamente Encandeada New(p);

P

Lista Duplamente Encandeada

New(p);

0

AA

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO QUANDO LISTA VAZIA

Page 2: Lista Duplamente Encandeada New(p);

P

Lista Duplamente Encandeada

New(p);P^.prox := nil;

0 Pr

ox=N

IL

AA

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO QUANDO LISTA VAZIA

Page 3: Lista Duplamente Encandeada New(p);

P

Lista Duplamente Encandeada

New(p);P^.prox := nil;P^.ant := nil;

0 Prox

=NIL

AA

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO QUANDO LISTA VAZIA

Ant=

NIL

Page 4: Lista Duplamente Encandeada New(p);

P

Lista Duplamente Encandeada

New(p);P^.prox := nil;P^.ant := nil;L := P;

0 Pr

ox=N

IL

AA

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO QUANDO LISTA VAZIA

Ant=

NIL

LAA

Page 5: Lista Duplamente Encandeada New(p);

P

Lista Duplamente Encandeada

New(p);P^.prox := nil;P^.ant := nil;L := P;F := P;

001 Jose0 R$ 1500,00 Pr

ox=N

IL

AA

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO QUANDO LISTA VAZIA

Ant=

NIL

FAAL

AA

Page 6: Lista Duplamente Encandeada New(p);

P

Lista Duplamente Encandeada

New(f^.prox);

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO SEQUENCIAL NO FINAL DA LISTA

Ant=

NIL

LAA

FAA

BB

Page 7: Lista Duplamente Encandeada New(p);

P

Lista Duplamente Encandeada

New(f^.prox);P:= f^.prox;

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

BB

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO SEQUENCIAL NO FINAL DA LISTA

Ant=

NIL

LAA

FAA

BB

Page 8: Lista Duplamente Encandeada New(p);

P

Lista Duplamente Encandeada

New(f^.prox);P:= f^.prox;p^.ant :=F

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

BB

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO SEQUENCIAL NO FINAL DA LISTA

Ant=

NIL

LAA

FAA

BB

Ant A

A

Page 9: Lista Duplamente Encandeada New(p);

P

Lista Duplamente Encandeada

New(f^.prox);P:= f^.prox;p^.ant :=F;F := P;

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

BB

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO SEQUENCIAL NO FINAL DA LISTA

Ant=

NIL

LAA

FBB

BB

Ant A

A

Page 10: Lista Duplamente Encandeada New(p);

P

Lista Duplamente Encandeada

New(f^.prox);P:= f^.prox;p^.ant :=F;F := P;P^.prox := nil;

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

BB

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO SEQUENCIAL NO FINAL DA LISTA

Ant=

NIL

LAA

FBB

002 Antonio R$ 1000,00 Pr

ox=N

IL

BB

Ant A

A

Page 11: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO INICIO DA LISTA

Ant=

NIL

LAA

FBB

002 Antonio R$ 1000,00 Pr

ox=N

IL

BB

Ant A

A

Page 12: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

New(P);

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO INICIO DA LISTA

Ant=

NIL

LAA

FBB

002 Antonio R$ 1000,00 Pr

ox=N

IL

BB

Ant A

AP

0 Pr

ox=N

IL

CC

CC

Page 13: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

New(P);P^.prox := L;

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO INICIO DA LISTA

Ant=

NIL

LAA

FBB

002 Antonio R$ 1000,00 Pr

ox=N

IL

BB

Ant A

AP

0 Pr

ox=A

A

CC

CC

Page 14: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

New(P);P^.prox := L;P^.ant := nil;

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO INICIO DA LISTA

Ant=

NIL

LAA

FBB

002 Antonio R$ 1000,00 Pr

ox=N

IL

BB

Ant A

AP

0 Pr

ox=A

A

CC

CC

Ant=

NIL

Page 15: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

New(P);P^.prox := L;P^.ant := nil;L^.ant : P;

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO INICIO DA LISTA

Ant=

CC

LAA

FBB

002 Antonio R$ 1000,00 Pr

ox=N

IL

BB

Ant A

AP

0 Pr

ox=A

A

CC

CC

Ant=

NIL

Page 16: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

New(P);P^.prox := L;P^.ant := nil;L^.ant : P;L := P;

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO INICIO DA LISTA

Ant=

CC

LCC

FBB

002 Antonio R$ 1000,00 Pr

ox=N

IL

BB

Ant A

AP

0 Pr

ox=A

A

CC

CC

Ant =

NIL

Page 17: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

New(P);P^.prox := L;P^.ant := nil;L^.ant : P;L := P;

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

LISTA DUPLAMENTE ENCADEADA – INCLUSÃO INICIO DA LISTA

Ant=

CC

LCC

FBB

002 Antonio R$ 1000,00 Pr

ox=N

IL

BB

Ant A

A

P

003 Carlos0 R$ 780,00 Pr

ox=A

A

CC

CC

Ant=

NIL

Page 18: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada 001

Jose0 R$ 1500,00 Pr

ox=B

B

AA

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO FINAL DA LISTA

Ant=

CC

LCC

FBB

002 Antonio R$ 1000,00 Pr

ox=N

IL

BB

Ant A

A 003 Carlos0 R$ 780,00 Pr

ox=A

A

CC

Ant=

NIL

Page 19: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

P := F^.ant;

001 Jose0 R$ 1500,00 Pr

ox=B

B

AA

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO FINAL DA LISTA

Ant=

CC

LCC

FBB

002 Antonio R$ 1000,00 Pr

ox=N

IL

BB

Ant A

A 003 Carlos0 R$ 780,00 Pr

ox=A

A

CC

Ant=

NIL

PAA

Page 20: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

P := F^.ant;P^.prox := NIL;

001 Jose0 R$ 1500,00 Pr

ox=N

IL

AA

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO FINAL DA LISTA

Ant=

CC

LCC

FBB

002 Antonio R$ 1000,00 Pr

ox=N

IL

BB

Ant A

A 003 Carlos0 R$ 780,00 Pr

ox=A

A

CC

Ant=

NIL

PAA

Page 21: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

P := F^.ant;P^.prox := NIL;Dispose(F);

001 Jose0 R$ 1500,00 Pr

ox=N

IL

AA

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO FINAL DA LISTA

Ant=

CC

LCC

FBB

002 Antonio R$ 1000,00 Pr

ox=N

IL

BB

Ant A

A 003 Carlos0 R$ 780,00 Pr

ox=A

A

CC

Ant=

NIL

PAA

Page 22: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

P := F^.ant;P^.prox := NIL;Dispose(F);F:= P;

001 Jose0 R$ 1500,00 Pr

ox=N

IL

AA

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO FINAL DA LISTA

Ant=

CC

LCC

FBB

003 Carlos0 R$ 780,00 Pr

ox=A

A

CC

Ant=

NIL

PAA

Page 23: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

001 Jose0 R$ 1500,00 Pr

ox=N

IL

AA

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO NO INICIO/FINAL QUANDO LISTA TEM SOMENTE UM ELEMENTO

Ant=

NIL

FAAL

AA

Page 24: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

Dispose(F); 001 Jose0 R$ 1500,00 Pr

ox=N

IL

AA

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO NO INICIO/FINAL QUANDO LISTA TEM SOMENTE UM ELEMENTO

Ant=

NIL

FAAL

AA

Page 25: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

Dispose(F);

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO NO INICIO/FINAL QUANDO LISTA TEM SOMENTE UM ELEMENTO

FAAL

AA

Page 26: Lista Duplamente Encandeada New(p);

Lista Duplamente Encandeada

Dispose(F);L :=NIL;F := NIL;

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO NO INICIO/FINAL QUANDO LISTA TEM SOMENTE UM ELEMENTO

FAAL

AA

Page 27: Lista Duplamente Encandeada New(p);

002 Antonio R$ 1000,00 Pr

ox=C

C

BB

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO EM UMA POSICAO

Ant=

AA

LCC

FBB

004 Judite R$ 1000,00 Pr

ox=N

IL

DD

Ant C

C 001 Jose0 R$ 1500,00 Pr

ox=A

A

AA

Ant=

NIL 003

Carlos0 R$ 1800,00 Pr

ox=D

D

CC

Ant=

BB

Digite a Posição da Lista.: 3

R:= L;P:= L^.PROX;Cont := 1;While (cont < posi-1) doBegin r:= r^.prox; p := p^.prox; cont := cont + 1;End;

Page 28: Lista Duplamente Encandeada New(p);

002 Antonio R$ 1000,00 Pr

ox=C

C

BB

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO EM UMA POSICAO

Ant=

AA

LCC

FBB

004 Judite R$ 1000,00 Pr

ox=N

IL

DD

Ant C

C 001 Jose0 R$ 1500,00 Pr

ox=A

A

AA

Ant=

NIL 003

Carlos0 R$ 1800,00 Pr

ox=D

D

CC

Ant=

BB

Digite a Posição da Lista.: 3

RAA

pBB

R:= L;P:= L^.PROX;Cont := 1;While (cont < posi-1) doBegin r:= r^.prox; p := p^.prox; cont := cont + 1;End;

Page 29: Lista Duplamente Encandeada New(p);

R:= L;P:= L^.PROX;Cont := 1;While (cont < posi-1) doBegin r:= r^.prox; p := p^.prox; cont := cont + 1;End;

002 Antonio R$ 1000,00 Pr

ox=C

C

BB

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO EM UMA POSICAO

Ant=

AA

LCC

FBB

004 Judite R$ 1000,00 Pr

ox=N

IL

DD

Ant C

C 001 Jose0 R$ 1500,00 Pr

ox=A

A

AA

Ant=

NIL 003

Carlos0 R$ 1800,00 Pr

ox=D

D

CC

Ant=

BB

Digite a Posição da Lista.: 3

RAA

pBB

Page 30: Lista Duplamente Encandeada New(p);

R:= L;P:= L^.PROX;Cont := 1;While (cont < posi-1) doBegin r:= r^.prox; p := p^.prox; cont := cont + 1;End;X := p^.prox;

002 Antonio R$ 1000,00 Pr

ox=C

C

BB

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO EM UMA POSICAO

Ant=

AA

LCC

FBB

004 Judite R$ 1000,00 Pr

ox=N

IL

DD

Ant C

C 001 Jose0 R$ 1500,00 Pr

ox=A

A

AA

Ant=

NIL 003

Carlos0 R$ 1800,00 Pr

ox=D

D

CC

Ant=

BB

Digite a Posição da Lista.: 3

RBB

pCC

XDD

Page 31: Lista Duplamente Encandeada New(p);

R:= L;P:= L^.PROX;Cont := 1;While (cont < posi-1) doBegin r:= r^.prox; p := p^.prox; cont := cont + 1;End;X := p^.prox;X^.ant := R;

002 Antonio R$ 1000,00 Pr

ox=C

C

BB

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO EM UMA POSICAO

Ant=

AA

LCC

FBB

004 Judite R$ 1000,00 Pr

ox=N

IL

DD

Ant B

B 001 Jose0 R$ 1500,00 Pr

ox=A

A

AA

Ant=

NIL 003

Carlos0 R$ 1800,00 Pr

ox=D

D

CC

Ant=

BB

Digite a Posição da Lista.: 3

RBB

pCC

XDD

Page 32: Lista Duplamente Encandeada New(p);

R:= L;P:= L^.PROX;Cont := 1;While (cont < posi-1) doBegin r:= r^.prox; p := p^.prox; cont := cont + 1;End;X := p^.prox;X^.ant := R;R ^.prox := X;

002 Antonio R$ 1000,00 Pr

ox=D

D

BB

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO EM UMA POSICAO

Ant=

AA

LCC

FBB

004 Judite R$ 1000,00 Pr

ox=N

IL

DD

Ant B

B 001 Jose0 R$ 1500,00 Pr

ox=A

A

AA

Ant=

NIL 003

Carlos0 R$ 1800,00 Pr

ox=D

D

CC

Ant=

BB

Digite a Posição da Lista.: 3

RBB

pCC

XDD

Page 33: Lista Duplamente Encandeada New(p);

R:= L;P:= L^.PROX;Cont := 1;While (cont < posi-1) doBegin r:= r^.prox; p := p^.prox; cont := cont + 1;End;X := p^.prox;X^.ant := R;R ^.prox := X;Dipose(p);

002 Antonio R$ 1000,00 Pr

ox=D

D

BB

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO EM UMA POSICAO

Ant=

AA

LCC

FBB

004 Judite R$ 1000,00 Pr

ox=N

IL

DD

Ant B

B 001 Jose0 R$ 1500,00 Pr

ox=A

A

AA

Ant=

NIL 003

Carlos0 R$ 1800,00 Pr

ox=D

D

CC

Ant=

BB

Digite a Posição da Lista.: 3

RBB

pCC

XDD

Page 34: Lista Duplamente Encandeada New(p);

002 Antonio R$ 1000,00 Pr

ox=D

D

BB

LISTA DUPLAMENTE ENCADEADA – EXCLUSAO EM UMA POSICAO

Ant=

AA

LCC

FBB

004 Judite R$ 1000,00 Pr

ox=N

IL

DD

Ant B

B 001 Jose0 R$ 1500,00 Pr

ox=A

A

AA

Ant=

NIL

REGISTRO EXCLUIDO