Quiz Time!

Want to know how well you can print patterns? Or why time and space complexity is really that intriguing?

Then here is a set of tricky and intresting patterns, and complexity based questions to ponder upon!

Q(1-4) Write the looping conditions for these programs !

1.Pattern 1 :

    *
   **
  ***
 ****
*****
 ****
  ***
   **
    *

2.Pattern 2:



**********
****  ****
***    ***
**      **
*        *
**      **
***    ***
****  ****
**********

3. Pattern 3:

5 5 5 5 5 5 5 5 5
5 4 4 4 4 4 4 4 5
5 4 3 3 3 3 3 4 5
5 4 3 2 2 2 3 4 5
5 4 3 2 1 2 3 4 5
5 4 3 2 2 2 3 4 5
5 4 3 3 3 3 3 4 5
5 4 4 4 4 4 4 4 5
5 5 5 5 5 5 5 5 5 

4. Pattern 4:

      1
    1 2 1
  1 2 3 2 1 
1 2 3 4 3 2 1
  1 2 3 2 1
    1 2 1
      1

5. What is the time complexity of the following Program?

int i, j, l = 0; 
 for (i = n / 2; i <= n; i++) { 
     for (j = 2; j <= n; j = j * 2) { 
         l= l + n / 2; 
     } 
 }

6.Find the time complexity of the program !

int ans = 0, i = N; 
 while (i > 0) { 
     ans += i; 
     i /= 2; 
 }

7.Find the time complexity of the program !

void function() 
 {  int i, j; 
 for (i=1; i<=n; i++) 
     for (j=1; j<=log(i); j++) 
         printf("BitXorBytes"); 
 }

8.What is time complexity of following program?(c is a constant)

void powerFunction(){
    for (int i = 2; i <=n; i = pow(i, c)) { 
       print("*")
    }

//Here fun is sqrt or cuberoot or any other constant root
    for (int i = n; i > 1; i = fun(i)) { 
      print("*")
    }
 }

Solve as many as you can and dm us how many you could solve on instagram @bitxorbytes. You can also reach us at us at everythinggeeky.101@gmail.com.

For any doubts or ambiguities, mail us at everythinggeeky.101@gmail.com

Don’t forget to Like, Comment and Share with your friends.

Stay Tuned for Everything Geeky, We post every weekend!

Cheers! 🙂

Team Bitxorbytes

Cover Image Credits: https://wallpapersafari.com/question-mark-wallpaper/

Published by BitXorBytes

A technical blog which features articles about anything and everything related to computer science and programming! Learn something new and interesting with every post!

Leave a comment

Design a site like this with WordPress.com
Get started