top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Implement the following functions recursively in the code linked list type

0 votes
363 views

int seqSearch(int key); // this is a member function of the linkedListType class. It searches for the value key in the linked list. If the key is found, then its position is returned. Otherwise, -1 is returned. NOTE: in order to implement this function, you need to implement another private member function to send it the first pointer. Here is the prototype for the private member function:

int recSeqSearch(nodeType *p, int key);

#include <iostream>
using namespace std;

struct nodeType
{
    int info;
    nodeType *next;
};

class linkedListType
{
public:
    linkedListType();
    int listSize();
    bool isEmpty();
    int seqSearch(int);
    void remove(int);
    void insertFirst(int);
    void insertEnd(int);
    void insertAt(int, int);
    void removeAt(int);
    void print();
    void clearList();
    void insertOrdered(int);
    void removeFirst();
    void removeLast();
    void removeLast2();
    int removeOddSumEven();
     ~linkedListType();  


private:
    nodeType *first, *last;
    int length;
};
posted Nov 23, 2013 by As M Ob

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button
Not sure about recursion but you can take a look at open implementations  they might have few of them in recursion.
https://github.com/zhemao/libds
http://home.gna.org/gdsl/

...