Arrow · Pattern

Down Arrow

Down Arrow

Arrow

Symbol pattern, solid style, size 5. Changing the rubric, style or size above re-shapes the loops — the structure stays identical while only the printed value or the cell filter changes.

Down Arrow · output

Symbol · Solid · size 5

max 9
         
         
         
         
         
         
         
         
         
1 / 20
Drawing… ready to start.
Python · Down Arrow · Python
    n = 5
    for i in range(2 * n - 1):
        for j in range(2 * n - 1):
            if (i < n - 1 and j == n - 1) or (i >= n - 1 and n - 1 - (i - (n - 1)) <= j <= n - 1 + (i - (n - 1))):
                print('*', end='')
            else:
                print(' ', end='')
        print()

Behind the Scenes Execution

registers · line tracking · call stack · memory regions
PC0x4000SP0x7FE8FLAGSZF 0OPenter function
Call Stack
main()@0x7FD0
n = 5i = -1j = -1count = 0
Memory Map
AddressVariableValue
Stack (4)
0x200n5
0x204i-1
0x208j-1
0x20Ccount0
String Pool (static) (2)
0x400000pool["*"]*
0x400008pool["\n"]\n
Heap (9)
0x3000grid[0]
0x3020grid[1]
0x3040grid[2]
0x3060grid[3]
0x3080grid[4]
0x30A0grid[5]
0x30C0grid[6]
0x30E0grid[7]
0x3100grid[8]
1 / 20
Arrow

Down Arrow

Downward arrow: the shaft comes first (one centred value per row), then the inverted centred triangle. Same two phases, swapped order.

The size-5 grid

The mirror image: four shaft rows in column 4, then the centred pyramid printed widest first, widths 9, 7, 5, 3, 1, so the point faces down. The total is still nine rows and the shaft is n - 1 rows.

Off-by-one traps

Starting the pyramid at row 4 rather than row 3 merges the shaft with the widest row and the arrow loses its neck; the head must begin immediately after the last shaft row.

Step by step

  1. Loop rows i = 0..2n - 2.
  2. If i < n - 1: print one centred value (the shaft).
  3. Else: print the inverted pyramid row 2·(n - 1 - m) + 1 values wide.
  4. Newline per row.

Complexity

BestO(n²)
AverageO(n²)
WorstO(n²)
SpaceO(1) if printed directly

When to use it

  • Phase ordering
  • Arrow diagrams
Study tip: pick a size, then run and step through the execution. Watch the grid[r] rows in the Heap region and the i / j / count registers on the Stack — every printed character is one write to the grid.

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits