CIS-3050 Algorithms and Data Structures
Due: Wednesday, Oct. 6
This assignment is to extend your SList class.
- Add the following new methods:
insertNth(int n, const T data) // insert element into the
Nth position (zero based)
getNth(int n) // get the Nth element, where the list is
removeNth(int n) // remove (delete) the Nth element in the SList
insertLast(const T data) // insert element into the last
getLast() // get the last element
removeLast() // remove (delete) the last element in the SList
By Nth element, assume your list is 0 based -- so a request getNth(0)
would be the same as getFirst(). A request to getNth(size -
1) would be the same as getLast(). Likewise, insertNth(0, someData)
would be the same as insertFirst(someData).
HINT: Note that this means you really only have to write 3
functions for this assignment; the other three can be one line
functions that use the three you do have to write.
When in doubt, draw pictures, and figure out what your pointers have to
do for each situation.
To be turned
- Your new implementation of the SList class. This will
of SList.h and possibly SList.cpp
- A program (C++ main) that fully tests the new
sure to test all the public functions. This can just be an update
of your earlier test program.
- Within the comments of SList, be sure to mention the
runtime performance (Big-Oh notation) of each new function of SList.
- There is no need to resubmit your Node class, if it hasn't
changed from Assignment 2
- You may use whatever development environment/C++ compiler you
- Include your name and what environment/compiler you used in
README file that you submit
- All the files you create/modify should be placed in a zip file
and submitted via Blackboard. The assignment is due by midnight
on Monday, Sept. 20.
- All code should have reasonable comments/style. I'm not
enforcing a set style, but your code should be readable, and include
comments about anything that is nonobvious. For this first
assignment, I will assume that you know what this means, and provide
guidance for violators. I do reserve the right to take
deductions if your code is particular hard to read/undocumented, but my
goal is just to coach you in the right direction, unless the violation
is particularly major.
As needed, I can be reached via email, AIM or in my office on the 2nd
floor of the 700 building. See my schedule
for my official office hours. I also anticipate being
available during the afternoons until around 4p. If
you do need help,
including your source code files in any email to me can be helpful and
Good Luck and Good Coding!