Click here to Skip to main content
15,892,072 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
A small investment company stores data into a singly linked list. Each list element consists of:
Customer First name
Customer unique identifier
Investment type
Investment amount
Write the corresponding structure and Write the function that removes customer with bad investment (those with investment amount less than 0) from the list. The function returns the number of removed list members.
Posted
Updated 8-Mar-15 7:56am
v2

1 solution

In a linked list all item are linked, so if you delete one the linkage gets lost. So if you want to delete one, you need predecessor and the successor to successfully remove one element.

before deletion:
predecessor -> obsolet -> successor

after deletion:
predecessor -> successor

So if you scan to remove a element you need to replace the linkage. For that your code must have the predecessor and successor of a removed element.

The rest is "boiler plate" code. Check that the buffer size is big enough for all data. Use a class (or struct) for the costumer data. It must have a predecessor and successor pointer for the deletion.
 
Share this answer
 
Comments
Cheres_bk 8-Mar-15 15:35pm    
@KarstenK thank you.
i was looking for a code but thank you. this was really helpful

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900