Salve,
A seguir estão duas implementações para a função initQueue() de uma fila.
Essas implementações utilizam listas encadeadas com ou sem cabeça?
/* implementaçao 1 */
typedef struct queueNode* Link;
struct queueNode {
Item conteudo;
Link prox;
};
static Link inicio;
void
queueInit()
{
inicio = (Link) mallocSafe(sizeof *inicio);
inicio->prox = inicio;
}
/* implementacao 2 */
typedef struct queueNode* Link;
struct queueNode {
Item conteudo;
Link prox;
};
struct queue { /* aqui esta especificado o que e' */
Link inicio; /* uma fila: dois apontadores para struct queueNode */
Link fim;
};
typedef struct queue *Queue;
Queue
queueInit(int maxN)
{
Queue q = mallocSafe(sizeof *q);
q->inicio = NULL;
q->fim = NULL;
return q;
}