Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 136,485 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 1,715 people online right now. Registration is fast and FREE... Join Now!




Pseudocode for an ADT

 
Reply to this topicStart new topic

Pseudocode for an ADT, REVERSE A LIST WITH A FUNCTION SWAP

rickyg
27 Jan, 2008 - 07:20 PM
Post #1

New D.I.C Head
*

Joined: 27 Jan, 2008
Posts: 6

Hi. Very new to the programming world. I have been asked to reverse a list with pseudocode. Using a function swap(), but with no need to define it, nor do I need to write the list, merely demonstrate an understanding by writing on paper a pseudocode which would reverse some implied list. I tried something like this, however, someone told me no good:

int main()
{
List.alist;
for(position = 1 through getLength())
swap(position(s), dataItem, success);
Display dataItem;
}

User is offlineProfile CardPM
+Quote Post

lockdown
RE: Pseudocode For An ADT
28 Jan, 2008 - 07:21 AM
Post #2

D.I.C Regular
Group Icon

Joined: 29 Sep, 2007
Posts: 376



Thanked: 1 times
Expert In: PC, Support

My Contributions
QUOTE(rickyg @ 27 Jan, 2008 - 08:20 PM) *

Hi. Very new to the programming world. I have been asked to reverse a list with pseudocode. Using a function swap(), but with no need to define it, nor do I need to write the list, merely demonstrate an understanding by writing on paper a pseudocode which would reverse some implied list. I tried something like this, however, someone told me no good:

int main()
{
List.alist;
for(position = 1 through getLength())
swap(position(s), dataItem, success);
Display dataItem;
}


What you have posted I not think most really consider pseudo code. Everyone has their own way of writing their pseudo code (some make it very technical other make it simple). I normally write it so its almost like basic and really has no functional code in it. You are on the right track but I would say to remove the function (int main) and just leave the rest of the code. You can break it down even more but I think without the function it should be ok. It just depends on whom ever you are doing this for thinks pseudo code should be.
User is offlineProfile CardPM
+Quote Post

baavgai
RE: Pseudocode For An ADT
28 Jan, 2008 - 07:52 AM
Post #3

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,031



Thanked: 105 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions
Swap which positions? Thats really the heart of the problem. Also, if you're swaping, you're moving two elements, so you should only need to swap for half the length of the list.

Hope this helps.

User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/2/08 07:20PM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month