neel help in recusive call

You need to write a permute class that will take first and second strings to rearrange letters in first, followed by second. For example, if the first is “CAT” string and second is “MAN” string, then the program would print the strings TACMAN, ATCMAN, CTAMAN, TCAMAN, ACTMAN, and CATMAN. The first and second strings can be any length of string or a null.



The permute class uses a Note class as link list note to link all letters arrangement. The permute class has Note pointers, firstNote and lastNote, to point to the beginning and ending Notes of the link list as private data members. There are three other private data members (total, firstString and secondString) to store the total possible number of arrangements and strings pass into the class.



Write a driver to test the permute class to pass in any two strings of any sizes.



Other than mention in the following, you can add more classes, functions, and private data members to this program.



Note class

The Note class needs to have two private data members and a constructor. The two private data members are data and p pointer. The data’s data type is string and p pointer is Note. The Note class constructor has two parameters, one is string and the other is Note pointer.



Permute class

The Permute class has five private data members (*firstNote, *lastNote, total, firstString and secondString). The firstNote and lastNote pointers are point to Note. The total has integer data type. The firstString and secondString have string data type.



There should have at least three public member functions, Permute, permutation and print. The Permute function is the constructor which takes strings to initialize the private data members. The permutation function does the recursive call to arrange the strings and setup the link list. The print function will print out the private data member information.



Driver file

The driver file should declare a Permute eight elements pointer array. Instantiate eight Permute object with the following eight set of data and assign the object to the pointer array. Use a repetition to call the object’s print function to print out the private data member information. If the total of the permute private data member is less than 100 then print out the permutated letters four in a row, otherwise print out 9 in a row.

first = "", second="",

first = "", second ="CATMAN",

first = "C", second ="ATMAN",

first = "CA", second ="TMAN",

first = "CAT", second ="MAN",

first = "CATM", second ="AN",

first = "CATMA", second ="N",

first 1 = "CATMAN", second ="";



You are welcome to use more advance skills than the techniques

 
  im a beginner in c++ all the help will be helpful
What have you started with? I don't even see a question.
opps sorry the questions is
write a program from above to give the the output shown belowthe output is


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
String 1 for this object is:
String 2 for this object is:
There is no permutation.



String 1 for this object is:
String 2 for this object is: CATMAN
The total possible permutation is 1
That is:
CATMAN

String 1 for this object is: C
String 2 for this object is: ATMAN
The total possible permutation is 1
That is:
CATMAN

String 1 for this object is: CA
String 2 for this object is: TMAN
The total possible permutation is 2
They are:
ACTMAN CATMAN

String 1 for this object is: CAT
String 2 for this object is: MAN
The total possible permutation is 6
They are:
TACMAN ATCMAN CTAMAN TCAMAN
ACTMAN CATMAN

String 1 for this object is: CATM
String 2 for this object is: AN
The total possible permutation is 24
They are:
MTACAN TMACAN AMTCAN MATCAN
TAMCAN ATMCAN CMTAAN MCTAAN
TCMAAN CTMAAN MTCAAN TMCAAN
ACMTAN CAMTAN MACTAN AMCTAN
CMATAN MCATAN TACMAN ATCMAN
CTAMAN TCAMAN ACTMAN CATMAN


String 1 for this object is: CATMA
String 2 for this object is: N
The total possible permutation is 120
They are:
AMTACN MATACN TAMACN ATMACN MTAACN TMAACN AAMTCN AAMTCN MAATCN
AMATCN AMATCN MAATCN TAAMCN ATAMCN ATAMCN TAAMCN AATMCN AATMCN
MTAACN TMAACN AMTACN MATACN TAMACN ATMACN CAMTAN ACMTAN MCATAN
CMATAN AMCTAN MACTAN TCAMAN CTAMAN ATCMAN TACMAN CATMAN ACTMAN
MTCAAN TMCAAN CMTAAN MCTAAN TCMAAN CTMAAN AMTCAN MATCAN TAMCAN
ATMCAN MTACAN TMACAN ACAMTN CAAMTN AACMTN AACMTN CAAMTN ACAMTN
MACATN AMCATN CMAATN MCAATN ACMATN CAMATN AMACTN MAACTN AAMCTN
AAMCTN MAACTN AMACTN CAMATN ACMATN MCAATN CMAATN AMCATN MACATN
TACAMN ATCAMN CTAAMN TCAAMN ACTAMN CATAMN ATACMN TAACMN AATCMN
AATCMN TAACMN ATACMN CATAMN ACTAMN TCAAMN CTAAMN ATCAMN TACAMN
ACATMN CAATMN AACTMN AACTMN CAATMN ACATMN MTACAN TMACAN AMTCAN
MATCAN TAMCAN ATMCAN CMTAAN MCTAAN TCMAAN CTMAAN MTCAAN TMCAAN
ACMTAN CAMTAN MACTAN AMCTAN CMATAN MCATAN TACMAN ATCMAN CTAMAN
TCAMAN ACTMAN CATMAN

String 1 for this object is: CATMAN
String 2 for this object is:
The total possible permutation is 720
They are:
NAMTAC ANMTAC MNATAC NMATAC AMNTAC MANTAC TNAMAC NTAMAC ATNMAC
TANMAC NATMAC ANTMAC MTNAAC TMNAAC NMTAAC MNTAAC TNMAAC NTMAAC
AMTNAC MATNAC TAMNAC ATMNAC MTANAC TMANAC ANAMTC NAAMTC AANMTC
AANMTC NAAMTC ANAMTC MANATC AMNATC NMAATC MNAATC ANMATC NAMATC
AMANTC MAANTC AAMNTC AAMNTC MAANTC AMANTC NAMATC ANMATC MNAATC
NMAATC AMNATC MANATC TANAMC ATNAMC NTAAMC TNAAMC ANTAMC NATAMC
ATANMC TAANMC AATNMC AATNMC TAANMC ATANMC NATAMC ANTAMC TNAAMC
NTAAMC ATNAMC TANAMC ANATMC NAATMC AANTMC AANTMC NAATMC ANATMC
MTANAC TMANAC AMTNAC MATNAC TAMNAC ATMNAC NMTAAC MNTAAC TNMAAC
NTMAAC MTNAAC TMNAAC ANMTAC NAMTAC MANTAC AMNTAC NMATAC MNATAC
TANMAC ATNMAC NTAMAC TNAMAC ANTMAC NATMAC AMTANC MATANC TAMANC
ATMANC MTAANC TMAANC AAMTNC AAMTNC MAATNC AMATNC AMATNC MAATNC
TAAMNC ATAMNC ATAMNC TAAMNC AATMNC AATMNC MTAANC TMAANC AMTANC
MATANC TAMANC ATMANC CNAMTA NCAMTA ACNMTA CANMTA NACMTA ANCMTA
MCNATA CMNATA NMCATA MNCATA CNMATA NCMATA AMCNTA MACNTA CAMNTA
ACMNTA MCANTA CMANTA NAMCTA ANMCTA MNACTA NMACTA AMNCTA MANCTA
TCNAMA CTNAMA NTCAMA TNCAMA CNTAMA NCTAMA ATCNMA TACNMA CATNMA
ACTNMA TCANMA CTANMA NATCMA ANTCMA TNACMA NTACMA ATNCMA TANCMA
CNATMA NCATMA ACNTMA CANTMA NACTMA ANCTMA MTCNAA TMCNAA CMTNAA
MCTNAA TCMNAA CTMNAA NMTCAA MNTCAA TNMCAA NTMCAA MTNCAA TMNCAA
CNMTAA NCMTAA MCNTAA CMNTAA NMCTAA MNCTAA TCNMAA CTNMAA NTCMAA
TNCMAA CNTMAA NCTMAA AMTCNA MATCNA TAMCNA ATMCNA MTACNA TMACNA
CAMTNA ACMTNA MCATNA CMATNA AMCTNA MACTNA TCAMNA CTAMNA ATCMNA
TACMNA CATMNA ACTMNA MTCANA TMCANA CMTANA MCTANA TCMANA CTMANA
NAMTCA ANMTCA MNATCA NMATCA AMNTCA MANTCA TNAMCA NTAMCA ATNMCA
TANMCA NATMCA ANTMCA MTNACA TMNACA NMTACA MNTACA TNMACA NTMACA
AMTNCA MATNCA TAMNCA ATMNCA MTANCA TMANCA ACNAMT CANAMT NACAM
I mean what is your question not what are your instructors instructions.
What are you having a hard time with? I don't think anyone here will do this assignment for you just for the kicks.
this is what i have got written:
BUT IT IS NOT COMING AS OUTPUT IT FAILS TO COMPILE

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include <cstdlib> // Provides size_t // included in permute_append.h
#include <sstream> // provides the << operator for string concatenation. // not using
#include <string> //provides string type //included in permute_append.h
#include "permute_append.h"
using namespace std;
namespace CISP430_A5 
{
 
	/*CONSTRUCTORS, DECONSTRUCTOR*/
	
        permute_append::permute_append() {
			firstString = "CAT"; // x is just a default value
			secondString = "MAN"; // x is just a default value
			total = 0;
		}
	
		permute_append::permute_append(const char* first, const char* second) {
			firstString = first;
			secondString = second;
			
			total = 1; // at least one permutation
			for (int i=firstString.length(); i>0; --i) { // number of permutations is equal to factorial of the number of characters in firstString
						total *= i;
			}
			/*Turn string into linked list of chars*/
			for (int i=0; i<firstString.length(); ++i) {
						permute_me.add(firstString[i]);
			}
		}
		permute_append::permute_append(const permute_append &source) {
			firstString = source.firstString;
			secondString = source.secondString;
			total = source.total;
			permute_me = source.permute_me;
			result_list = source.result_list;
		}
		permute_append::~permute_append() {
			total = 0;
			firstString = "";
			secondString = "";
			/*so I guess we don't need to delete the linked_list object manually*/
			// delete permute_me;
			// delete result_list;
		}
	linked_list<string> permute_append::permute(linked_list<char> charList) { // permute the characters in the array (n items, n at a time)
	/*Returns a linked_list of strings, each string a permutation of the chars in charList.*/
			static linked_list<string> perms; static linked_list<char> usedChars;
			linked_list<char> character;
			for (int i = 0; i < charList.size(); ++i) {
						character = list_splice(charList, i, 1); //??? How do we pass charList to list_splice so list_splice modifies charList directly? Answer: just like I did.
						usedChars.add( character.get(0) );
						if (charList.size() == 0) perms.add( charList_join("", usedChars) ); //??? Is charList_join() working? I believe so.
						permute(charList);
						list_splice( charList, i, 0, character.get(0) );
						list_pop( usedChars );
			}
			return perms;
	}

	string permute_append::do_it() {
	// appends secondString to each permutation of firstString and stores each result in result_list
			linked_list<string> perms( permute(permute_me) ); // ??? How do you point to the returned linked_list properly?
			// string result = "";
			for (size_t i=0; i<perms.size(); ++i) {
						result_list.add(perms.get(i) + secondString);
			}
	}
	string permute_append::do_it(const char* first, const char* second) {
	// set firstString and secondString then appends secondString to each permutation of firstString and stores each result in result_list
			firstString = first; secondString = second;
			do_it();
	}

	string permute_append::get(size_t position) { // get a result
	/*Get the item at position position from result_list */
			return result_list.get(position);
	}

}


and main function
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <string> // provides the string type (class)
#include <iostream> // provides cout, etc.
#include "linked_list.h" // provides linked_list
#include "permute_append.h" // provides permute_append
 
using namespace std;
using namespace CISP430_A5;
 
/*PERMUTE_APPEND STUB TEST*/
int main(void)
{
	permute_append tester;
	tester.do_it( first, second);
	cout << tester.get(4);
	return 0;
}
Topic archived. No new replies allowed.