Answered step by step
Verified Expert Solution
Question
1 Approved Answer
What would I type into gdb to be able to answer this? Run the program (single step) and enter a seed value of 1022015. After
What would I type into gdb to be able to answer this? Run the program (single step) and enter a seed value of 1022015. After calling the shuffle() function, what is the value of array[8]? ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// #include#include using std::cout; using std::cin; using std::flush; const int ARRAYSIZE = 30; void fill(int ar[], int size); void shuffle(int ar[], int size); int main(void) { int array[ARRAYSIZE] = {0}; // Clear out array int seed; cout << "Seed value? " << flush; cin >> seed; srand(seed); fill(array, ARRAYSIZE); shuffle(array, ARRAYSIZE); return 0; } void fill(int b[], int size) { int index; // Place random values at random locations in the array for(int i = 0; i < 10 * size; i++) { index = rand() % size; b[index] = rand(); } } void shuffle(int ar [], int size) { int* first, * second; for(int j = 0; j < 5 * size; j++) { // Pick a random pair of positions to swap first = ar + rand() % size; second = ar + rand() % size; // Swap int temp = *first; *first = *second; *second = temp; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started