Home › Forums › C Programming › Linked Lists
- This topic has 1 reply, 2 voices, and was last updated 17 years, 1 month ago by
Humayan.
Viewing 1 reply thread
- AuthorPosts
- March 23, 2008 at 2:09 pm #2083
shell
Participant123456789101112131415161718192021<br />for(currentNum = low; currentNum <= high; currentNum++){<br />for(index = 0; index <= 255; index++ ){<br />if(freq[index]==currentNum && size == 0){<br />TreeNode* node = new TreeNode(index, freq[index]);<br />front = new List(node);<br />current = front;<br />size++ ;<br />}<br />else{<br />if(freq[index]==currentNum){<br />TreeNode* node = new TreeNode(index, freq[index]);<br />cout << node->getChar() << node->getFreq() << "n";<br />current->Next = new List(node);<br />current = current->Next;<br />}<br />}<br />}<br />}<br />return front;<br />}Ive been trying to construct a linked list as shown above, for some reason it only adds nodes till like the fourth node and after that stops adding, Ive debugged and see that it gets down to actually creating the node but for some reason it doesnt add to the List , help would be appreciated.
- March 24, 2008 at 4:11 pm #3369
Humayan
ParticipantThe algorithm for building the list from front to back looks correct ( I assume the constructor for List sets the Next pointer to NULL ). I would guess the problem to be in the test:
12<br />if(freq[index]==currentNum)since the rest looks ok…….
- AuthorPosts
Viewing 1 reply thread
- The forum ‘C Programming’ is closed to new topics and replies.