Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8035347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:17:00+00:00 2026-06-05T02:17:00+00:00

I was asked to write something that would determine if an array is a

  • 0

I was asked to write something that would determine if an array is a subset of another larger array. I’ve decided to start with a simpler problem and written a function that will determine if a character present in an array of characters.
I’ve came up with this code:

private static boolean findSequenceRecHelper(char [] findIn, char c, int index) {
    boolean result = false;
    if(index<findIn.length) {
        if(findIn[index] == c) {
            result = true;
        }
        else {
            findSequenceRecHelper(findIn,c,index+1);
        }
    }
    return result;
}

I’ve done some debugging and found that the function iterates through the whole char[] array and when an element in array equals to desired value, result turns to true. But then again it turns to false and false is actually returned, which is incorrect.

I can’t find an error here – can someone please help me with this problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:17:01+00:00Added an answer on June 5, 2026 at 2:17 am

    In the recursive step:

    else
    findSequenceRecHelper(findIn,c,index+1);
    

    You should return the value returned by the recursive call. Otherwise – nothing is being done and the recursive call is actually redundant.

    private static boolean findSequenceRecHelper(char [] findIn, char c, int index)
    {
    boolean result = false;
    if(index<findIn.length)
    {
        if(findIn[index] == c)
            result = true;
        else
        return findSequenceRecHelper(findIn,c,index+1);
        //^ 
        //added return here
    }
    return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was asked to write a servlet that collects client's details such as ip,
I have been asked to write an application that is going to act as
I got asked to write a little PHP script that takes some POSTed input
My boss just asked me to write a little test for people that are
I have been asked to write a java program on linux platform. According to
I've been asked to write a program which generates reports in the form of
I have been asked to write a program using python for an assignment. I
I have been asked to write a compliment website/service for an iPhone app. The
I've been asked to write a web application in PHP to handle customers, sales,
I was interviewed recently and asked to write mystrcat(*s1, *s2, *s3) where s1 and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.