LecLabs 2.6/7 - Advanced Memory


Intro to Programming Languages.

[ ← Module List ]

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


Challenges

Lecture video on Double Ptr Local

Lecture video on Double Ptr Heap

Lecture video on Triple Ptr Local

Lecture video on Pass-By-Address

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

Lecture video on PBA - Double Ptrs

Lecture video on Array lists

Lecture video on Array lists insert and remove

Lecture video on Linked List

Lecture video on Linked List Insert at End

Lecture video on Linked List Insert at

Lecture video on Linked List Remove

Lecture video on Array list v. Linked List

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

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

30-Day Scoreboard:

This scoreboard reflects solves for challenges in this module after the module launched in this dojo.

Rank Hacker Badges Score