•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 423,856 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,858 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 862 | Replies: 6 | Solved
![]() |
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 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.
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
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...
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.
Last edited by Jishnu : Dec 16th, 2007 at 10:24 am.
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
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..
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...
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.
Age is unimportant -- except in cheese
Yes, I thought so. Now, as he has specified, changing the memory model is inapplicable to this case.
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
![]() |
•
•
•
•
•
•
•
•
DaniWeb C++ Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Other Threads in the C++ Forum
- Previous Thread: c++ reading text file
- Next Thread: Diff b/w object and instance?



Linear Mode