Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to get child count.

 
Himani Vashistha
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a file with text like:

<L [1]
<L [1]
<U4 [1] 85000>
>
>

< and > are like opening and closing braces, and [*] tells no. of childs in the list. Only a list can have childs. other elements like U4 are stand alone and can not have childs(Thats why closing ">" for U4 is in sequence with opening "<").

I need to validate above string, If a L[1] is specified it should have only one child, like in above example.

One wrong syntaxt is:
<L [2]
<U4 [1] 85000>
>

This is wrong as L[2] specifies 2 childs, but there is only one child into it.

I want to write recursive code for above validations....

Please Help!!!

Regards,
Himani.
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!