Computer Science Canada re: permutations in C language,,not C++, a subset of the C++ |
Author: | boredstudent3 [ Sun Nov 14, 2004 11:41 pm ] |
Post subject: | re: permutations in C language,,not C++, a subset of the C++ |
hello folks...i need to determine the different combinations when given a set of numbers and order does matter so essentially what i need to do is find all the sets,,don't know if that makes sense or not but i know when doing permutations by hand u can obviously write out all the different combinations but how can u do such a thing in C?...like i'm pretty sure that i'll have to use a loop to iterate through all the permutations and possibly an if statement to check for repetitions but how do i actuallly go about attaining the combinations? thanks for your time boredstudent3- |
Author: | wtd [ Mon Nov 15, 2004 1:00 am ] |
Post subject: | |
http://mathforum.org/dr.math/faq/faq.comb.perm.html |
Author: | boredstudent3 [ Wed Nov 17, 2004 11:40 am ] |
Post subject: | |
hmmm,,thanks for your reply wtd but i don't need to find the number of possible permutations,,instead say if i was given the set of numbers {1,2,3} i need to write a prgm to get the combinations such as: 123 132 213 231 321 312 ...how do i go about getting these sets?...=p...argh,prgm'ing is not my cup of tea...bleh,,=) |
Author: | md [ Wed Nov 17, 2004 4:27 pm ] | ||
Post subject: | |||
one way is to recursively build the permutaions for example using characters...
generates: 123 132 213 231 312 321 ** if this is for an assigment then you'd better not submit this... |
Author: | bugzpodder [ Wed Nov 17, 2004 5:09 pm ] |
Post subject: | |
search for SEPA algorithm |
Author: | boredstudent3 [ Sat Nov 20, 2004 12:27 am ] |
Post subject: | |
-wow,,thanks alot for the ideas corkflake,,i appreciate it pal -no,,even though this is for an assignment i won't submit the code which u have posted b/c plagiarism has a very hefty price in uni,,heh... -hey bugz why is the relevence of searching SEPA?...is this an acroynm?...=),,nm bugz...SEPA = simple efficient permutation algorithm...hehe,,awesome tip man...thanks alot!!! |
Author: | bugzpodder [ Sat Nov 20, 2004 12:31 am ] |
Post subject: | |
fine, dont search for SEPA algorithm which is an algorithm to generate all permutations effeciently in O(1) time (per permutation) without overhead of recursion or excessive data structures |
Author: | boredstudent3 [ Sat Nov 20, 2004 3:56 pm ] |
Post subject: | |
wait, lemme get this straight,, bugz is SEPA "code" that alot of programmers use?,,cuz i'm doing this for an assignment and if isn't sth which is common to programmers then i don't think i should use it cuz it could constitute as plagerism correct?...=( |
Author: | bugzpodder [ Sat Nov 20, 2004 4:05 pm ] |
Post subject: | |
you think you can just take the code and claim it as yours without referencing it? OF COURSE NOT. you reference where you got the code from if you didnt come up with it. |
Author: | wtd [ Sat Nov 20, 2004 7:28 pm ] |
Post subject: | |
While you should still give credit where it's due, implementing an algorithm is not the same as copying and pasting code.[/u] |
Author: | bugzpodder [ Sat Nov 20, 2004 9:05 pm ] |
Post subject: | |
if you notice, it is SEPA "code", not SEPA algorithm, as I believe all the resources in google gives you the algorithm in C code rather than pseudocode. And taking other's code and change the variable names does not make it your own code, it is still plagiarism |
Author: | wtd [ Sat Nov 20, 2004 9:46 pm ] |
Post subject: | |
bugzpodder wrote: if you notice, it is SEPA "code", not SEPA algorithm, as I believe all the resources in google gives you the algorithm in C code rather than pseudocode. And taking other's code and change the variable names does not make it your own code, it is still plagiarism
Honestly, in this case I think it would be sufficient to credit the author with the algorithm. Especially when one is shooting for efficiency and speed, there just aren't that many ways to write this one, especially in C. |
Author: | boredstudent3 [ Sun Nov 21, 2004 1:07 am ] |
Post subject: | |
well thanks alot guys for your posts,, in the end i managed to write the code myself using a different method and this is just an introductory programming course which i have to take so the instructor is not looking for efficiency (length of code, amount of memory i use, number of vars, etc). bored- |