Understanding Recursion part II

Hello;
I went back through the chapter on recursion and realized part of my problem was not understanding what happens in the steps.
Some calls are easy to understand like this one
import java.util.*
public class CountDown
private int count;
public static void main(String[] args)
CountDown countDowner = new CountDown( );
countDowner.getCount( );
countDowner.showCountDown( );
public void getCount( )
System.out.println("Enter a positive number:");
Scanner keyboard = new Scanner(System.in);
count = keyboard.nextInt( );
if (count <= 0)
System.out.println("Input must be positive.");
System.out.println("Try again.");
getCount( );//start over
public void showCountDown( )
int left;
System.out.println("Counting down:");
for (left = count; left >= 0; left--)
System.out.print(left + ", ");
System.out.println("Blast Off!");
}Here's one I'm stuck understanding ;
This program returns ten to the power of user integer.
import java.util.*;
public class tenToThe
public static void main(String[] args)
Scanner keyboard = new Scanner(System.in);
System.out.println("Please enter an integer greater than zero");
int userNumber = keyboard.nextInt();
double result = (double)tenToThe(userNumber);
System.out.println("10 to the " + userNumber + " power is "
+ result);
private static double tenToThe(int n)
if (n==0)
return 1;
else
return (tenToThe(n-1)*10);
}So when I put in three as my user integer, the first if is not true, but it looks like the next expression is equivalent to (3-1)*10 equal 20??
I don't see how they got to 1000.
Last bits. Tonight I wrote an iterative method that sums an array hoping it might give me insight how to make it recursive. This works but still stumped. What would be the steps to make it recursive?
public class iterativeSumArray
     /** iterative method returns the value of each element in array */
     public static void main(String[] args)
               int[] a = {2,3,4,5,6,7,8,9};
               System.out.println(iterativeSumArray.sumArray(a));
     private static int sumArray(int[] theArray)
          int sum = 0;
          for (int i=0; i< theArray.length-1; i++)
               sum += theArray;     
          return sum;
Thanks again for your help and patience!
Edited by: Zarnon on Feb 28, 2008 6:41 PM
Edited by: Zarnon on Feb 28, 2008 6:42 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

if u know how to play with stacks or if u know How internally recursion works ( ofcourse with stack) , then i dont think ther is any difficulty u face while programming with recursion . (Make your data Structure fundamental clear, first . )
What would be the steps to make it recursive?
public class MySumArray
     static int sum, i, length;
     /** iterative method returns the value of each element in array */
     public static void main(String[] args)
               int[] a = {2,3,4,5,6,7,8,9};
               System.out.println(MySumArray.sumArray(a, a.length));
     private static int sumArray(int[] theArray, int length)
          if(length != 0)
               sum += theArray[length - 1];
               sumArray(theArray, --length);
          return sum;
}here i modify your code , to make it work recusively , but if u can do the same job by iterarion ( Java provide good Iterator class in java.util.*) , then dont go for recursion (it may happen u stuck in infinte recursive loop , and may stack overflow )
Hope this help..

Similar Messages

  • Dont understand partition part

    hi all,
    i had problems understanding this part of code.
    please advise. tks.
    insert into t_ri_contract_reinsurer
    contract_id,
    er_indi,
    er_limit,
    ri_code,
    share_rate,
    reinsurer_code,
    insured_status,
    er_risar,
    er_premium
    select contract_id,
    er_indi,
    er_limit,
    ri_code,
    share_rate,
    reinsurer_code,
    insured_status,
    --er_risar,
    -- defect number 9153 as at 02/10/2007
    -- modified by jeff
    er_risar * share_rate as er_risar,
    er_premium
    from (
    select contract_id,
    er_indi,
    er_limit,
    ri_code,
    share_rate,
    reinsurer_code,
    insured_status,
    er_risar,
    er_premium,
    row_number() over (partition by contract_id, er_indi, reinsurer_code order by contract_id) rn
    from rim2_contract_reinsurer) where rn = 1
    ;

    example...
    Each day employees make a number of sales. We want to know on which date each employee made their most sales and where they've made the same sales on more than one date we want to know the most recent date.
    If you break this down in your head you will want the row with the maximum sales per employee. The "per employee" tells us that we want to partition on employees. The maximum sales figure can be found by ordering the sales for that employee in descending order and the most recent date (if there are duplicates) will be the descending order on the date too, and then taking that first row of data for each employee...
    SQL> ed
    Wrote file afiedt.buf
      1  with testdata as (select 1 as emp_id, to_date('30/09/2007','DD/MM/YYYY') as sale_date, 15 units_sold from dual union all
      2                    select 1, to_date('01/10/2007','DD/MM/YYYY'), 10 from dual union all
      3                    select 1, to_date('02/10/2007','DD/MM/YYYY'), 13 from dual union all
      4                    select 2, to_date('28/09/2007','DD/MM/YYYY'), 29 from dual union all
      5                    select 2, to_date('29/09/2007','DD/MM/YYYY'), 5 from dual union all
      6                    select 2, to_date('30/09/2007','DD/MM/YYYY'), 14 from dual union all
      7                    select 2, to_date('01/10/2007','DD/MM/YYYY'), 29 from dual union all
      8                    select 2, to_date('02/10/2007','DD/MM/YYYY'), 7 from dual)
      9  -- END OF TEST DATA
    10  select emp_id, sale_date, units_sold
    11  from (
    12        select emp_id, sale_date, units_sold, row_number() over (partition by emp_id order by units_sold desc, sale_date desc) as rn
    13        from testdata
    14       )
    15* where rn = 1
    SQL> /
        EMP_ID SALE_DATE           UNITS_SOLD
             1 30/09/2007 00:00:00         15
             2 01/10/2007 00:00:00         29
    SQL>

  • HT2737 I understand this part but once it shows amount my account has why can I not use that to gift music.

    I understand this part but once it shows amount in my account why can I not use that amount shown to gift music?

    Apple doesn't allow that. They've never said why.
    (96758)

  • Issue : Types don't match between the anchor and the recursive part in column Sql server 2005

    My table structure as follow
    ID JID EntryDate RefundDate Comments Refund ActionBy
    3 41986 2013-12-17 12/24/2013 Cancel 0 Matt
    4 41986 2013-12-17 12/25/2013 done 1 Kelly
    5 41986 2013-12-17 12/24/2013 no 0 Smith
    i want this type of output after issuing sql
    JID EntryDate RefundDate Comments Refund ActionBy
    41986
    2013-12-17 12/24/2013 Cancel 0 Matt
    2013-12-17 12/25/2013 done 1 Kelly
    2013-12-17 12/24/2013 no 0 Smith
    just to get the above output i issued this sql as follows
    ;WITH Hierarchy AS
    -- Anchor
    SELECT TOP 1 JID
    ,NULL EntryDate
    ,NULL RefundDate
    ,NULL Comments
    ,NULL Refund
    ,NULL ActionBy
    ,nLevel = 1
    FROM refundrequested
    UNION ALL
    -- Recursive query
    SELECT E.JID
    ,E.EntryDate
    ,E.RefundDate
    ,E.Comments
    ,E.Refund
    ,E.ActionBy
    ,H.nLevel+1
    FROM refundrequested E
    JOIN Hierarchy H ON E.JID = H.JID
    SELECT *
    FROM Hierarchy
    ORDER BY JID, nLevel

    i did this way and the error vanished
    ;WITH Hierarchy AS
    SELECT TOP 1 JID
    ,CAST(NULL AS DATETIME) EntryDate
    ,CAST(NULL AS DATETIME) RefundDate
    ,CAST(NULL AS VARCHAR(MAX)) Comments
    ,CAST(NULL AS BIT) Refund
    ,CAST(NULL AS VARCHAR(30)) ActionBy
    ,nLevel = 1
    FROM refundrequested
    UNION ALL
    SELECT E.JID
    ,E.EntryDate
    ,E.RefundDate
    ,E.Comments
    ,E.Refund
    ,E.ActionBy
    ,H.nLevel+1
    FROM refundrequested E
    JOIN Hierarchy H ON E.JID = H.JID
    SELECT *
    FROM Hierarchy
    ORDER BY JID, nLevel
    but a new error is showing and that is The statement terminated. The maximum recursion 100 has been exhausted before statement completion. how to fix this problem? please guide me. thanks

  • Datatypes in a recursive common table expression

    I'm trying to use a (recursive) common table expression to generate a list of dates. The following code is working fine with 11.2
    WITH dates ( nr, dt ) AS (
        SELECT 1, DATE '2005-02-01'
        from dual
        UNION ALL
        SELECT d.nr + 1, DATE '2005-02-01' + 1
        FROM dates d
        WHERE d.nr < 30
    SELECT dt
    FROM dates;But I would like to avoid repeating the start date in the recursive part, and I tried the following:
    WITH dates ( nr, dt ) AS (
        SELECT 1, DATE '2005-02-01'
        from dual
        UNION ALL
        SELECT d.nr + 1, d.dt + 1
        FROM dates d
        WHERE d.nr < 30
    SELECT dt
    FROM dates;But I get the following error: ORA-01790: expression must have same datatype as corresponding expression
    Now from my understanding the datatype should be DATE for both parts of the UNION.
    I also tried it with d.dt + interval '1' day but that produces the same error message. using to_date() instead of the ANSI date literal does not change it either.
    What am I missing here?

    castorp wrote:
    I'm trying to use a (recursive) common table expression to generate a list of dates. The following code is working fine with 11.2
    WITH dates ( nr, dt ) AS (
    SELECT 1, DATE '2005-02-01'
    from dual
    UNION ALL
    SELECT d.nr + 1, DATE '2005-02-01' + 1
    FROM dates d
    WHERE d.nr < 30
    SELECT dt
    FROM dates;But I would like to avoid repeating the start date in the recursive part, and I tried the following:
    WITH dates ( nr, dt ) AS (
    SELECT 1, DATE '2005-02-01'
    from dual
    UNION ALL
    SELECT d.nr + 1, d.dt + 1
    FROM dates d
    WHERE d.nr < 30
    SELECT dt
    FROM dates;But I get the following error: ORA-01790: expression must have same datatype as corresponding expression
    Now from my understanding the datatype should be DATE for both parts of the UNION.
    I also tried it with d.dt + interval '1' day but that produces the same error message. using to_date() instead of the ANSI date literal does not change it either.
    What am I missing here?http://www.orafaq.com/forum/mv/msg/95011/463394/102589/#msg_463394

  • Recursive

    Hi i got a number and it goes like that. Its been tough for me to understand recursive. Any1 can do it for me and explain it to me. Thanks
    (i) In mathematics the Lucas Numbers are
    1, 3, 4, 7, 11, 18, 29, 47, 76, 123, ...
    They can be generated by the formula
    L(n) = L(n-1) L(n-2), n>2+
    where L(1) = 1 and L(2) = 3.
    Write a java recursive method that returns the nth Lucas Number, n is passed as parameter.
    (ii) Write an iterative version(using a loop) of the algorithm in (i) above.
    (iii) Explain why a simple recursive method of calculating L(n) could be extremely inefficient.
    Thats it.. can any1 help me please... Thanks

    No one is going to do it for you. If someone else does it for you, how will you learn?
    Let me give you a start tho.
    A recursive method is a method that calls itself till the base case is reached.
    You have base cases L(1) = 1 and L(2) = 3.
    so for example, if you were given a loop
    while(n > 0)
    System.out.println("HI");
    n--;
    In this loop, you are saying if n > 0 then print HI and decrement n.
    So, a recursive example for this one would be,
    Let's get the base case first. Since there is no base case. You could simply just write the calling itself part, but I am just going to write an empty one just to show you.
    public void Call(int n)
    if ( ! (n > 0) )
    else
           System.out.println("HI");
    // Call the method again.
           Call(n - 1);
    }did you see what I did? I used the base case for the if part (There is no base case for the example I provided and thus the actual way to do it would be different) then I said, if its not the base case, then use the else part print HI and then call the method again decrementing n till you reach the base case where n is != 0

  • Need some recursion assistance

    Hello,
    I'm trying to understand recursion,. I understand most of it, but this one thing is confusing me.
    public class recursion {
         public static void main(String[] args) {
              System.out.println(t(5));
         public static int t(int n) {
              if (n == 1 || n == 2) {
                   return 2 * n;
              else {
                   return t(n - 1) - t(n - 2);
    }I'm trying to understand the process for doing this recursion. -4 gets outputted from t(5), but I don't understand how to get that answer.
    I understand that t(n - 1) is called, and when it reaches 2, the base case is true. The part that confuses me is the t(n - 2) and how that comes into play. Can anyone help?

    E11 wrote:
    t(5)
    = t(4) - t(3)
    = (t(3) - t(2)) - (t(2) - t(1))
    = ((t(2) - t(1)) - t(2)) - (t(2) - t(1))
    = ((4 - 2) - 4) - (4 - 2)
    = (2 - 4) - (4 - 2)
    = -2 - 2
    = -4Nicely done.

  • Identifying which part of stored procedure is taking long time

    Hi Everyone,
    I have a stored procedure which is taking long time to execute.  I am trying to understand which part/query in the stored procedure is taking long time.
    It involves lots of table variables and n no of queries .Could anyone please help me in how to identify which query/part of the stored procedure is taking long time to execute?
    Thanks in Advance

    Hi Vivek -
    I am only familiar with running the plan visualization for a single SQL query.
    Could you please guide me how to run it for a procedure.
    Thanks in Advance.

  • Recursion:returning the largest value in a linked list

    import java.io.*;
    import java.util.*;
    class Node{
         int num;
         Node next;
         Node(int n){
              num = n;
              next = null;
    class RecursivePrint{
         public static void main(String[] args){
              Node np, last;
              Node top = null;
              last = null;
              for(int i = 1; i <11; i++){
                   np = new Node(i);
                   if(top==null)top = np;
                        else
                   last.next = np;
                   last = np;
              int x =Largest(top);
             System.out.println("large is "+ x);
         }//end main
         public static int Largest(Node top){
              int large = 0;
              if(top==null){
                   return 0;
                   while(top!=null){
               if(top.num > large){
                   large = top.num;
                   //top = top.next;
              Largest(top.next);     
         }//while
         return large;
    }//end class
    I am trying to return the largest value in a linked list (10) in this case.  when I do it withour recurrsion it works ok, but when I try it with recurrsion it dies.  The logic seems ok to me, cannot figure why it dies.

    chetah wrote:
    public static int Largest(Node top){
              int large = 0;
              if(top==null){
                   return 0;
              if(top.num > large){
                   large = top.num;
                   //top = top.next;
                   Largest(top.next);
         return large;
    Initially I had the above, it return only 1 that was the reason for puting the loop.You don't seem to understand recursion or variable scope.
    int large = 0;large is a different variable inside each instance of the method.
    So when you get back up to the value 1 from the recursive calls its just comparing 1 to 0
    Here's a solution...
         public static int Largest(Node top){
              if(top.next != null){
                   if(Largest(top.next) > top.num)
                        return Largest(top.next);}
              return top.num;
         }

  • Recursion and memory

    I have a program that generates XML. We noticed that it was using an extrodinary amount of memory. Thinking that the problem involved clobs I started researching the code. As I was benchmarking items I noticed that the problem did not seem to lie in the clobs i was creating but the recursion I was performing. Below I have two procedures. They both create X number of clobs and append their results to a main clob. I ran both for 10,000 iterations and recorded the results. The recursive version took longer(pretty much as i suspected) and took almost 5x the memory(way more than I could ever expect). Is there any thing that can be done to decrease the memory overhead involved with recursion. The program I was benchmarking for traverses a tree structure and the trees can sometimes be very large. Recursion keeps the code very flexible and much easier to read(once you get past the recursion part, as it can be confusing at times). In one case the memory that the oracle service was using jumped from 147mb to 1.4gb. This is not even remotely acceptable and I really want to find a solution other than rewriting the core of the tree traversing logic.
    Below is the sample code for my benchmarking and the results
    CREATE OR REPLACE PROCEDURE make_clobs(v_num_clobs IN NUMBER)
    IS
    TYPE t_clob_ar IS TABLE OF CLOB INDEX BY BINARY_INTEGER;
    v_arr t_clob_ar;
    v_main CLOB;
    BEGIN
    FOR i IN 1..v_num_clobs LOOP
    v_arr(i) :='123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789-'||chr(13);
    v_main := v_main||v_arr(i);
    END LOOP;
    dbms_output.put_line(dbms_lob.getlength(v_main));
    END;
    create or replace PROCEDURE recursion(p_start IN NUMBER, p_limit IN NUMBER, p_clob IN OUT CLOB)
    is
    begin
    p_clob := p_clob||'123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789-'||chr(13);
    IF(p_start <= p_limit)THEN
    recursion(p_start + 1, p_limit, p_clob);
    END IF;
    end recursion;
    RESULTS:
    10,000 iterations
    ~80 character clobs(per iteration)
    program start mem end mem total mem time total clob len
    make_clobs(for loop) 103,740 112,684 8,944 445.781s 810000
    recursion 103,532 147,284 43,752 1037.469s 810081

    Based off what was said earlier I recreated the recursion function inside a package and used a package spec globally defined clob. I removed the clob from the parameter list. I ran it for 4000 iterations and got the same results as a 4000 iteration on the original recursion procedure.
    Below is the code from both recursion procedures. They both reside in the same package. in the package spec the clob pv_clob is declared
    recursion_int_clob uses the internal clob and recursion_clob uses the parameter
    PROCEDURE recursion_int_clob(p_start IN NUMBER, p_limit IN NUMBER)
    is
    begin
    pv_clob := pv_clob||'123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789-'||chr(13);
    IF(p_start <= p_limit)THEN
    recursion_int_clob(p_start + 1, p_limit);
    END IF;
    end recursion_int_clob;
    PROCEDURE recursion_clob(p_start IN NUMBER, p_limit IN NUMBER, p_clob IN OUT NOCOPY CLOB)
    is
    begin
    p_clob := p_clob||'123456789 123456789 123456789 123456789 123456789 123456789 123456789 123456789-'||chr(13);
    IF(p_start <= p_limit)THEN
    recursion_clob(p_start + 1, p_limit, p_clob);
    END IF;
    end recursion_clob;
    4,000 iteration results
    program total mem usage time
    recursion_in_clob 17352 166.375s
    recursion_clob 17788 104.922s
    any ideas on why this might be?

  • Understanding 5505 firewall-site to site and internet traffic

    Hi,
    My question is mutli-faceted. I apologize for the lengthy intro here but i think the info is necessary to understand where I am headed in this.
    I am new to the cisco 5505. I have had very limited exposure to a 5510 that was preset. I have managed to make modifications to it here and there, but dont completely understand how it was put together. I learn by watching, listening, and gleaning what I can from others. I have had no formal training in CLI, but I have learned some of the commands. I know enough to be dangerous, but I respect my limitations.
    That being said, I have been charged with setting up a 5505 at a remote site. I need to accomplish several things.  Our ultimate goal is to use this device as a site to site with the 5510 at the corporate office. However, I need to accomplish this in baby steps, test, test real users and then maybe convert in full. Where I could outsource this in its entirety, that would preclude me from learning so I can address this in the future on my own.
    We need to have this in place by the end of February 2013.
    Currently the remote site is connected via a very slow (by todays standards) T1 line on a MPLS. Stable. Works, but slow. All internet traffic as well as work traffic is routed through that connection. We have added a 50mb cable connection (with static ips) to the office. First we want to set up the 5505 so that it can be used as follows:
    1, Internet traffic can be routed out through this device and all other "work" traffic routed through the MPLS.
    2, Test using this connection as a route out to the internet AND use it as a site to site VPN connection to the home office. (or anyconnect vpn)
              I need to be able to have users in both environments. IE, some still using step 1 and some starting to use and test step 2.
    3, long term, use this as the main connection per number 2, but add the IP address so that if the cable connection drops, the office can access internet via the VoIP T1 line as a life line.
    In all cases, I dont want internet going through the home office as it currently is traveling.
    I have done a lot of searching but so far have come up empty with answers.
    Question 1:     (This one probalby shows my ignorance the worst) - in using the 5505 firewall, will it segregate normal internet traffic from the VPN traffic when used by the workstation? Using the Gui, I didnt see where this was necessarily happening. Do I need to use CLI language (and what) to make this happen? Or is that a basic function that happens during the setup of the firewall using the GUI. Do I need to do some sort of "split tunneling"?
    Question 2:     Do I use this device as the Default gateway for both step 1 and 2/3) for normal use and then change the gateway on the Pcs to the VoIP network during emergency use,(that would bypass the firewall though or is there a way to have it route to that router if there is no connection through the Outside port? Or as long as I have some access to the device, can I make a change remotely to help accomplish this failsafe?
    Question 3:     We have 25 Anyconnect VPN licenses. Should we use these and not the Static site to site, if so, why or why not? They dont need to be used at all.
    Question 4:     In setting up the VoIP line for backup, would using that on the "DMZ" connection help in making this viable so that the device could still ultimately control the internet traffic?
    Question 5:     In setting up the VPN connections, unless i am getting the two methods confused, I will need the 5505 to hand out IP addresses for the vpn connection. I see in using a class c schema that i can use 92.168.0.0 to 192.168.255.0. So for instance, I could use 101.1.20.0 for the inside network Vpn addresses?? I need to stay away from 192.168.0.0 networks as we use that in our normal structure.
    Reasons for setting this up:
    Slow speeds over the T1.
    increasing demand for Skype, Video conferencing etc that the T1 pipe couldnt adequately handle
    Lack of backup pathways for downed connections - ie, backhoe chopping through wire at a construction site).
    I read through the Getting started guides on both the 5510 and the 5505 and feel I can likely get the site to site setup (I have a list of all the Ip addresses i need for inside networks and outside networks etc.
    additional notes:
    I have to email ATT anytime I want a change made on the MPLS router, so doing as little to that as possible would be good.
    I will be onsite for testing at the end of February  and will have direct access to the home office via other methods to work on the asa5510 if any additional work needs to be done on it once i am onsite.
    Thanks for taking the time to read through all of this. please forgive my lack of knowledge...
    Dave

    Thanks for getting back to me and so quickly!
    1) I am not sure if I understand the “ACL” portion of your question, but this is how I want to access info via the VPN tunnel:
    192.168.D.0 inside(NJ) to outside 5505 - 12.175.X.X to outside 5510 - 12.200.X.X to inside network (HQ)192.168.X.0. Routes are needed to find subnets 192.168.A.0, 192.168.B.0 and 192.168.C.0. The default gateway to those subnets right now is: 192.168.X.XX4 inside of HQ. This would be so that the NJ office could find resources of the other offices if needed. This will change as we wean off the MPLS. Inside the ASA 5505, the IP addresses are 192.168.D.0 for data, 10.X.X.0 for the Phone system. All other traffic would be sent out through the internet. Phone system uses the XOcomm conection to route phone traffic.
    2) I did some reading on SLA. Thanks for pointing that out. For purposes of learning here, I am showing this as 12.175.XXX.XXX for Comcast and 12.200.XXX.XXX for XO comm.
    4) I guess I would use an Outside 2 as that makes sense, in description, I would label them “ComCast” for outside 1 and “XOcomm” for outside 2.
    5) I am still not sure I understand this part. Are additional IP addresses needed for the Site to site VPN to talk to the local hosts, or will it use the IP addresses assigned by the local server?
    Next Steps
    1-         Configure the ASA5510 for the 5505 connection
    2-         Configure the ASA5505 for the 5510 connection
    3-         Configure SLA for Comcast and XOcomm outside connections
    4-         For this I need help….I think this is from step 1, but I need help to configure the internet to be segregated via my question from #1. Have I given enough information to do so? Please advise on ACL entries, and route statements needed so that NJ can talk to all the offices when using this connection, not just the Headquarters.
    Thanks
    dave

  • Where to download Oracle Student System, part of Oracle E-business suite 11

    I am very new to Oracle E-Business suite of applications, but need to download Oracle Student System, which as I understand is part of the suite. Currently, on E-delivery, on release 12.1 is available, which doesnt contain OSS. Any ideas where to get this application? Is it available on its own as well?
    Many thanks in advance.

    Hi,
    Most Oracle Apps 11i software were removed from e-Delivery website, and in order to get the software, you will have to log a SR and ask Oracle support to send you the Media Pack (this requires having a valid Metalink account).
    Regards,
    Hussein

  • Recursion Help (I don't get this)

    I feel so stupid. I just can't understand recursion.
         public static int fib(int n)
              int result;
              if (n <=2)
                   result = 1;
              else
                   result = fib(n-1) + fib(n-2);
              return result;
         }The above is the famous Fibonacci method. But I DON'T GET IT. How the heck does this work? I don't understand how the recursive case works (result = fib(n-1) + fib(n-2)).
    The way I understand it:
    If we were to call call fib(5)...
    recursive case:
    result = fib(n-1) + fib(n-2); -> 4 + 3
    The result would be 7, and then we would be done because we've reached the base case (n <=2). The correct answer is 5, so I'm obviously wrong. I just can't grasp this key concept. I'm feeling very noobish. :(

    I should add that recursion is related to
    mathematical induction, a powerful tool in
    mathematics.
    And once you get used to thinking about recursion,
    you should see that in many ways recursive solutions
    are simpler and clearer than non-recursive approaches.Ever so true but an efficient recursive solution should use a stack of
    depth log(n), where n is the problem size, at most. It should also not
    recompute what has been computed before.
    The naive recursive fibonacci function doesn't fit that bill: it uses a stack
    of size n for the calculation of fib(n) and it recalculates what has been
    calculated before many times.
    kind regards,
    Jos

  • Calculating Subsets of an Array Recursively?

    I'm just really confused here...
    I need to take a positive integer n
    E.G.
    Output:
    Enter n: 3
    {1}
    {2}
    {3}
    {1, 2}
    {1, 3}
    {2, 3}
    {1, 2, 3}
    I know how to take input and all of that jazz... But I'm just abhorrently stuck with the recursion part...
    Help me out?

    petes1234 wrote:
    What works for me is I start with the trivial an work my way up. This means that I start with an array of 0 items, then 1item, and 2 items, and think through with pencil and paper how I would recursively figure out all the permutations (or is it combinations -- my math is getting rusty!). Then see if I can come up with an algorithm that will work for an array of any size. But again, firstly, think small and simple!I usually do it the opposite way:
    1. Figure out the base case (I get we are not into the opposite part yet!)
    2. Assuming you know how to solve the case of size N, use that to solve the case of size N+1.
    This is easy: if you can generate all the combinations of 1...N, the combinations of 1...N+1 will be that list repeated twice: once without adding (N+1) and once adding (N+1).

  • Understanding wsdl file to be called from Partner link

    Hii All,
    I am trying to understand the wsdl file. This file is being called from a partner link. I have understood most of the part of it but could not understand the following:
    <jca:operation
    LogicalDirectory="inputTriggerDir"
    ActivationSpec="oracle.tip.adapter.file.inbound.FileActivationSpec"
    IncludeFiles=".*\.trg"
    PollingFrequency="10"
    MinimumAge="0"
    DeleteFile="true"
    OpaqueSchema="false" >
    </jca:operation>
    Would appreciate if you could please help to make me understand this part of wsdl file. I have noticed that if i change the value of LogicalDirectory parameter then the build does not deploy successfully. Somehow it is linked with the bpel.xml...Please suggest me how?
    Appreciate your help..
    Thanks,
    Regards,
    AS

    This is the operation that will be performed when a file is read.
    LogicalDirectory = This is the property you have specified to identify the directory to poll. This is best practice, if you do this then you need to specify a name in the bpel.xml file. This also means you can change the directory on the fly within the BPEL console. If you right-click on the recieve for the partner link there is a property tab add the property inputTriggerDir and give the value of the directory on the server.
    ActivationSpec = This is just a pointer to the java code, this is defaulted and should not be changed.
    IncludesFiles = in your case you are looking for files with the extension of .trg
    PollingFrequency = in your case 10 second interval
    MinimumAge = This allows you to put a buffer so if a file takes some time to load you can put a wait until you get the full file.
    DeleteFile = Once read it will delete
    OpaqueSchema = If true means that you have specified no schema and is read in as binary. This is used for pass through, what you read in is what comes out the other side. Manly used for pdf and images.
    cheers
    James

Maybe you are looking for