0% found this document useful (0 votes)
9 views2 pages

TT2 - Linked Lists

DATA structure and algorithm, linked list data stucture

Uploaded by

phamtheminh2409
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views2 pages

TT2 - Linked Lists

DATA structure and algorithm, linked list data stucture

Uploaded by

phamtheminh2409
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Algorithms and data structures

LECTURE 56-LW2: Linked Lists

After each labwork session:

ˆ You will have one week (or 7 days) to complete the remaining exercises and
upload your files to the “Labwork X” assignment in Google Classroom.

ˆ Compress all code source files in a zip file and rename it as FULLNAME-ID-
Lab#no.zip (e.g NguyenVanA-BI10-070-Lab1.zip). Save your files according
to the exercise number i.e Ex1.cpp, Ex2.c, etc. Incorrect filenames will result
in no score for the respective exercises.

ˆ Only code source files (.c or .cpp) should be in the zip files. Other files (.exe,
.o) MUST be removed from the zip file.

ˆ - Copy/Paste from any source is not tolerated. Penalty will be applied for late
submissions.

NOTE: You must follow the guide. Incorrect zip file names, zip files containing
other files (.exe), and copy/paste lead to heavy penalties.

Exercise 1: Suppose that we use a List data structure to represent unbounded


integers.

ˆ the first element refers to the sign: 1 is positive and -1 is negative.

ˆ each element in the list represents one digit of these integers.

Implement and test the program in C/C++ using an Array-based List (Static or
Dynamic) to manage this unbounded integers:

ˆ add new digits at any place in an integer.

ˆ remove a digit at a specfic position in an integer.

ˆ calculate the sum of all digits from an unbounded integer.

ˆ display the whole number on the screen.

Exercise 2: Assume that a railway train has N railroad cars attached together
such as car1 , car2 , car3 , ..., carN . A train can be considered as a list and each car
corresponds to a node in this list.

1
ˆ Each car carries a maximum capacity of passengers (int type) and has an id
(char type). Both variables are user-defined values.

ˆ Each car is reserved by a number of passengers (int type) (which should be


less than its capacity). If there are any cars that don’t have any passengers,
they should be removed from the train.

ˆ It is possible to add new cars to the train.

ˆ A function is available to display all cars’ information or the length of the


train.

Implement a program in C/C++ using Linked List to manage the train and test all
functions.

You might also like