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

#1 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon

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

Challenge: Binary Tree (ASCII Art)

Post icon  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  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

#3 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon

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

Re: Challenge: Binary Tree (ASCII Art)

Posted 12 April 2014 - 03:48 AM

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


Was This Post Helpful? 0
  • +
  • -

#4 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • 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
Was This Post Helpful? 0
  • +
  • -

#5 AdamSpeight2008  Icon User is offline

  • MrCupOfT
  • member icon

Reputation: 2298
  • View blog
  • 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.
Was This Post Helpful? 0
  • +
  • -

#6 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • 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

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1