## Left Arrow Star Pattern

Back to Programming

### Description

Left Arrow Star Pattern

For printing the pattern the number of lines is taken as input. For printing, this pattern the number of lines should be odd. So after taking the number of lines as input checking is done. If it is odd, then only the pattern can be printed else an error message is shown. The stars are printed so that it looks like an arrow.

### Algorithm

``````INPUT: number of lines
OUTPUT: the aforesaid pattern
PROCESS:
Step 1: [taking the input]
Step 2: [printing the pattern]
If n mod 2≠0 then
Set u1<-(n-1)/2
Set u2<-3*n/2-1
For i=0 to n-1 repeat
For j=0 to n-1 repeat
If i+j=u1 or i-j=u1 or i=u1 then
Print "*"
Else
Print “ “
[End of ‘if’]
[End of ‘for’ loop]
Move to the next line
[End of ‘for’ loop]
else
print “Please give correct input(no. of lines should be odd)"
[End of ‘if]
Step3: Stop.
``````

## Time Complexity:

for(i=0;i<n;i++)--------------------------------------------- n

{    for(j=0;j<n;j++) ---------------------------------- n

{

if(i+j==u1||i-j==u1||i==u1)

printf("*");

else

printf(" ");

}

printf("\n");

}

The complexity is: O(n*n)=O(${\mathrm{n}}^{2}$)