Click to See Complete Forum and Search --> : CCAE RFC -what about a pseudocode section?
Okay, so technically this isn't really an official "RFC", but nonetheless, I'd like some input.
Ndogg made the suggestion that we have a section for pseudocode, and we're trying to decide if we should go with it or not... there's a bit of dispute over the value of pseudocode and whether a pseudocode section is worthwhile, so we figured we'd get some input from the LNO programming community.
What do you think about pseudocode? Would having a pseudocode section be helpful? or would people be better served by just having well (and clearly) commented code?
Feel free to expound upon your beliefs with regards to this subject. Don't be afraid to say what you feel with honesty and passion, because we'll probably ignore you anyway. :) Everything usually comes down to an armwrestling match between TLD and I anyway. :) Seriously, we'd really like some input.
EyesWideOpen
05-17-2001, 11:19 AM
Personally speaking I've never written pseudocode outside of school and probably never will again. It's funny you should mention this because I was just pondering the idea of writing pseudocode for a project I'm working on but I decided against it.
I find it's always suited me just fine to dive write into writing code and let the flow develop as I go along. Now that's not to say that I wouldn't be better off had I written out a design flow before hand but my current technique works so I'll stick with it (if it aint' broke then don't fix it.)
So to answer your question, from my POV, I probably wouldn't spend too much time looking at the pseudocode section. But that's just me... ;)
jcrowe
05-17-2001, 11:25 AM
I think that a psuedo code section would be cool. It would give people to opportunity to practice using different languages for the same program. For those of use who want to learn a language it would be a good tool.
klamath
05-17-2001, 12:37 PM
Personally, I'd have no value for a pseudocode section -- but maybe others would...
Stuka
05-17-2001, 01:03 PM
My $.02 -
While I think pseudocode is a useful technique for beginning programmers and sketching out more complex code sections, I don't think it really fits in with (my opinion of) the purpose of the site. The CCAE, I think, is really for those who understand the basic ideology of programming, but would like to view sample code from a new language, using a particular language feature, or perhaps in a problem domain (networking, etc.) with which they aren't familiar. These people should be capable of writing any pseudocode they feel necessary. Now, if you ask me, an algorithm section would be really cool, and maybe a bit on design patterns, but I don't think a pseudo-code section would be of much use.
jemfinch
05-17-2001, 01:39 PM
I suggest just making the "pseudocode" link be the same directory as the "python" link, since they look so similar :D
Jeremy
lol, jemfinch, good point. :)
Stuka - Good point; I think that's what I like most about the idea. How would the 'algorithms' section work, though? Would it be in pseudocode? any language?, python? :). That would be helpful... and the design patterns thing would be cool, too...
sans-hubris
05-17-2001, 05:50 PM
The following is the pseudocode to a merge sort (due to the limitations of ascii, certain things will be represented with C notation, like subscripts will be represented by [], and greater than or equal to will be >=, and := is an assignment, while = is a test):
Procedure Merge sort (a[1], a[2], a[3],..., a[n] : distinct integers where n is the number of elements in the list)
middle:=ceil(n/2)
if n>=1 then
begin
L[1]:=(a[1], a[2], a[3], ..., a[middle])
L[2]:=(a[middle+1], a[middle+2], ..., a[n]
L[1]:=Merge sort( L[1] )
L[2]:=Merge sort( L[2] )
L:=List merge( L[1], L[2] )
end
else
L:=a[1] {when n=1}
{returns the sorted list L}
Procedure List merge( L[1], L[2] :lists of distinct integers in increasing order, which have no numbers in common)
L:= the empty list
while L[1] and L[2] are both nonempty
Compare the first elements of both L[1] and L[2]
Append the lowest of the two numbers into list L
Delete that number from the appropriate list
if removing this smallest element makes one list empty then remove all numbers from the other list and append them to L
end
{returns the merged list L. The numbers in L are in increasing order.}
and here's the corresponding C++ code (I'm not error checking this, BTW):
int* mergeSort(int a[], int n) {
int middle=ceil(n/2);
int* L[2], returnL;
L[0]=new int[middle];
L[1]=new int[middle];
if(n>=1) {
for(int i=0; i<middle; i++)
L[0][i]=a[i];
for(int i=middle; i<n; i++)
L[1][i-middle]=a[i];
L[0]=mergeSort(L[0], middle);
L[1]=mergeSort(L[1], middle);
returnL=listMerge(L[0], L[1], middle);
} else returnL=new int(a[0]);
return returnL;
}
int* listMerge(int L1[], int L2[], int size) {
int *L=new int[2*size];
for(int i=0, i1=0, i2=0; i<2*size; i++) {
if((i1<size)&&((i2>=size)||(L1[i1]<=L2[i2]))
L[i]=L1[i1++];
else if (i2<size)
L[i]=L2[i2++];
}
return L;
}
The pseudocode for binary conversion is easier to understand though (** is the fortran exponentiation operater, where x**y is x to the yth power):
Procedure conversion(a[1]a[2]a[3]...a[n] a bit string of length n (each a[i] is either 0 or 1))
beta:=0
i:=n
while i>=1 do
begin
beta:=beta+2**(n-i) * a[i]
i:=i-1;
end
{return beta}
These pseudocode examples are pretty easy to understand and easily ported to other languages because they're so general. During some of my Discrete Math ("Math for Computer Science") tests, instead of trying to figure out the result of some procedure, I would program it into my calculator. This is what I was talking about when I mentioned to kmj to add a pseudocode section. Very generalized description of some method that almost looks like code, but isn't. Actually, the merge sort example is prolly a bad example, but its still low level enough to pass. It could prolly be thought out a little further, but I just took that almost straight from one of the informative packets we got in class.
Strike
05-17-2001, 06:59 PM
I still disagree and think a pseudocode section would be more trouble than it's worth. If I want to know the method of doing something, I look for tutorials and not code examples (well, I look for the latter AFTER reading the tutorials and understanding the subject). I'm not saying it's not a worthwhile endeavour, not at all. I'm just saying that it doesn't really fit within the scope of CEO ( :))