Intro to Programming Languages

LecLabs 2.6/7 - Advanced Memory

[ ← Module List ]

These labs cover an introduction to advanced memory management in C++. Including double pointers, pass-by-address, array lists, and linked lists.

15 challenges

Challenges

CHALLENGE 01

Lecture 2.6.1. Double Ptr Local

— solves

Lecture video on Double Ptr Local

CHALLENGE 02

Lecture 2.6.1.1. Double Ptr Heap

— solves

Lecture video on Double Ptr Heap

CHALLENGE 03

Lecture 2.6.1.2. Triple Ptr Local

— solves

Lecture video on Triple Ptr Local

CHALLENGE 04

Lecture 2.6.2.2. Pass-By-Address

— solves

Lecture video on Pass-By-Address

CHALLENGE 05

EzLab 2.6.2.2 Pass By Address

— solves

Follow the CODE instructions to create a function that takes a pointer to an integer and modifies the value it points to.

CHALLENGE 06

Lecture 2.6.2.3. PBA - Double Ptrs

— solves

Lecture video on PBA - Double Ptrs

CHALLENGE 07

Lecture 2.7.1.2. Array lists

— solves

Lecture video on Array lists

CHALLENGE 08

Lecture 2.7.1.3. Array lists insert and remove

— solves

Lecture video on Array lists insert and remove

CHALLENGE 09

Lecture 2.7.2.0 Linked List

— solves

Lecture video on Linked List

CHALLENGE 10

Lecture 2.7.2.1. Linked List Insert at End

— solves

Lecture video on Linked List Insert at End

CHALLENGE 11

Lecture 2.7.2.2. Linked List Insert at

— solves

Lecture video on Linked List Insert at

CHALLENGE 12

Lecture 2.7.2.3. Linked List Remove

— solves

Lecture video on Linked List Remove

CHALLENGE 13

Lecture 2.7.2.4. Array list v. Linked List

— solves

Lecture video on Array list v. Linked List

CHALLENGE 14

Lab 2.7.2.4a - Linked List Songs

— solves

Objective

In this lab, we will create a new version of the song list that uses Objects and linked list data structure.

CTRL-Click Here for Follow Along Video

Requirements

  1. Update songnode.h
    • Define a default constructor and a parameterized constructor that takes in genre, artist, title
    • Add pointers for next and previous
    • Add accessors and mutators for the next and prev
  2. Update songlist.h: add pointers to head and tail of the linked list
  3. Update songlist.cpp
    • Ignore the moveDisplayForward and movedisplayBackwards they are for Lab 8.2
    • Define addSong, including code to create a SongNode and insert it into the linked list at the end
    • Define createFromFile use ifstream and getline() to read in songs and build up a linked list.
    • Define print(), which will print the first 10 nodes from the linked list.

Steps to Complete

  • Implement the requirements
  • Compile and test the program
  • Run /challenge/tester
  • Get flag
CHALLENGE 15

Lab 2.7.2.4b - LL Paging

— solves

Objective

In this lab, we will enhance the Linked List of Songs to page the results.

CTRL-Click Here for Follow Along Video

Requirements

  1. Update songlist.h: add pointers first_node_to_display and last_node_displayed
  2. Update songlist.cpp
    • Define moveDisplayForward, use last_item_displayed
    • Define moveDisplayBackwards, count backwards from first_node_to_display
    • Update print to keep track of first_node_to_display and last_item_displayed
  3. Update main.cpp
    • Wrap call to sll.print() in a while loop that exits with 'q' is entered
    • Below print prompt "(n for next, p for previous, q to quit): "
    • Get the input, don't forget to use cin.ignore() to clear the buffer
    • input of 'n' calls moveDisplayForward
    • input of 'p' calls movedisplayBackwards

Steps to Complete

  • Implement the requirements
  • Compile and test the program
  • Run /challenge/tester
  • Get flag