Question: 0 solutions submitted ( max: Unlimited ) Assignment Create a class that contains at least a numeric vector called vector as a property and has

0 solutions submitted (max: Unlimited)
Assignment
Create a class that contains at least a numeric vector called vector as a property and has the following methods:
NumVector constructor: Loads the vector and assign values to all your properties in the constructor.
Max: return the largest element of the vector. To implement this method, you are not allowed to use the built-in max function of MATLAB.
Sort: return the sorted vector. You must use the Bubble-Sort Algortihm to sort the vector (see below). You are not allowed to use any built-in function in MATLAB for sorting.
iSort: return the vector sorted in the reverse order. Hint: Sort the vector using your previous function and flip the vector. You are not allowed to use the built in flip function of MATLAB.
Bubble Sort
Start by comparing 1 st and 2 nd element and swap if 1 st element is greater.
After that do the same for 2nd and 3rd element.
Keep doing this in a loop. At the end of the loop you will have the max element at the end of vector.
Now do the same to position the second largest element in the correct position (end of the vector -1).
Perform this for (number of elements -1) times to place all elements in the correct position until you get a sorted vector.
You are welcome to search the Internet for more details. A good explanation with coding in a few languages can be find here.Code to call your function o.
I mostly need help with the Max part of the problem
0 solutions submitted ( max: Unlimited )

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!