0% found this document useful (0 votes)
4 views

TP05-Linked list

The document outlines an assignment for a Data Structure and Programming II course focused on creating a linked list in C++. It includes objectives, tasks such as defining structures for student data, implementing functions to manage the linked list, and writing a program to store numbers until a specific condition is met. Students are required to submit a PDF report and source code to Moodle by a specified deadline.

Uploaded by

Da Vy
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)
4 views

TP05-Linked list

The document outlines an assignment for a Data Structure and Programming II course focused on creating a linked list in C++. It includes objectives, tasks such as defining structures for student data, implementing functions to manage the linked list, and writing a program to store numbers until a specific condition is met. Students are required to submit a PDF report and source code to Moodle by a specified deadline.

Uploaded by

Da Vy
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

Data structure & programming II

Data structure and Programming II


TP05: Linked list

➢ Objective: Deadline:
• To practice create linked list advanced data structure that is able to store
6 days
unlimited data
• Apply C++ programming
➢ Individual work
➢ Submit to Moodle (do not zip)
• A pdf report (cover, exercise and solution with screenshot)
• Source codes

Write C++ programs to create and implement linked list data structure below.

1. Given a list below. Describe what does it store. Let’s create structures that can hold all of those data.

An example
Another detail example

Remark: Do not write the full implementation of linked list. You are just asked to define two structures
such as the element structure and the list structure.

2. Define a data structure that can store unlimited data of ITC students. Each student has ID, name,
year and program degree. Let’s create an element for student then a list that contains head, tail and
pointer.

struct …………….. { struct ListStudent {


…. ….
…. ….
…. ….
}; };
3. In addition to Exercise #1, create 2 functions such as: create an empty list, and add student to list.
After that, in the main program, call to these functions and add 5 students of your classmate that
you like the most.

ListStudent *createEmptyList { void add(Student s, ListStudent LS {


…. ….
…. ….
…. ….
}; };

4. Create a function to display all data in the list that implemented in the exercises 2 and 3 above. Test
your program in main. Finally, add 2 more students to the list. Display all data.

5. Write a program that can store numbers as many as possible using linked list data structure. The
program ask user for a number at a time then add to the list. Keep asking the user for another
number and add to the list if the input number is not 0.
a. When the user inputs 0 twice, display all data in the list and stop the program.
b. Finally, compute the summation of all data in the list and show the result.

*** A program to store number as many as possible: ***


Enter a number: 10
Enter a number: 95
Enter a number: -5
Enter a number: 25
Enter a number: 1
Enter a number: 0
You have entered the number 0 once. Only 1 more left. We will quit the program.
Enter a number: 4
Enter a number: 9
Enter a number: 75
Enter a number: 0
You have entered the number 0 twice so far. The program is going to stop now.

All data in the list are: 10 95 -5 25 1 4 9 75.


Summation of all numbers is: 214

All data in the list of: 10 95 -5 25 1 0

You might also like