User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Dec 2007
Posts: 109
Reputation: rajatC is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 7
rajatC's Avatar
rajatC rajatC is offline Offline
Junior Poster

Help permutations of STRING Vs First n natural numbers

  #1  
Dec 16th, 2007
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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Oct 2006
Location: India
Posts: 514
Reputation: Jishnu will become famous soon enough Jishnu will become famous soon enough 
Rep Power: 4
Solved Threads: 25
Jishnu's Avatar
Jishnu Jishnu is offline Offline
Posting Pro

Re: permutations of STRING Vs First n natural numbers

  #2  
Dec 16th, 2007
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.
Reply With Quote  
Join Date: Dec 2007
Posts: 109
Reputation: rajatC is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 7
rajatC's Avatar
rajatC rajatC is offline Offline
Junior Poster

Re: permutations of STRING Vs First n natural numbers

  #3  
Dec 16th, 2007
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...
Reply With Quote  
Join Date: Oct 2006
Location: India
Posts: 514
Reputation: Jishnu will become famous soon enough Jishnu will become famous soon enough 
Rep Power: 4
Solved Threads: 25
Jishnu's Avatar
Jishnu Jishnu is offline Offline
Posting Pro

Re: permutations of STRING Vs First n natural numbers

  #4  
Dec 16th, 2007
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.
Reply With Quote  
Join Date: Dec 2007
Posts: 109
Reputation: rajatC is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 7
rajatC's Avatar
rajatC rajatC is offline Offline
Junior Poster

Re: permutations of STRING Vs First n natural numbers

  #5  
Dec 16th, 2007
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..
Reply With Quote  
Join Date: May 2006
Posts: 2,723
Reputation: WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold 
Rep Power: 15
Solved Threads: 222
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Maven

Re: permutations of STRING Vs First n natural numbers

  #6  
Dec 16th, 2007
Originally Posted by rajatC View Post
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.

Originally Posted by rajatC View Post
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...

Originally Posted by rajatC View Post
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
Reply With Quote  
Join Date: Oct 2006
Location: India
Posts: 514
Reputation: Jishnu will become famous soon enough Jishnu will become famous soon enough 
Rep Power: 4
Solved Threads: 25
Jishnu's Avatar
Jishnu Jishnu is offline Offline
Posting Pro

Re: permutations of STRING Vs First n natural numbers

  #7  
Dec 21st, 2007
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.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the C++ Forum

All times are GMT -4. The time now is 3:57 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC