i am working on creating a priority queue, i seem to have done the algorithm for inserting from the top correctly but the algorithm for inserting from the bottom doesnt seem to work it just overwrites the existing data.
below is my code :
list is an array and listlength is the size of the array declared as a integer
In you insertbottom, you are indeed over writing everything in your array. It will take everything from the last element in the array to the first and make them all equal to the last. Then after your for-loop is done, you then change the last element in the array to task.
Here is an example code that inserts at the back of the array: