Thread: Recursion Revisited again, and again!

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Registered User VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,607
    This may help.

    Code:
    template <class elemType>
    int arrayListType<elemType>::seqSearch(const elemType& item)
    {
       static int loc =0;
       loc++;
       //Assuming here that length and list are members
       if (length == 0 || loc == length)
       { 
          return -1;
       }
       else if (list[loc] == item)
       {  
         return loc;
       }   
       else
       {
         return seqSearch(item);  //THIS IS MY PROBLEM STATEMENT - MENTAL BLOCK!!!
       }
    
    } //end seqSearch
    Last edited by VirtualAce; 12-01-2007 at 01:52 PM.

Popular pages Recent additions subscribe to a feed