User Tools

Site Tools


Sidebar

projects

haas:spring2014:data:projects:sll

Corning Community College

CSCS2320 Data Structures

~~TOC~~

Project: SLL (Singly Linked List)

Objective

To implement base singly linked list functionality (insert, append, getNode) and explore the processing of data through utilization of a linked listTake the Singly Linked List code we worked on in class, and extend it as follows:

Function

Utilizing the same basic node structure we created and experimented with, create the following functions (in accordance with function prototypes given) to perform the requested functionality on our list:

  • Node *append(Node *start, Node *given, Node *newNode); - passing the appropriate values, append a new node after a given node on a list.
  • Node *insert(Node *start, Node *given, Node *newNode); - passing the appropriate values, insert a new node before a given node on a list.
  • Node *getNode(Node *start, Node **indicated); - passing the appropriate values, remove indicated node from a list but do NOT deallocate it.

Some other implementation criteria:

  • No I/O is to be performed IN these functions. Obtain all necessary input and provide output OUTSIDE of these functions (such as in main()).
  • These operations can take place on any node, and at any valid position in the list.

Implementation

Your task for this project will be to implement the above functions, working with our previously established node structure, to create singly linked lists.

For this project, you will be focusing on the implementation of those functions, and providing some means of demonstrating their efficacy:

  • in your main(), assemble a linked list USING these functions
  • perform manipulations to your list using these functions
  • output various states of the list to demonstrate correct implementation of list functions

Evaluation

Points I will look to evaluate:

  • Does it compile clean?
  • Does it run (any combination of actions) without error or problem?
  • Does it have and use functions for the various linked list operations?
  • Does the testing code adequately demonstrate all the functions?
  • When displayed, are all list contents/attributes correct?

Looking ahead

While I am not requiring such for THIS project, these will soon become requirements (perhaps as soon as next week), so you may want to start considering and being mindful of them:

  • modularity: putting core functionality in functions
  • multi-file: each function in its own file (insert.c, append.c, get node.c, main.c, etc.)
  • use of a custom header file that all project files include
  • use of a Makefile to automate building
  • creation of a library to link against projects created using our functions
  • user-operated menu allowing interactive manipulation of a list
  • additional list functions:
    • Node *mknode(int value); - allocate a new node, initialize to passed value, return a pointer to it
    • Node *cpnode(Node *given); - allocate a new node, and duplicate its contents to match that of given node; return pointer to new node
    • Node *rmnode(Node *given); - deallocate node, set to NULL, return updated pointer
    • void display(Node *start); - passing a list, display the nodes in the list (note that this function performs I/O in the form of output)
    • Node *seeker(int pos); - pass the node number you'd like to seek to (remember in a singly linked list you may want it to be behind by one.
    • Node *mklist(); - create new linked list, returning a pointer to its start (use existing functions as part of implementation). This function will perform I/O to obtain information from the user
    • Node *cplist(Node *start); - duplicate (allocate and copy) a list, return a pointer to start of new list
    • Node *rmlist(Node *start); - deallocate each node in the list
    • Node *sortlist(Node *start); - passing the appropriate values, sort the list from least to greatest.
    • int listQty(Node *start); - return a count of the number of nodes in a list
    • Node *searchlist(Node *start, int value); - search from start of indicated list for value, returning pointer to first matching node (or NULL if not found).
    • int getpos(Node *start, Node *given); - locate the position of given node from the start (0 position) of a list, return the numeric position
haas/spring2014/data/projects/sll.txt · Last modified: 2014/02/20 16:49 by wedge