logo

Crowdly

FIT2004 Algorithms and data structures - S1 2025

Looking for FIT2004 Algorithms and data structures - S1 2025 test answers and solutions? Browse our comprehensive collection of verified answers for FIT2004 Algorithms and data structures - S1 2025 at learning.monash.edu.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

What is the auxiliary space of least significant digit (LSD) radix sort for an array of n integers? 

0%
0%
View this question

Consider the following Python code that returns true if and only if the string s is a palindrome. A string is a palindrome if it is the same when reversed, e.g., "madam" is a palindrome whereas "algorithm" is not. 

def is_palindrome(s):

      left = 1

      right = len(s)

      while left < right:

            # loop invariant

            if s[left] != s[right]:

                  return False

            left += 1

            right -= 1

      return True

What is an appropriate loop invariant for this algorithm at the point specified?

View this question

Which of those sorting algorithms has time complexity that is independent from the array contents (assuming that it is an array of integers)?

0%
100%
100%
100%
View this question

Consider the following algorithm, which returns the index of the maximum value in an array of integers.

The function accepts a list A[1…n] with n items

myfunc(A, n):

    i = 1

    j = n

    while (i < j):

        if (A[i] > A[j]):

            j = j – 1

        else:

            i = i + 1

### Loop Invariant ###

    return i

What is an appropriate loop invariant for this algorithm at the point specified?

0%
0%
0%
100%
0%
View this question

Consider the following algorithm, which accepts a list A[1…n] with n items and performs a set of operations:

myfunc(A, n):

    i = 1

    while (i < n):

### Loop Invariant ###

        if (A[i] > A[i+1]):

            temp = A[i]

A[i] = A[i+1]

A[i+1] = temp

        i = i + 1

    return A[n]

What is an appropriate loop invariant for this algorithm at the point specified?

0%
0%
0%
0%
0%
0%
View this question

Solve, in big-θ, the following recurrence relation

T(n) = 2 * T(n/2), where n > 1

T(n) = c, where n = 1

for a constant c.

0%
0%
100%
0%
0%
0%
0%
0%
View this question

Given the following pseudocode, derive the recurrence relation that represents its time complexity. 

def power(x, n):

if n == 0:

return 1

return x * power(x, n - 1)

Let b and c represent constant values. What is the base case and recurrence step?  

100%
0%
0%
View this question

Want instant access to all verified answers on learning.monash.edu?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!