• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 1 out of 3 pages
Other

CS 2 Exam Review

Document preview thumbnail
Preview 1 out of 3 pages

CS 2 Exam Review Notes

Content preview

1. You are asked to design a function that removes duplicates from a
singly linked list. In plain English describe how you could break this
problem down into simpler subtasks before writing code.
2. The definition of the ‘new’ operator
3. Which XXX will avoid a memory leak:

#include <iostream>

Using namespace std;

Class myClass{

Public:

myClass();

int value;

private:

int* ptr;

};

myClass::myClass(){

ptr = new int;

*ptr = 0;

Delete ptr;

}

Int main(){

Int value = 100;

Int* ptr = new int;

///XXX

Ptr1 = &value;

4. Which statement properly frees the dynamically allocated array below:
a. Musketeer* musketeers = new Musketeer[8];
5. You have the following doubly-linked list. Each node has a data(char),
as well as prev and next Node pointers. Create a new Node with the
value ‘z’ and replace thisNode with your new Node. For this exercise,
you will not overwrite thisNode’s data. Instead, you will connect your

Document information

Uploaded on
December 6, 2025
Number of pages
3
Written in
2025/2026
Type
Other
Person
Unknown
$9.19

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Sold
0
Followers
0
Items
1
Last sold
-



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions