hi....well this is my first post in this community...i hope people here will help me in my doubts...
I am an intermediate level programmer of c++...
i have a doubt regarding the permutations of a given string and permutations of first N natural numbers...
i have written a program for printing all the possible permutations of first N natural numbers..in the order of their indexes.....means if the user enters the index...the program will also tell him the i-th permutation....i havent used recursion...but when i searched here i saw the program for permuting a given string using recursion....i want to know whether the two problems are same or different...
And why the permutation problem is so important...that it is asked in interviews...kindly help me out...i can post my code and the algorithm i have followed for permutation of first n numbers...(if anybody want)

thanks & regards...
Rajat

i want to know whether the two problems are same or different

The problem is the same. Solutions are worked out in different manner.

Apart from this, I could not make out from your post what problem you are facing. Please mention if I've misunderstood something.

You said this:

i have a doubt regarding the permutations of a given string and permutations of first N natural numbers...

But afterwards, you didn't mention the doubt.

well u already answered one of my questions.....the other is that why is it to so important..

well i also want to tell u that the program which i have made works fine upto first 8 natural number's permutations...but when i try it for 9 or number greater than 9 then it takes lot of time to print all the permutations...factorial 9>300000....so i wonder whta's the best solution possible till now...what's the time complexity of the best solution using recursion or some other efficient method...

I don't know about the best solution. But you can improve the existing program by using long int instead of int and also changing the memory model to large or huge.

long int??? for what??? sorry i didnt get ur point..
i m using double to store the number of total permutation and an integer array[n] to store different permutations of n numbers...
And how will long int affect the running time of my program...

also changing the memory model to large or huge...
i m using Dev-C++..where does this model means??? how to change it??
help plz..

long int??? for what??? sorry i didnt get ur point..
i m using double to store the number of total permutation and an integer array[n] to store different permutations of n numbers...

Doubles are inexact. You can't have 2354.34 permutations. Therefore double is a bad choice.

And how will long int affect the running time of my program...

Floating point takes longer to compute. Granted in this program it may not make a noticeable difference...

also changing the memory model to large or huge...
i m using Dev-C++..where does this model means??? how to change it??

It doesn't. Jishnu obviously thinks you're using a very old compiler.

Yes, I thought so. Now, as he has specified, changing the memory model is inapplicable to this case.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.