Hi, can anyone please take a look at these algorithms. Are they correct? Are they going to work?
Algorithm for the linked list implementation of the following for simple lists.
fanction takes ponter of the beginning of the list (Node *list)
while( list != NULL )
go through the list by making pointer point to the next node and delete nodes
one by one with free( );
True if no more items can be dequeued and there is no front item.
Boolean function takes a pointer to the list and returns true if empty
and false if not
if (list==0) function returns true
if not then fanction returns false
True if no more items can be enqueued.
Boolean fanction takes a pointer to the list and returns true if full
and false if not
if(list!=0) function returns true
otherwise fanction returns false
Function takes pointer of the beginning og the list and
returns the number of nodes in the list.
Declare and initialize integer count=0.
go throught the list and count nodes. / count++;
Algorithm for the array implementation of the following for simple lists.
Function takes pointer to the list.
Check if list is empty, if empty despaly the message.
Use finite loop (where i initialized to end of the list, go down through
the list in the array untill
i not equal -1)
True if no more items can be removed .
Boolean Function takes a pointer to the list.
if list->count==-1 then function returns 0; else returns true.
True if no more items can be added.
Boolean fanction takes a pointer to the list.
if list->count=(MAXSIZE-1) then function returns true, othervise
Takes pointer to the beginning of the list.
Returns number of entries in the list.
Integer count declared and initialized to 0.
using finit loop traverse through the list untill not equal (MAXSIZE-1)
and count nodes.
Agorithms to append and serve nodes for this structure.
appened: The new node will be placed just after the tail node
(between the tail and the first node)
Allocate a space for the new node
Assign data to new node pNew->data=data; pNew->data=pNew;
if tail is equal NULL, new node becomes tail ,
otherwise make pNew->next and pTail-> point to the same
location. Make tail next point to new node. New node becomes tail.
serve: The last node will be deleted from the list
Allocate space for temp node.
Assigned tail->next to temp;
make tail next and temp next pointer to point to the allocated space.
delete temp using free();