Is there any way in which I can delete an element from an array without implementing linked-list? In my program, I need to find the minimum value from the array and delete the element with minimum value. Then I repeat the step of searching for minimum value from the remaining elements and delete the element with minimum value.

If there is no way of avoiding the implementation of linked-list, please send any sample codes, information and URLs related to linked-list implementation.

I tried to use dynamic allocation to declare a 2-dimensional array but there was an error during compilation. Message was "Cannot convert void* to double*".

typedef double **matrix;

typedef double *row;

typedef double elem;

matrix get_space(int M, int N)

{ int i;

elem *p;

matrix a;

p = malloc(M*N*sizeof(elem)); //get space for all elements

a = malloc(M*sizeof(row));

--a; //offset pointer

for (i=1;i<=M;i++)

a[i]=p+((i-1)*N)-1;

return a;

}

Please advise. Thanks in advance.

In your problem where you need to remove the smallest value, you could replace the value by the last element of the list and reduce the list length by one. This would change the order of values but would be much simpler to implement. You must then add a variable holding the number of values left in the array to examine. This is as fast as a linked list remove operation.

Thus in your case both solutions are equivalent.

Though if you need to implement this in a 2D array, playing with linked list becomes really tricky. The second solution is then much simpler to implement.

About your programming problem, you look really in trouble.

ABout your void* error message you simply need to put a cast in front of the malloc operation. malloc returns a void* and you want to store the value into a double *. This is just a type checking problem.