only c code dont use c++ and c#. Function write the arraylist_sort function and arraylist_remove_duplicates according to the given parameters. #include #include #include #define N 2000 #define D 250 // A simple restaurant structure typedef struct { char restaurant_name[15]; double rating; char city[31]; unsigned short opening_ye
please only c code dont use c++ and c#. Function write the arraylist_sort function and arraylist_remove_duplicates according to the given parameters.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define N 2000
#define D 250
// A simple restaurant structure
typedef struct
{
char restaurant_name[15];
double rating;
char city[31];
unsigned short opening_year;
} RESTAURANT_t, *RESTAURANT;
// Arraylist structure
typedef struct ArrayList_s
{
void **list;
int size;
int capacity;
int delta_capacity;
} ArrayList_t, *ArrayList;
* Function: arraylist_sort
* This generic function sorts an array list using the given compare function.
*/
void arraylist_sort(ArrayList l, int (*compare)(void *, void *))
{
// TODO: Fill this block.
/* NOTE: If you cannot write down a generic function which works for all types, write down a function which sorts resturants. If you cannot use function pointers, you can write down multiple functions which sort using different criteria.*/
}
/**
* Function: arraylist_remove_duplicates
* This generic function deletes the duplicate elements in the array list using the given compare function.
*/
void arraylist_remove_duplicates(ArrayList l, int (*compare)(void *, void *))
{
// TODO: Fill this block.
// NOTE: If you cannot write down a generic function which works for all
// types, write down a function which removes duplicate restaurants.
}
Step by step
Solved in 2 steps