4. 빅 오 표기법을 사용해 다음 함수의 시간 복잡도를 나타내자. 함수는 문자열 배열을 받아 각 문자열을 다양한 형태로 출력한다.

    def multiple_cases(array) 
        array.each do |string|
            puts string.upcase 
            puts string.downcase 
            puts string.capitalize
        end  
    end

    5. 다음 함수는 수로 된 배열을 순회하며 인덱스가 짝수이면 배열 내 모든 수에 대해 그 인덱스의 수를 더해 출력한다. 빅 오 표기법으로 나타내면 이 함수의 효율성은 무엇일까?

    def every_other(array) 
        array.each_with_index do |number, index|
            if index.even?
                array.each do |other_number|
                    puts number + other_number
                end 
            end
        end  
    end
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.