Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Interview Question asked to me can somebody help me ! Thanks in advance

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Location
    Delhi
    Posts
    2
    My Mood
    Tired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Interview Question asked to me can somebody help me ! Thanks in advance

    they told me that data is stored in that format
    [1,2,3,4[5,6,7[8,9,10],11,12,13],14,15,16[17,18,19,20[21[22,23,24],25]]]{There is no limit for number of element within the hierarchy }
    Write a function in java to bring all elements in a new array in sequential order as they are stored.
    They suggest me to use recursion for this....!


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    4,490
    My Mood
    Mellow
    Thanks
    152
    Thanked 610 Times in 597 Posts

    Default Re: Interview Question asked to me can somebody help me ! Thanks in advance

    What was your answer?

  3. #3
    Junior Member
    Join Date
    Jan 2014
    Location
    Delhi
    Posts
    2
    My Mood
    Tired
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Interview Question asked to me can somebody help me ! Thanks in advance

    i started with nested for-each loop and said that every time i will check whether there is any child element of that .and if child element is there i will go for the next loop .but he restrict me saying that the hierarchy is not limited .try it with recursion.then i started using recursion but i don't know how to pass the element when i know that there is a child element of any element because java doesn't support pointers so how can i pass the exact index to my function?

Similar Threads

  1. Question about what can be asked here.
    By mist4lyf in forum Java Theory & Questions
    Replies: 1
    Last Post: April 7th, 2013, 07:35 PM
  2. Interview Question
    By thelegendery in forum Java Theory & Questions
    Replies: 0
    Last Post: February 3rd, 2013, 02:28 PM
  3. Interview Question
    By Darek in forum What's Wrong With My Code?
    Replies: 6
    Last Post: August 8th, 2012, 08:39 AM