I have a homework assignment that ask you to complete an empty project that contains a queue and stack. the data should be stored in a circular array.
Functions of the queue are:
pushBack : to insert in the back
pushFront : to insert in the front
popBack : to remove from the back
popFront : to remove from the front
rotate(n) : to rotate the array. if numbers are 3, 2, 1, 0, 7, 8 and then you rotate(2) it will be 1, 0, 7, 8, 3, 2
reverse: to reverse the array. if numbers are 8, 3, 2, 1, 0, 7 and you reverse it will be 7, 0, 1, 2, 3, 8
I just couldn't come with an appropriate method to do it.
Should the implementation be based on front and rear and just change the value of front and rear. if yes, what is the right way to code it? the problem is that the program will have an empty cell between rear and front.
any help will be appreciated