Quiz 3 - Pointers and Linked Lists Answer Key PDF
Document Details
Uploaded by ReplaceableMossAgate9281
Kutztown University of Pennsylvania
Professor Wolfe
Tags
Summary
This document contains questions and answers related to pointers and linked lists, commonly covered in introductory computer science courses focusing on programming concepts.
Full Transcript
Name: _Professor Wolfe____________ Quiz 3 - Pointers and Linked Lists 1. Consider the following block of code: int workingNumber = 10; int* simplePointer = &workingNumber; int** pointerPointer = &simplePointer; a. Create a pointe...
Name: _Professor Wolfe____________ Quiz 3 - Pointers and Linked Lists 1. Consider the following block of code: int workingNumber = 10; int* simplePointer = &workingNumber; int** pointerPointer = &simplePointer; a. Create a pointer called myPointer and make it point to workingNumber via simplePointer (i.e. do not write “workingNumber” in your code) int* myPointer = simplePointer; b. What variable would (*pointerPointer)++ increment? By how much? It would increment simplePointer by 4 bytes (i.e. sizeof(int)). c. What variable would (**pointerPointer)++ increment? By how much? It would increment workingNumber by 1. 2. What is a difference in how an array is stored in memory vs. a linked list? An array is always stored in consecutive memory locations, usually on the stack. A linked list can be stored across distant memory locations, always on the heap. 3. For int* ptr = NULL, what would cout operator: cout data); cout