4

Minty Tech 刷题营摸底测试

1 / 3

1. Given the following sorting algorithms, please sort them in ascending order in terms of Time complexity and Space complexity? Provide your explanations accordingly if necessary. (You can need to consider the recursion stack when calculating Space Complexity)

Quick Sort, Selection Sort, Merge Sort, Bubble Sort, Bucket Sort

2 / 3

2. Please write some JAVA codes to get a value in a HashMap “map” with key “some_key” and assign it to an integer value “k”. If the key is missing, assign it to 0.

3 / 3

3. Given the following code snippet, and an array [true, true, false, false, false] as the input of the function “findIndex”. What’s the return value of the following function?
 
public int findIndex(bool[] arr) {
    

int left = 0;

    

int right = arr.length() - 1;

    

while (left < right) {

        

int mid = left + (right - left) / 2;

      

  if (!array[mid]) {

            

right = mid;

     

   } else {

          

  left = mid + 1;

      

  }

 

   }

  

  return left;

}

Your score is

0%

Exit