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 9312079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T01:32:28+00:00 2026-06-19T01:32:28+00:00

Am working on some programming homework and am a bit lost. The project is

  • 0

Am working on some programming homework and am a bit lost. The project is to select the even/odd elements of a listarray and store in another array. It is not the even numbers in each element, but the elements themselves so if an array had values “1,2,5,7,9” and returned the even elements it would give “1, 5, 9”. Also have to use recursion. Would anyone be able to give me a starting point or some advice. Though about starting with 2 elements and taking 2nd element and then building up from that, but don’t know how it would add on the 2nd pass

 public static ArrayList<Integer> even(ArrayList<Integer> list)
 ArrayList<Integer> evenlist = ListMethods.deepClone(tList);//make copy of list
 if (evenlist.size()<=1)    // The list is empty or has one element
 {
//        return null;// Return the list as is
 }

if 
(evenlist.size()==2)
{
 //return right element
 //call method again
 //add to list
}
  • 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-19T01:32:29+00:00Added an answer on June 19, 2026 at 1:32 am

    This sounds similar to the homework I just completed, so if it is (And you’re in my class!), I’ll not tell you to use any terminology we haven’t covered as I know it can be daunting trying to discover something new for practicals (beyond what we have to do).

    First, set your exit condition. As you’ve already said, you have to create a new ArrayList out of the existing one. You are going to remove items from the existing ArrayList, storing the integers that are at even (or odd) indices, until the list is empty.

    So your exit condition is:

    if (evenList is Empty)
        return evenList;
    

    Then, work your way through the steps. I would advise determining if the Array you start with has an even of odd number of steps, something like this:

    if (evenList has Even Elements)
        int holderForIntsAtEvenElements = last evenList EVEN element
    

    Note we start at the last element, so when you are coming OUT of the recursive method, this will be the last one added to your new ArrayList, and thus it’ll be in numerical order. You might find this post interesting to do this: What does this boolean return mean?

    We then want to remove the last element from the list and recursively call the method again.

    Finally, when we hit our exit condition and start to come out, we want to add the ints we’ve been storing to them, e.g.:

    evenList.add(holderForIntsAtEvenElements);
    return evenList;
    

    That doesn’t solve one problem, which is what to do with the very first element if the list does NOT have an even number of elements – however, I’ll let you try and solve that!
    That’s a good mix of code and pseudo code and will hopefully help to get you on the right track.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on my first homework project in a web programming class, which is
I am working on some review material for dynamic programming. I need to come
I'm still working my way through some pretty basic Actionscript programming (in Flex), and
I've been trying to learn some programming on my own by working through the
I am working on some old Flex project (Flex 2.0.1 hotfix 2) and I
I am working on some socket programming stuff and attempting to match some strings.
I'm working on programming some application and I would like to create while loop
I have not done much database programming at all. I am working from some
I am working on a homework problem. For Database SQL programming. Q4. Using today’s
I'm working with CUDA (GPGPU programming) for some research and the innate Double Precision

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.