Data Structures/Doubly Linked List
dynamicsequentialpointer
Press play to start
1void inserirInicio(Lista* l, int x) {
2 Celula* tmp = (Celula*)malloc(sizeof(Celula));
3 tmp->elemento = x;
4 tmp->prox = l->primeiro->prox;
5 tmp->ant = l->primeiro;
6 if (tmp->prox != NULL)
7 tmp->prox->ant = tmp;
8 else
9 l->ultimo = tmp;
10 l->primeiro->prox = tmp;
11}
Step 1/0

Practice

LeetCode·#707 Design Linked ListMediumHackerRank·Insert at TailEasyNeetCode·Reverse a Linked ListEasy
OperationBestAverageWorst
inserirInicioO(1)O(1)O(1)
inserirFimO(1)O(1)O(1)
removerInicioO(1)O(1)O(1)
removerFimO(1)O(1)O(1)
pesquisarO(1)O(n)O(n)
SpaceO(n)