INE5408
Estruturas de Dados
Aula 6b
Listas Circulares
Listas Encadeadas Circulares
• Último elemento conecta ao primeiro.
• Implementação mais simples:
3
info próximo info próximo info próximo
nro dados
melão
doce
caro
maçã
azeda
cara
uva
irkh
barata
Listas Encadeadas Circulares
• Caso especial:
– Lista circular unitária.
• Atividade:
– Quais operações têm algoritmos diferentes?
– Qual é a posição mais indicada para inserir quando a posição não
importa ?
1
info próximo
nro dados
melão
doce
caro
Listas Encadeadas Circulares
• Alternativa para evitar mudança nos algoritmos
– nodo-sentinela funciona sempre como nodo sem informações
atachado à cabeça de lista
– lista é criada posuindo o nodo sentinela
– algoritmos não se modificam
4
info próximo info próximo info
nro dados
maçã
azeda
cara
uva
irkh
barata
melão
doce
caro
próximo
info próximo
Para que servem listas circulares?
• Modelagem e planejamento de rotas
circulares
– Caminho de retorno é diferente do de ida.
– Exemplo: rotas aéreas tipo volta-ao-mundo.
– Útil em sistemas de planejamento de itinerário e
de reserva global de passagens como Amadeus
Global Travel Distribution System
Para que servem listas circulares?
Para que servem listas circulares?
Para que servem listas circulares?
• Escalonamento de Processos (Process
Scheduling) em kernels de sistemas
operacionais multitarefa preemptivos.
– Exemplo: método round-robin (tradução:
sabiá-cíclico - não se preocupe: ninguém
usa) de escalonamento de processos com
fatia de tempo constante por processo.
Round Robin
CPU
Proc.#1
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
Proc.#2
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
Proc.#3
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
Proc.#4
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
Round Robin
CPU
Proc.#1
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
Proc.#2
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
Proc.#3
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
Proc.#4
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
Round Robin
CPU
Proc.#1
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
Proc.#2
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
Proc.#3
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
Proc.#4
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
long int SomeFunction(); /*
int OtherFunction(); */ /* int
*/ CallingFunction() { long
int test1; register /* int */
test2; test1 = SomeFunction();
if (test1 > 0) test2 = 0; else
test2 = OtherFunction();
return test2; }.
Var1
Var2
Var3
Var4
Var5
Para que servem listas circulares?
• Sistemas de impressão que controlam várias
impressoras
– Realizam escalonamento de impressoras
(round-robin printing queue) por
disponibilidade para impressão de
documentos em uma fila de impressão
cíclica única para várias impressoras.
Para que servem listas circulares?

Mais conteúdo relacionado

PPTX
Aula sobre Brainstorming 07.09.2022.pptx
PPT
Aula_03_-_2_-_Aloca_o_Din_mica_de_Mem_ria_new_delete (1).ppt
PPT
Aula_05_-_Listas_Duplamente_Encadeadas_opp.ppt
PPT
Aula_03_-_2_-_Aloca_o_Din_mica_de_Mem_ria_new_delete.ppt
PPT
Aula_03_-_2_-_Aloca_o_Din_mica_de_Mem_ria (1).ppt
PPT
Aula_02_-_Listas_com_Vetores-OOP.ppt
PPT
Aula_05_-_Listas_Duplamente_Encadeadas.ppt
PPT
Aula_07_Complexidade_de_Algoritmos (1).ppt
Aula sobre Brainstorming 07.09.2022.pptx
Aula_03_-_2_-_Aloca_o_Din_mica_de_Mem_ria_new_delete (1).ppt
Aula_05_-_Listas_Duplamente_Encadeadas_opp.ppt
Aula_03_-_2_-_Aloca_o_Din_mica_de_Mem_ria_new_delete.ppt
Aula_03_-_2_-_Aloca_o_Din_mica_de_Mem_ria (1).ppt
Aula_02_-_Listas_com_Vetores-OOP.ppt
Aula_05_-_Listas_Duplamente_Encadeadas.ppt
Aula_07_Complexidade_de_Algoritmos (1).ppt

Último (19)

PDF
Banco de Dados 2atualização de Banco de d
PPTX
Aula 9 - Funções em Python (Introdução à Ciência da Computação)
PDF
Processamento da remessa no SAP ERP, SCM610 Col15
PPTX
Aula 7 - Listas em Python (Introdução à Ciencia da Computação)
PDF
SEMINÁRIO DE IHC - A interface Homem-Máquina
PDF
ASCENSÃO E QUEDA DO SOFTWARE LIVRE NO ESTADO BRASILEIRO
PDF
Processos no SAP Extended Warehouse Management, EWM100 Col26
PDF
Visão geral da SAP, SAP01 Col18, Introdução sistema SAP,
PPTX
3b - Bradesco Lean Agile Training Plan - Ritos Operacionais (1).pptx
PDF
Metodologia Scrumban-XP - Um Guia Rápido (MrSomebody19).pdf
PPT
Aula de Engenharia de Software principais caracteristicas
PPT
Conceitos básicos de Redes Neurais Artificiais
PDF
Customizing básico em SAP Extended Warehouse Management, EWM110 Col26
PPTX
Analise Estatica de Compiladores para criar uma nova LP
PPTX
Proposta de Implementação de uma Rede de Computador Cabeada.pptx
PDF
Jira Software projetos completos com scrum
PPTX
Tipos de servidor em redes de computador.pptx
PPTX
ccursoammaiacursoammaiacursoammaia123456
PDF
Aula 9 - Funções 202yttvrcrg5-1.pptx.pdf
Banco de Dados 2atualização de Banco de d
Aula 9 - Funções em Python (Introdução à Ciência da Computação)
Processamento da remessa no SAP ERP, SCM610 Col15
Aula 7 - Listas em Python (Introdução à Ciencia da Computação)
SEMINÁRIO DE IHC - A interface Homem-Máquina
ASCENSÃO E QUEDA DO SOFTWARE LIVRE NO ESTADO BRASILEIRO
Processos no SAP Extended Warehouse Management, EWM100 Col26
Visão geral da SAP, SAP01 Col18, Introdução sistema SAP,
3b - Bradesco Lean Agile Training Plan - Ritos Operacionais (1).pptx
Metodologia Scrumban-XP - Um Guia Rápido (MrSomebody19).pdf
Aula de Engenharia de Software principais caracteristicas
Conceitos básicos de Redes Neurais Artificiais
Customizing básico em SAP Extended Warehouse Management, EWM110 Col26
Analise Estatica de Compiladores para criar uma nova LP
Proposta de Implementação de uma Rede de Computador Cabeada.pptx
Jira Software projetos completos com scrum
Tipos de servidor em redes de computador.pptx
ccursoammaiacursoammaiacursoammaia123456
Aula 9 - Funções 202yttvrcrg5-1.pptx.pdf

Aula_6b_-_Listas_Circulares.ppt

  • 1. INE5408 Estruturas de Dados Aula 6b Listas Circulares
  • 2. Listas Encadeadas Circulares • Último elemento conecta ao primeiro. • Implementação mais simples: 3 info próximo info próximo info próximo nro dados melão doce caro maçã azeda cara uva irkh barata
  • 3. Listas Encadeadas Circulares • Caso especial: – Lista circular unitária. • Atividade: – Quais operações têm algoritmos diferentes? – Qual é a posição mais indicada para inserir quando a posição não importa ? 1 info próximo nro dados melão doce caro
  • 4. Listas Encadeadas Circulares • Alternativa para evitar mudança nos algoritmos – nodo-sentinela funciona sempre como nodo sem informações atachado à cabeça de lista – lista é criada posuindo o nodo sentinela – algoritmos não se modificam 4 info próximo info próximo info nro dados maçã azeda cara uva irkh barata melão doce caro próximo info próximo
  • 5. Para que servem listas circulares? • Modelagem e planejamento de rotas circulares – Caminho de retorno é diferente do de ida. – Exemplo: rotas aéreas tipo volta-ao-mundo. – Útil em sistemas de planejamento de itinerário e de reserva global de passagens como Amadeus Global Travel Distribution System
  • 6. Para que servem listas circulares?
  • 7. Para que servem listas circulares?
  • 8. Para que servem listas circulares? • Escalonamento de Processos (Process Scheduling) em kernels de sistemas operacionais multitarefa preemptivos. – Exemplo: método round-robin (tradução: sabiá-cíclico - não se preocupe: ninguém usa) de escalonamento de processos com fatia de tempo constante por processo.
  • 9. Round Robin CPU Proc.#1 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 Proc.#2 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 Proc.#3 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 Proc.#4 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5
  • 10. Round Robin CPU Proc.#1 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 Proc.#2 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 Proc.#3 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 Proc.#4 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5
  • 11. Round Robin CPU Proc.#1 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 Proc.#2 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 Proc.#3 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 Proc.#4 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5 long int SomeFunction(); /* int OtherFunction(); */ /* int */ CallingFunction() { long int test1; register /* int */ test2; test1 = SomeFunction(); if (test1 > 0) test2 = 0; else test2 = OtherFunction(); return test2; }. Var1 Var2 Var3 Var4 Var5
  • 12. Para que servem listas circulares? • Sistemas de impressão que controlam várias impressoras – Realizam escalonamento de impressoras (round-robin printing queue) por disponibilidade para impressão de documentos em uma fila de impressão cíclica única para várias impressoras.
  • 13. Para que servem listas circulares?