Week 9: Linked Lists Flashcards
Nodes for a linked list will be _____ dynamically created or deleted in the ______
Nodes for a linked list will be OBJECTS dynamically created or deleted in the HEAP
In SINGLY linked lists, nodes will contain:
Two member variables:
- Item value
- NODE* next
In node objects, data objects can be either
Simple or complex data structures
For singly linked lists. If you have a LIST structure, you should keep track of the _____ and ____
Head node and count
A createList() function should take in what parameter?
void
A createList() function has what return type?
LIST*
list pointer
A createList() function does what after dynamically creating the list?
Have an if statement checking whether or not the list was properly created
A createList() function should do what after creating the list and ensuring it was created?
Set head to NULL and count to 0
An insertList() function to insert a node to a list has what parameters
LIST* pointer to a list and a void* data item pointer
An insertList() function to insert a node to a list, what are the steps that must be taken?
- Create a NODE* pointer
- Assign the new NODE* pointer’s data pointer to the data item parameter
- Assign the new NODE* pointer’s next pointer to the list’s head
- Assign the LIST* head pointer to the new node
- Increment the list count
To search for an item in a linked list, you must begin the search at the ____ of the list
Head of the list
For a searchList() function, what are the parameters?
LIST* pointer and the value to be searched for
For a searchList() function, what is the variable created in the function?
A node pointer NODE* nP to traverse the list
For a searchList() function, what is used to traverse the list? What does it look like?
A for loop
for (NODE* nP = LIST->head; nP != NULL; nP = nP->next)
or
NODE* nP;
for (nP = LIST->head; nP != NULL; nP = nP->next)
For a searchList() function, what is within the for loop?
if (nP->dataPtr == value) return nP;