Homework 1: fsu::List Solution

$35.00 $29.05

You'll get a: . zip file solution, download link after Payment


Educational Objectives: After completing this assignment, the student should be able to accomplish the following:

Use linked structures to implement a dynamically sized data structure

lu5456eej04 tmp 28354739eb944612

Test dynamic data structures for functionality

lu5456eej04 tmp 28354739eb944612

Test dynamic data structures for resource leaks

lu5456eej04 tmp 28354739eb944612

Implement the ADT List using linked structures

lu5456eej04 tmp 28354739eb944612

Explain the use of single and double links and the advantages of each in an implementation Define and implement iterators for a data structure

lu5456eej04 tmp 28354739eb944612 lu5456eej04 tmp 28354739eb944612

Operational Objectives: Supply source code implementing the template classes List<T> and ListIterator<T>. Code should be thoroughly tested for functional correctness, robustness, and memory management. The supplied code should function correctly and be free of memory leaks, and your tests should provide evidence of both. This evidence should be summarized in a test report.

Deliverables: Three files: list.cpp, name.com, log.txt

List API

List Implementation Plan

Procedural Requirements

  1. Begin with understanding the chapters on Lists and Deques and a working knowledge of the techniques involved in creating linked structures dynamically.

  1. The official development/testing/assessment environment is the environment on the linprog machines.

  1. Make sure you understand the implementation plan for List<T> described above.

  1. Work within your subdirectory called cop4530/hw1. Keep in mind that with all assignments it is a violation of course policy and the FSU Honor Code to give or receive help on assignments from anyone other than the course instruction staff or to copy code from any source other than those explicitly distributed in the course library.

  1. Copy the following files from the course LIB into your hw1 directory:







  1. Create three more files:

    1. a source code file list.cpp implementing the template classes fsu::List<T>, fsu::ListIterator<T>, and fsu::ConstListIterator<T> that are defined in tcpp/list.h. There are only a few missing implementations.

    1. a text file name.com that is a command file for flist.cpp [ElementType = char] such that:

      1. The characters of your first name are inserted into x1 in alphabetical order, with the first letter capitalized

      2. The characters of your last name are inserted into x2 in alphabetical order, with the first letter capitalized

      3. Finishing with the commands to accomplish x3 = x1; x3 += x2; x3.Display(cout) results in printing your name to screen.

      1. Note character insert order is alphabetical, and traversal order spells your name.

For example, the file name.com depicted here:


# name.com

file:///C|/Users/Desktop/Documents/FSU/COP%204530/hw1/Homework%201%20fsuListT.htm[4/13/2012 9:44:32 AM]

Homework 1: fsu::List<T>


# input order: Chirs acehLr

# traversal order: Chris Lacher























results in “ChrisLacher” to screen.

    1. a text file log.txt consisting of a log of all development activity, including documentation for all testing. All three files should be placed in the hw1 directory.

  1. Keep detailed notes on procedures and results as you test your implementation list.cpp. Use these testing notes to create a report in the file log.txt.

  1. Turn in the files list.cpp, name.com, and log.txt using the script hw1submit.sh.

Warning: Submit scripts do not work on the program and linprog servers. Use shell.cs.fsu.edu to submit this assignment. If you do not receive the second confirmation with the contents of your project, there has been a malfunction.

Technical Requirements and Specifications

  1. Your file list.cpp is a “slave” file to list.h. (See the chapter on Vectors for an explanation of “slave” file.)

  1. Your implementation should follow the plan detailed above.

  1. Much of the implementation is given in the file list.cpp.partial. You supply the missing implementations.

  1. Your implementation of List<T>, ConstListIterator<T>, and ListIterator<T> should be tested for both functionality and memory containment using at least the classes T = char and T = fsu::String. Two test programs, clients of fsu::List<T>, are supplied. Specific instructions for testing for memory leaks are included as comment at the top of the file mlist.cpp. DO NOT TEST FOR MEMORY LEAKS WITHOUT FOLLOWING THESE INSTRUCTIONS.

  1. Document all testing in your log.txt, which will be collected by the submit script.


The following files are used directly from the course library:

lu5456eej04 tmp 28354739eb944612



defines fsu::List<T> and list iterator classes


// the fsu::xran

family of random object generators



… these are

used by mlist.cpp



The file tcpp/list.h is in the course library. Note that the file list.cpp is included into this file near the bottom but inside the namespace fsu. Therefore the code in list.cpp is automatically in the correct namespace.

lu5456eej04 tmp 28354739eb944612

file:///C|/Users/Desktop/Documents/FSU/COP%204530/hw1/Homework%201%20fsuListT.htm[4/13/2012 9:44:32 AM]

Homework 1: fsu::List<T>

The file flist.cpp contains a typical “functionality” test program. The idea is to provide access to the entire public interface of class List<> and ListIterator<> so that you can perform operations on three distinct List objects and associated iterators. It is up to you to use this test program effectively.

The file mlist.cpp contains a dynamic test for correct memory and pointer management in the implementation of List<> and ListIterator<> . In contrast to the functionality test, this one runs without user input. It sets up three List<> objects and associated iterators, much as is done in flist , but the operations are called randomly in a loop that runs until Ctrl-C is entered or until the program crashes. This is a very dangerous program that will crash the entire server on which it runs if a defective implementation of List is tested without careful containment of the runspace for the program. Therefore it is imperative that the precautions delineated in the documentation be followed.

lu5456eej04 tmp 28354739eb944612

The file fcqueue.cpp contains a functionality test for the CQueue<> adaptor class. Run this test using List as a basis for ADT queue to be sure that your List implements queue correctly.

lu5456eej04 tmp 28354739eb944612

A makefile for your project that compiles separate executables for the client programs is supplied. You can compile the two supplied test programs using this makefile by entering the command “make all“. You can compile individual test programs or any other target in the makefile by entering “make xxx ” where “xxx” is the target. For example, “make flist.x” creates the executable for flist.cpp and “make mlist.o” creates the object code for mlist.cpp.

lu5456eej04 tmp 28354739eb944612

Be sure to follow the recommendations in Notes Chapter 1 on incremental implementation of complex classes. In particular: create the file list.cpp with all method headers and minimalist non-functional bodies (empty or returning a simple value of the appropriate type). This should result in no compile or link errors. Then proceed to implement the methods one at a time. Test the methods as you build them. Think about, understand, plan, and design each method before proceeding to its implementation.

lu5456eej04 tmp 28354739eb944612

Sample executables for flist and mlist are available in LIB/area51.

lu5456eej04 tmp 28354739eb944612

file:///C|/Users/Desktop/Documents/FSU/COP%204530/hw1/Homework%201%20fsuListT.htm[4/13/2012 9:44:32 AM]