[Webinar] Streamline your web hosting managementRegister Today

x
• Status: Solved
• Priority: Medium
• Security: Public
• Views: 2370

# How to use pseudocodes in linked list?

pointsTail = new node;
strcpy(pointsTail->playerName, "COMPUTER");
pointsTail->playerPoint = 0;

How can I simply tell the above algorithm in Pseudocodes?
Thanks....
0
joely2k
1 Solution

Commented:
not sure what you mean but try this

pointsTail <-- allocate node
pointsTail.playerPoint <-- 0

as you my know different software dev firms may write there pseudocode different. There is no set standard for it.
Oh ya you should really write psuedocode first then write your code, it will be good practice for you when you get to the REAL job.
0

Commented:
There are several ways to do it in pseudocode, different formal templates, here is a formal one used everywhere:

Pre: none
Returns: 1 for insertion or 0 for failed insertion
- allocate memory for node
- store data in node

Algorithm insert_at_middle()
Pre: list must not be empty
Post: inserts a node sorted somewhere in the list
Returns: 1 for insertion or 0 for failed insertion
- allocate memory for node
- store data in node
- make previous pointer point to this new pointer and this new pointer to next to connect chain
End Algorithm insert_at_middle()

Algorithm insert_at_end()
Pre: list must not be empty and next available pointer is null/tail(end of list)
Post: returns 1 for insertion or 0 for failed insertion and creates a circular list
- allocate memory for node
- store data in node
- connect the the tail node to the head node
End Algorithm insert_at_end()

There that is the pseudocode for you code, I am assuming you are inserting at head, middle and end and creating a circular list with your last statement pointsTail->pointsHead.next.

Although your code is not functional, this is the pseudocode for that code.

Regards,

Robert Mezei
Programmer/Analyst
0

Commented:
joely2k: