Conestoga College - PROG 71985
removeElement() Breakdown
Assignment 4In this chapter, we will do a full breakdown on how to complete the removeElement function
//Exam Question 1: Complete the implementation for removing elements
int removeElement(struct listElement **targetList, int targetIndex){
//Recall from lecture - why do we need a double pointer for targetList?
//1. Remove Head Elements
//2. Remove Tail Elements
//3. Remove Middle Elements
//use addElement() implementations for reference
// YOUR IMPLEMENTATION HERE
return 0;
}🧠 Why do we need a double pointer for targetList?
We use a double pointer (struct listElement **targetList) because we might need to change where the head of the list points — especially when removing the first element.
If we used a single pointer, we’d only be modifying a copy of the head pointer. The original list in main() would stay the same. But with a double pointer, we can update the actual head pointer, and that change will be seen outside the function.
Members only
Keep reading this lesson
You've reached the end of the free preview. Unlock the rest of this lesson plus 3 more lessons in Conestoga College - PROG 71985.
- Unlimited coding questions
- Unlimited access to all classroom material
- Weekly live call for questions and guidance
- 3,000 AI tutor tokens / month
- Personal SQL database (3 MB)
- Progress tracking
Cancel any time.