Question: 3. Sorting Implement a generic Stack linked list data structure for integers that supports these function:s a. i. InsertionSort(), which runs an insertion sort algorithm


3. Sorting Implement a generic Stack linked list data structure for integers that supports these function:s a. i. InsertionSort(), which runs an insertion sort algorithm on the stack Your insertionSort() algorithm should print to the console every time it makes a swap. Print the operation performed ("Swapped a with b"), then on the next line print the current contents of the array. Print to the console when the sort has finished ("Sort finished!") 1. 2. ii. Push(int data), which pushes values to the head of the stack ili. Pop();, which pops values from the head of the stack and returns it iv. Peek(), which returns a value from the head of the stack b. Implement a pastPeek() function such that it always peeks the head of the stack prior to the sort taking place. When the head of the stack is popped from the sorted stack, update peek() to move to where the next head would have been
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
