Question: Write a program that prompts the user to enter the rows , and columns in each row to create a 2D dynamic array. Make sure
Write a program that prompts the user to enter the rows, and columns in each row to create a 2D dynamic array. Make sure that each row in 2D array should contain different number of columns. Fill the array by taking the values from the user and display the contents of 2D array. Now store the contents of this 2D array into a newly created 1D dynamic array in such a way that it stores the data column-wise i.e. (column major form) as shown in the figure. Now sort the data in 1D array by using merge sort algorithm and prompt the user to enter the key. Search the key in this 1D array by using binary search algorithm. Your program should return the value 1 if the key exists the in array, otherwise return -1.
Enter the number of rows : 3 Enter the number of columns for row# 1 : 2 Enter the number of columns for row# 2 : 4 Enter the number of columns for row# 3 : 3 Enter the value for index location 0, 0:9 Enter the value for index location 0, 1 : 8 Enter the value for index location 1, 0:7 Enter the value for index location 1, 1:6 Enter the value for index location 1, 2 : 5 Enter the value for index location 1, 3 : 4 Enter the value for index location 2, 0 : 3 Enter the value for index location 2, 1 : 2 Enter the value for index location 2, 2 : 1 9 7 3 Data in 2D array 8 6 5 4 2 1 Data in 10 array 9 7 3 8 Press any key to continue . 09 2 5 1 4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
