小编jos*_*urg的帖子

带有随机对象的 while 循环的大 O 时间复杂度

public class Question2 {
          //running time of function is N!!!!!!
    public static boolean isThere(int[] array, int num, int index){
        boolean isItThere = false;   //running time of 1
        for(int i =0; i <= index; i++){      //running time i
            if(array[i] == num){   //running time of 1
                isItThere = true;   //running time of 1
            }
        }
        return isItThere;
    }


    public static int[] firstAlgo(int N){
            Random random = new Random();  //running time of 1(initilizing)k
          int[] arr = new int[N];
          for (int i = 0; …
Run Code Online (Sandbox Code Playgroud)

java random math big-o

4
推荐指数
1
解决办法
204
查看次数

标签 统计

big-o ×1

java ×1

math ×1

random ×1