Hi guys i need help in algarithm code.
thanks

Remove All Occurrences
For this problem please start with the code provided in file list_reversal.cpp.
Add a new function to this code. The function should take two parameters: a list head and
an integer. The function should remove all elements of the list that contain that integer in
the “item” field.
Make sure that your function works correctly for all possible lists:
o empty list,
o list consisting of 1 element that needs to be removed
o this sample test data:
o list: 1 2 3 1 4 5 1. Elements holding 1 are being removed.
Note: Do not use IntList.cpp code for your solution. Specifically, don’t use deleteNode()
function multiple times, this approach is extremely inefficient. Your solution should
traverse the list only once.
i am tring to follow rhis step but kindda staring is hard
node * remove_all_occurrence (node * , int ); (1)


Characters of a String
Write a program that takes a string as argument, then prints out a table: for each character
that occurs in the string, the table contains the character and its frequency of occurrence.
Sample string: Alex A.
Output:
1
. 1
A 2
e 1
l 1
x 1

First, make an array of integer (1) initialized to 0 , which can hold 256 integers, and scanning a string, increase the value of index - the character code - the (1) array by 1.

Second, print each value and character if the value is not equal to 0 in traversing the (1) array.


Longest Sequence of Blanks
Write an efficient program that finds the length of the longest sequence of blanks in a
given string, examining as few characters in the string as possible.
Hint: Your program should become faster as the length of the sequence of blanks
increases.

Scan a string and find an occurrence of the head position and the last position of a sequence of blanks. Store the length and compare the largest length that may be store until now; if the length is bigger than the largest, update the largest with it.

Repeat the same procedure until you scan the last character in the string.

Recommended Answers

All 3 Replies

We can't help you as you have not provided file list_reversal.cpp.

You need to make an attempt and post here with a specific question when you get stumped. You've simply copied and pasted the assignment verbatim. That's going to get you no help. Give it a shot first and post a specific question.

I have some idea but it is not enough to star my project i need clue ..

For this problem please start with the code provided in file list_reversal.cpp.

I have some idea but it is not enough to star my project i need clue ..

Your instructor already told you where to start. Start by reviewing list_reversal.cpp, which presumably is complete and something that you understand. Since we have no idea what this file is, nor do we have any idea about what you already know, we have absolutely no way of helping you. You are going to have to write at least a paragraph explaining what you are having trouble with and what you already know, along with some code. Otherwise all we can do is point you to linked list tutorials.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.