Ask your own question, for FREE!
Computer Science 20 Online
OpenStudy (blackstreet23):

Could somebody help me understand this linklist project that my professor gave us as an example in c++. I just cannot understand most of the logic of the statements in it. http://www.filedropper.com/linklistproject

OpenStudy (blackstreet23):

I am totally lost with link list

OpenStudy (blackstreet23):

linked list*

OpenStudy (blackstreet23):

@Preetha

OpenStudy (blackstreet23):

@TheSmartOne

OpenStudy (blackstreet23):

@Zarkon

OpenStudy (rsmith6559):

A linked list is a list where each node contains a value and a pointer to the next node. If the pointer is null, that's the last node of the list. The first node of the list is called either the head or the root of the list. They're advantageous because nodes can be scattered all over memory and it doesn't matter. They stink because searching can only be done in a linear fashion, starting at the root. Your project has two header files (.h) and two C++ source files (.cpp). Header files declare the headers of classes, member functions (methods) and variables which can be defined in corresponding C++ files. In C++, when memory is dynamically allocated for struct(ure)s or classes, you address member functions or member variables with "->". In static memory, you'd use a period. The rest of it is just C++. If you have any more specific questions, feel free.

OpenStudy (mrhirohito):

@blackstreet23 Is this like a topic where you can talk about scripts,coding and what not?

OpenStudy (blackstreet23):

I am lost in the delete function void List::Delete(int data) { // Create a temp pointer Node *tmp = head; // No nodes if ( tmp == NULL ) return; // Last node of the list if ( tmp->Next() == NULL ) { delete tmp; head = NULL; } else { // Parse thru the nodes Node *prev; do { if ( tmp->Data() == data ) break; prev = tmp; tmp = tmp->Next(); } while ( tmp != NULL ); // Adjust the pointers prev->SetNext(tmp->Next()); // Delete the current node delete tmp; } }

OpenStudy (blackstreet23):

yes. I am trying to understand my professor's code for me to be able to write another program based on it. Also, i need to understand it to study for a test.

OpenStudy (blackstreet23):

@rsmith6559

OpenStudy (asnaseer):

Think of each element in a linked list as comprising of 2 cells as shown here: |dw:1457390649738:dw|

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!