Question: 0 solutions submitted ( max: Unlimited ) Assignment Create a class that contains at least a numeric vector called vector as a property and has
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 builtin max function of MATLAB.
Sort: return the sorted vector. You must use the BubbleSort Algortihm to sort the vector see below You are not allowed to use any builtin 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 st and nd element and swap if st element is greater.
After that do the same for nd and rd 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
Perform this for number of elements 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
I mostly need help with the Max part of the problem
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
