Lab 10: Picture Dynamic Memory

Announcements:

  • Time to switch partners! Say goodbye and say hello. Move a significant distance from your old location, going in a different direction than your old lab partner, and find a new partner. Introduce yourselves, and say where you might like to live if it weren't in Chicago, and why.

  • For this lab you do not need to write code but rather will draw pictures to represent what declarations of data look like in memory. As a group you will do this drawing in a Google Slides document which will be provided for you. Once your group is done with your drawings raise your hand to let one of the TAs know and they will check and grade your work.

  • I suggest you explore ahead of time how to use the drawing tools within Google Slides to cut/copy/paste boxes, lines, arrows and text boxes.


Quiz:

The quiz will be available during the first 5 minutes of lab:

    • Your lab TA will tell you the password you will need to get into the quiz for your section.

    • You may use either one of the lab machines or your own laptop.

      • For the lab computers your account name and password are the same as your UIC NetID and password.

    • Please Click on Your Lab Time: 9am, 10am, 11am, 12pm, 1pm, 2pm, 3pm, 4pm, 5pm


Lab:

  • Each question is worth 1 point, for a maximum of 3.

  • Your lab's lead TA will tell you your group number, that will determine which slide to draw on. The group number assigned to each slide is given at the top of that slide. (Be careful. Since there is a title slide, the slide for group 1 to edit is actually on the second slide, and so on.) On the slide for your group first enter your group member names. Place your drawings adjacent to each declaration. Note that you can zoom in and out using Cntrl +/- (PC) or Cmd +/- (Mac).

  • Three completed examples (numbers 1-3) are shown below to give you an idea of what your diagrams should look like.

  • You should draw your solution on paper, for your TA to check in-person. (If you happen to be one of the students who is working remotely for Covid reasons, then use the appropriate document linked here, and email your TA to check it once you are done: 9am 10am 11am 12noon 1pm 2pm 3pm 4pm 5pm ).


Example A:

/* Lab 11: Picture This

Objective: Draw Pictures of Computer Memory

*/

#include<iostream>

using namespace std;

int main() {

// Sample A:

int numbers[5];

//------------- Place drawing below this line ------------------

Example B:

/* Lab 11: Picture This

Objective: Draw Pictures of Computer Memory

*/

#include<iostream>

using namespace std;

int main() {

char words[3][10];

//------------- Place drawing below this line ------------------

Example C

// Sample C:

int *pNumbers = new int[4];

//------------- Place drawing below this line ------------------

Example D

// Sample D:

int *pointerArray[3];

pointerArray[1] = new int;

//------------- Place drawing below this line ------------------

Lab Problems:

Problem #1

char **pWords;

pWords = new char*[3];

for( int i=0; i<3; i++) {

pWords[i] = new char[5];

}

//------------- Place drawing below this line ------------------

Problem #2

//Assume we have:

class Student{

public:

Student(){

initials[0] = 'D';

initials[1] = 'F';

initials[2] = 'R';

UIN = 12345;

}

private:

char initials[3]; // Delano Frank Roosevelt would be DFR

long UIN;

};

// Now draw the following:

Student cs141[3];

Student *pStudent = &cs141[2];

Student *pOther = pStudent;

//------------- Place drawing below this line ------------------

Problem #3

//Assume we have:

struct Node {

int data;

Node *pNext;

};

// Now draw the following:

Node n1;

n1.data = 3;

Node *pNode = new Node;

pNode->data = 5;

pNode->pNext = &n1;

pNode->pNext->pNext = pNode;

//------------- Place drawing below this line ------------------

return 0;

}

// Sample C:

int *pNumbers = new int[4];

//------------- Place drawing of pNumbers below this line ------------------