Question

In: Computer Science

What property does a custom class need to have for it to be usable in an...

What property does a custom class need to have for it to be usable in an array with the three sort methods you implemented? Give a name to the concept and also explain specifically in C++ what would need to be implemented.

Solutions

Expert Solution

Lets consider 3 sorting techniques,

1. Merge sort : Here the custom class will need 3 pointers, i.e. one pointing to the first element of an array, one pointing to the middle and one pointing to the last. Then we use divide and conquer rule to complete this merge sort procedure unless all the elements are in a sorted order.

2. Selection Sort: here we need two pointers, initially pointing to the first element, then the second pointer will iterate through entire array by comparing all the elements with the first element, and the first element is swapped by the smallest element and so on.

3. Quick Sort: Here we consider a pivot element,so the custom class needs 3 variables and two pointer pointing to the first and last element, and then bringing the pivot element to its right position.

Note: If you have any doubts or queries, feel free to ask by commenting down below.

And if my answer suffice to the requirements, then kindly upvote as an appreciation

Happy Learning :)


Related Solutions

In Python What is a class? What is a property as it relates to a class?...
In Python What is a class? What is a property as it relates to a class? What is a method as it relates to a class? What is an object? How do you create an object? What is an instance variable versus a class level variable? What is a constructor? Is a constructor always required? Does it depend on the language? What is and what is the benefit of inheritance? What is and what is the benefit of encapsulation? What...
In this assignment, you need to determine the network ID, first usable host, last usable host,...
In this assignment, you need to determine the network ID, first usable host, last usable host, range of valid addresses, and broadcast address of a network. Must be written on paper Which subnet (network ID) does host 192.24.54.215 255.255.255.240 belong to? What is the last valid host on the subnetwork 192.168.243.32 255.255.255.248? What is the first valid host on the subnetwork that the node 192.31.253.75/28 belongs to? What is the first valid host on the subnetwork that the node 192.24.91.245...
How does a nurse know what (if any) knowledge in a research study is usable for...
How does a nurse know what (if any) knowledge in a research study is usable for clinical practice? What would a critical thinker look for in the evidence before deciding to change? What influence do credibility and clinical significance have on your decisions to integrate research-based evidence into your practice?
What does a drug need to be soluble in water? What does a drug need to...
What does a drug need to be soluble in water? What does a drug need to be permeable to tissues? What will happen if the solubility of my drug changes over time?
So I need to parse tweets with the String class and I have no idea what...
So I need to parse tweets with the String class and I have no idea what should I do for this lab and how to start my coding. It will be nice if anyone guide me what should I do exactly and how I start this lab. Use the Scanner class (as discussed in lecture) to read in a tweet entered by the user and store it in a String variable named tweet. You will be splitting up (parsing) the...
Design You will need to have at least four classes: a parent class, a child class,...
Design You will need to have at least four classes: a parent class, a child class, a component class, and an unrelated class. The component object can be included as a field in any of the other three classes. Think about what each of the classes will represent. What added or modified methods will the child class have? What added fields will the child class have? Where does the component belong? How will the unrelated class interact with the others?...
What is the separation property and why does it apply?
What is the separation property and why does it apply?
In ArcGIS, What is conforming property? Name something that has this property and something that does...
In ArcGIS, What is conforming property? Name something that has this property and something that does not-
a.What role does one's social class have in their life? b.How does social class intertwine with...
a.What role does one's social class have in their life? b.How does social class intertwine with culture, society, socialization, or gender, race, age?
What tow characteristics does a market structure need to have for firms in that industry to...
What tow characteristics does a market structure need to have for firms in that industry to engage in technological advance? What market structure best meets these criteria?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT