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

  • Home
  • SEARCH
  • 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 8096663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:31:29+00:00 2026-06-05T21:31:29+00:00

I read that using recursion with Divide and Conquer method is efficient. Could anyone

  • 0

I read that using recursion with Divide and Conquer method is efficient. Could anyone suggest how can i improve the recursion call below. All it does is repeat the element “a”, 80 times to the output. However it just repeats eighty times without any algorithm. Also how does it improve the performance(any links or pointers?)

<xsl:variable name="maxcount" select="'80'" />
<xsl:variable name="count" select="'1'" />
<xsl:if test="$count &gt; 0">
  <xsl:call-template name="copyrec">
    <xsl:with-param name="index" select="'1'" />
  </xsl:call-template>
</xsl:if>
<xsl:template name="copyrec">
  <xsl:param name="index" />
  <xsl:if test="$index &lt;= $maxcount">
    <xsl:variable name="tmpind" select="$index"/>
    <a>this element repeats 80 times</a>
    <xsl:call-template name="copyrec">
      <xsl:with-param name="index" select="$tmpind + 1" />
    </xsl:call-template>
  </xsl:if>
</xsl:template>
  • 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-05T21:31:30+00:00Added an answer on June 5, 2026 at 9:31 pm

    Divide and conquer will reduce the amount of stack space used by this code, but it will not make it any faster. For 80 repetitions, there is almost certainly enough stack space, so you might as well use it. For 10000 repetitions, your code will still run fine if the processor implements tail call optimization. But if you want to be sure not to run out of stack space even with 10000 iterations and with a processor that doesn’t do this basic optimization, then D+C is also very simple for this case:

    <xsl:template name="copyrec">
      <xsl:param name="count" />
      <xsl:choose>
        <xsl:when test="$count = 0"/> <!-- do nothing -->
        <xsl:when test="$count = 1">
          <a>this element repeats 80 times</a>
        </xsl:when>
        <xsl:otherwise>
          <xsl:call-template name="copyrec">
            <xsl:with-param name="count" select="floor($count div 2)" />
          </xsl:call-template>
          <xsl:call-template name="copyrec">
            <xsl:with-param name="count" select="$count - floor($count div 2)" />
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:template>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Throughout a Bison grammar I am using right recursion, and I have read that
I have read that a using like this: using (myObject) { myObject.DoStuff(); } Can
I've read some posts stating that using this method is not good, shouldn't be
I've read that using Object.prototype to attach functions to custom JavaScript objects is more
I want to get randomized results for a query. I read that using RAND()
I read in a few posts that using JUnit to test concurrency is not
i have read in more then one place that using NHibernate's Identifier as Primary
I have read that to match a word inside of a string using Regular
I'm new to using Java Enums and I've read that replace IF logic that
I read that using raw pointers in C++ is bad. Instead we should use

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.