VOOZH about

URL: https://www.geeksforgeeks.org/dsa/program-print-diagonal-star-patterns/

⇱ Program to print diagonal star patterns - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Program to print diagonal star patterns

Last Updated : 20 Feb, 2023

Time Complexity: O(N) where N is number of nodes in a given binary tree

Auxiliary Space: O(N)For the given input, this program prints the following pattern. The input must be an odd number.
Examples: 
 

Input : 7
Output :

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


 


Below is the code printing above pattern : 
 

Output : 
 

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

Time Complexity: O(n2)

Auxiliary Space: O(1)
For given input, this program prints the following pattern. The input must be an odd number.
Examples : 
 

Input : 9
Output :


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


 


Below is the code printing above pattern : 
 

Output : 
 

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

Time Complexity: O(n2)

Auxiliary Space: O(1)

Comment