Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views

Data Structures - CS301 Fall 2006 Assignment 01

Uploaded by

lltv tv
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Data Structures - CS301 Fall 2006 Assignment 01

Uploaded by

lltv tv
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Data Structures (CS301) Assignment No.

WWW.VUTUBE.EDU.PK
Assignment No. 1: Linked List
Subject: Data Structures Assigned: 11-10-2006 Assignment Marks: 15

Instructor: CS301 Team Due Date: 18-10-2006 Attached Files: Non


Objective:
This homework assignment is designed to give you practice working with linked lists and nested
loops.
Instructions:
1- This is an individual assignment. You will submit your work individually through your logins.
2- Write your name and roll number at the start of the assignment.
3- Do not copy and paste any thing from the internet. Your work must be original.
4- Please note that you must do your own work. If any one found copying from another
student, no marks will be given to him/ her.
5- Deadline for this assignment is 18 October, 2006. This deadline will not be extended.
6- No assignment will be accepted through email before and after the due date.
7- If you have any problems, feel free to mail at CS301@vu.edu.pk.
Problems
Your task is to extend the List class which is given in the example program in the handouts of
Lecture No. 03 by writing one method for removing successive duplicate items from lists, and one
method for adding them. The squish() method and twin() method will operate on singly-linked lists.

Here is the detail about these functions.

squish( )
The squish() method performs as described below.

squish() takes the list and, wherever two or more consecutive items are equal, it removes duplicate
nodes so that only one consecutive copy remains. Hence, no two consecutive items in this list are
equal upon completion of the procedure. After squish() executes, the list may well be shorter than
when squish() began. No extra items are added to make up for those removed.

For example, if the input list is [ 0 0 0 0 1 1 0 0 0 3 3 3 1 1 0 ], the output list is [ 0 1 0 3 1 0 ].

Here is the prototype of the squish() function that you will use in your code.

List squish(List list);

twin( )
The twin() method performs as described below.

twin() takes the list and doubles its length by replacing each node with two consecutive nodes
referencing the same item. For example, if the input list is [ 3 7 4 2 2 ], the output list is [ 3 3 7 7 4
4 2 2 2 2 ].

Here is the prototype of the twin() function that you will use in your code.

List twin(List list);

Note: Your Submission must include:

1. A working MakeFile (Dev-C++ project File).


2. All the Source Code(.h and .cpp files) necessary to compile and run your program.
3. Upload all the files on VULMS in a zip folder.

© Copy Right Virtual University of Pakistan 1


Data Structures (CS301) Assignment No. 1

Note: Use Dev-C++ 4.9.7.0 which is available at VULMS.

© Copy Right Virtual University of Pakistan 2

You might also like