# Challenge: Binary Tree (ASCII Art)

Page 1 of 1

## 5 Replies - 8308 Views - Last Post: 14 April 2014 - 06:49 AM

• MrCupOfT

Reputation: 2298
• Posts: 9,535
• Joined: 29-May 08

# Challenge: Binary Tree (ASCII Art)

Posted 31 January 2014 - 06:07 PM

Challenge: Binary Tree (ASCII Art)

Challenge: (Medium)

Given a balance parentheses string of a binary tree, produce the equivalent ASCII art version.

Examples

Input: (xx)
Output:
```  /\

```

Input: (x(xx)}
Output:
```  /\
/\

```

Input: ((xx)(xx))
Output:
```   /\
/\/\

```

Input: (x(x(xx)))
Output:
```  /\
/\
/\

```

This post has been edited by AdamSpeight2008: 31 January 2014 - 06:07 PM

Is This A Good Question/Topic? 0

## Replies To: Challenge: Binary Tree (ASCII Art)

### #2 thava

• D.I.C Lover

Reputation: 180
• Posts: 1,607
• Joined: 17-April 07

## Re: Challenge: Binary Tree (ASCII Art)

Posted 12 April 2014 - 03:16 AM

seems some thing went wrong while generate the art
(((xx)(xx))((xx)(xx)))
what is the output of the above input

• MrCupOfT

Reputation: 2298
• Posts: 9,535
• Joined: 29-May 08

## Re: Challenge: Binary Tree (ASCII Art)

Posted 12 April 2014 - 03:48 AM

(((xx)(xx))((xx)(xx)))
```     /\
/  \
/\  /\
/\/\/\/\

```

### #4 thava

• D.I.C Lover

Reputation: 180
• Posts: 1,607
• Joined: 17-April 07

## Re: Challenge: Binary Tree (ASCII Art)

Posted 13 April 2014 - 08:53 AM

any clue,
(x(x(xx)))
and
(((xx)(xx))((xx)(xx)))
both are at same level but different output

• MrCupOfT

Reputation: 2298
• Posts: 9,535
• Joined: 29-May 08

## Re: Challenge: Binary Tree (ASCII Art)

Posted 13 April 2014 - 01:43 PM

thava: Why don't you grab a pen and draw the trees. See what the difference is.

### #6 thava

• D.I.C Lover

Reputation: 180
• Posts: 1,607
• Joined: 17-April 07

## Re: Challenge: Binary Tree (ASCII Art)

Posted 14 April 2014 - 06:49 AM

well that was a nice clue, i can able to parse it as btree but not able to print it as you expected
Spoiler