I am a student who is taking the programming class data structures and algorithms and I am in need of help with a exam question I cant seem to get a grip off.
Here is the problem:
Consider the following algorithm func on a given array A = {a1, a2, ..., an}:
If n = 1, then return.
If a1 > an, then exchange a1 and an.
Run func on {a1, a2, ... ,a2n/3}.
Run func on {an/3, a(n/3)+1, ... ,an}.
Run func on {a1, a2, ... ,a2n/3}.
Give a recurrence for the worst-case running time of this algorithm.
Here is a link to an image of the assignment if my explanation wasnt clear: https://i.stack.imgur.com/m3qNG.png
I understand that it is a divide and conquer problem but Im having a hard time to figure out how to solve it.
Thank you :)