This commit is contained in:
2026-04-30 23:42:34 +02:00
commit 6ccc96b2fe
16 changed files with 32397 additions and 0 deletions
@@ -0,0 +1,14 @@
CC=gcc
CFLAGS=-Wall -Wextra -Werror -fsanitize=address -g
SRCS=main.c dlist.c dlist_merge_sort.c
OBJS=$(SRCS:.c=.o)
TARGET=dlist_merge_sort
all: $(TARGET)
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS)
clean:
$(RM) $(OBJS) $(TARGET)
@@ -0,0 +1,6 @@
#include "dlist_merge_sort.h"
void dlist_merge_sort(struct dlist *l)
{
// TODO
}
@@ -0,0 +1,25 @@
#ifndef DLIST_MERGE_SORT
#define DLIST_MERGE_SORT
#include <stddef.h>
struct node
{
int data;
struct node *next;
struct node *prev;
};
struct dlist
{
size_t size;
struct node *head;
struct node *tail;
};
struct dlist *dlist_init(void);
void dlist_clear(struct dlist *list);
void dlist_push_back(struct dlist *l, int data);
void dlist_merge_sort(struct dlist *l);
#endif /* ! DLIST_MERGE_SORT */
@@ -0,0 +1,29 @@
// This file will not be tested, you can modify it.
#include <stdio.h>
#include "dlist_merge_sort.h"
static void dlist_print(struct dlist *dl)
{}
int main(void)
{
struct dlist *l = dlist_init();
dlist_push_back(l, 4);
dlist_push_back(l, 2);
dlist_push_back(l, 5);
dlist_push_back(l, 1);
dlist_push_back(l, 3);
printf("Before sort: ");
dlist_print(l); // TODO
dlist_merge_sort(l);
printf("After sort: ");
dlist_print(l); // TODO
dlist_clear(l);
return 0;
}