0% found this document useful (0 votes)
4 views3 pages

Sheet 3

The document outlines a series of programming exercises for a Cyber Security program at Menoufia University, focusing on linked lists in C++. It includes tasks such as creating databases for students and products, performing various operations on linked lists, and implementing functions to manipulate and display linked list data. The exercises are designed for the 2nd semester of the academic year 2024/2025.
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 views3 pages

Sheet 3

The document outlines a series of programming exercises for a Cyber Security program at Menoufia University, focusing on linked lists in C++. It includes tasks such as creating databases for students and products, performing various operations on linked lists, and implementing functions to manipulate and display linked list data. The exercises are designed for the 2nd semester of the academic year 2024/2025.
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/ 3

Menoufia University Data Structures and Algorithms

Faculty of Electronic Engineering AC Year: 2024/2025


Cyber Security Program ‫جام عة الم نوف ية‬ 2nd Semester

Sheet [3]: Linked List

1. By using linked list, write a C++ program to create database


of students. Each student is defined by ID, name and
telephone. The program allows a user to input data of 20
students and then print data of the last 10 students on the
screen.

2. By using linked list, write a C++ program to create database


of products. Each product is defined by model, name and price.
The program allows a user to input data of 20 products and
print data of the first 10 products on the screen

3. Write a function called display to display the contents of all


nodes within the Linked List of problem 2.

4. Write a C++ program to first allow a user to input n integer


values into a linked list. Then, call other functions to perform
each of the following operations on the created list. Print the
result of each operation on the screen.
 A function to display the contents of all nodes.
 A function to find and return sum of the even values in the list.
 A function to count and return number of nodes containing values
divisible by 3 in the list.
 A function to find and return the largest value in the list.
 A function to move the node containing the largest value in the list
to the final node on that list.
 A function to free all the nodes in the list.

5. Write a function that moves the smallest item on a linked list pointed
by sptr to be the first node on the list.

1
6. Write a function called display() to display the contents of all nodes
within a Linked List pointed by sptr. Where, each node has a data
field containing float data.

7. Write a function called display() to display the contents of the first


10 nodes within a Linked List pointed by sptr. Where, each node has
a data field containing integer data

8. Write a function called add-node() to add node into a Linked List


pointed by sptr after the node that contains data equals 25.

9. Write a function called delete-node() to delete the node that has


data equals 30 from a Linked List pointed by sptr.

10. Write a function called add-node to add node into a Linked List
pointed by sptr after the 6th node.

11. Write a function called delete-node to delete the 3rd node from a
Linked List.

12. Write a code to perform each of the following operations.


 Append an element to the end of a list.
 Insert an element after the nth element of a list.
 Delete the last element from a list.
 Delete the nth element from a list.
 Delete every second element from a list.
 Free all the nodes in a list.
 Place the elements of a list in increasing order.
 Concatenate two lists.
 Combine two ordered lists into a single ordered list.
 Return the sum of the integers in a list,
 Return the number of elements in a list,
 Move node(p) forward n positions in a list,
 Make a second copy of a list.

13. Write a function that takes a link to a list as argument and returns a
link to a copy of the list (a new list that contains the same items, in
the same order).

2
14. Write a function to insert a node after the 5th node of a linked list
pointed by a start pointer called sptr.

15. Write a function to delete the 5th node from a linked list pointed by a
start pointer called sptr.

16. Write a function to count number of nodes containing values divisible


by 5 in a linked list pointed by a start pointer called sptr.

« With My Best Wishes »


Prof. Gamal M. ATTIYA

You might also like