Follow Me

Dynamic memory exercises in C Programming in C

  • Dynamic allocation of arrays: Write a program that dynamically allocates an array, then free the memory....
  • Variable static implementation of a stack: The array-based stack implementation introduced in class uses a fixed length array. As a result, it is possible for the stack to become full. Rewrite the \(\texttt{push}\) method so that it doubles the length of the array when the array is full. Rewr...
  • Variable static implementation of a queue - version 1: The array-based queue implementation introduced in class uses a fixed length array. As a result, it is possible for the queue to become full. Rewrite the \(\texttt{enqueue}\) method so that it doubles the length of the array when the array is full. R...
  • Variable static implementation of a queue - version 2: Implement queue using dynamic memory allocation such that the implementation should abide with the following constraints. The user should use memory allocation from the heap using \(\texttt{malloc()}\) function. You need to take care of the max value...

Back to the list of exercises