In any OOPS Language, object will have some kind of data.
Lets say
class Dog{
string breed; int age;
}
and class Bunny{
int age;
}
// Declaring array of objects, allocating memory etc
Bunny b[N]; Dog d[N]; // N being the size
Bunny b[0]= new Bunny(5); // initializing object 0 in case of
Bunny
Dog d[0] = new Dog("Labrador", 5); //similar for dog
// since you know mergesort on Integers, you can easily mergesort
bunny array
instead of num[i], we will access the variable using b[i].age, and
then follow same algo
//Lets say we need to mergsort dogs on basis of breed
// In this case, we need to sort on basis of strings. Assuming
student can do so
//instead of name[i], use d[i].breed
Get Answers For Free
Most questions answered within 1 hours.