Bubble sorting of 2d dynamic arrays

Write your question here.
I have got an assignment of bubble sorting with specific requirements and they are
program will be reading the value of n from a file.The first number in the data set will indicate the size of the data set.You will be using a two dimensional dynamic array to store the step wise results of the sort.The starting dimensions of the array will be n by n.When needed the array should be resized.
Any one can please help me!!!!
This is nothing extraordinary.

What have you tried? Or at least, what do you know?
I know how to sort the 1d arrays but not the dynamic ones...
Hi there,

A very good explanation of bubble sort is available here:
http://www.cplusplus.com/faq/sequences/sequencing/sort-algorithms/bubble-sort/

Some information about dynamic memory:
http://www.cplusplus.com/doc/tutorial/dynamic/

You will notice that you keep going through the array (loop) time and time again until everything is in its place.
Your teacher wants that for every iteration, you store the state of the array, for example:

Array to sort: {3, 5, 1, 2}

First bubble sort pass: {3, 1, 2, 5}
Stepwise array: { {3, 1, 2, 5} }

Second bubble sort pass: {1, 2, 3, 5}
Stepwise array: { {3, 1, 2, 5}, {1, 2, 3, 5} }

Hope that gives you what you need to get started. Please do let us know if you require any further help and perhaps come back to us with your attempted code.

All the best,
NwN
Last edited on
NwN thanku
Topic archived. No new replies allowed.