Question: Given the following program, 1- For each identifier in the following c++ code explain if its Stack or Heap bound, #include using namespace std; void
Given the following program,
1- For each identifier in the following c++ code explain if its Stack or Heap bound,
#include
using namespace std;
void swapping(int &a, int &b) { //swap the content of a and b
int temp;
temp = a;
a = b;
b = temp;
}
void display(int *array, int size) {
for(int i = 0; i cout << array[i] << " "; cout << endl; } void bubbleSort(int *array, int size) { for(int i = 0; i int swaps = 0; //flag to detect any swap is there or not for(int j = 0; j if(array[j] > array[j+1]) { //when the current item is bigger than next swapping(array[j], array[j+1]); swaps = 1; //set swap flag } } if(!swaps) break; // No swap in this pass, so array is sorted } } stack int main() { int n; cout << "Enter the number of elements: "; cin >> n; int arr[n]; //create an array with given number of elements stack cout << "Enter elements:" << endl; for(int i = 0; i cin >> arr[i]; } cout << "Array before Sorting: "; display(arr, n); bubbleSort(arr, n); cout << "Array after Sorting: "; display(arr, n); } 2- Extract the following List all static variables, stack-dynamic variables, explicit heap-dynamic variables, and implicit heap-dynamic variables.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
