• 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 4 pages
Exam (elaborations)

DSA Exam Verified Questions and Answers 100% Correct A+ Graded

Document preview thumbnail
Preview 1 out of 4 pages

DSA Exam Verified Questions and Answers 100% Correct A+ Graded What is a node? - Answer- A building block of a linked list that contains data and a link (pointer to next node). What two fields are inside a node? - Answer- Data and link (pointer to next node). What does the head pointer store? - Answer- The address of the first node in the linked list. What does head_ptr == nullptr mean? - Answer- The linked list is empty. What is a cursor pointer? - Answer- A temporary pointer used to walk through the list without losing head_ptr. What is the traversal pattern for linked lists? - Answer- node* cursor = head_ptr; while(cursor != nullptr) { cursor = cursor-link; } Why do we use cursor instead of head_ptr? - Answer- Moving head_ptr would lose access to the start of the list. What is the runtime of traversing a linked list? - Answer- O(n), as you must visit every node. What does list_length() do? - Answer- Counts the number of nodes in a linked list. What is the runtime of list_length? - Answer- O(n). What are the steps for inserting at head? - Answer- 1. Create node 2. Set data 3. Link to old head 4. Move head pointer. What is the insert head pointer pattern? - Answer- new_node-link = head_ptr; head_ptr = new_node. What is the runtime of inserting at head? - Answer- O(1), constant time. What pointers are needed to insert in the middle? - Answer- Previous and current. What is the insert after pointer pattern? - Answer- new_node-link = previous-link; previous-link = new_node. What are the steps to delete the head node? - Answer- 1. Save head 2. Move head forward 3. Delete old node. What is the delete head pattern? - Answer- node* remove_ptr = head_ptr; head_ptr = head_ptr-link; delete remove_ptr. What is the runtime of deleting head? - Answer- O(1). What does new do? - Answer- Allocates memory on the heap. What does delete do? - Answer- Releases dynamically allocated memory. What happens if you forget delete? - Answer- Memory leak. Why can't we use local nodes? - Answer- Local variables disappear when the function ends. What is the linked list toolkit? - Answer- A collection of non-member helper functions used to manipulate linked lists. What are examples of toolkit functions? - Answer- list_length, list_head_insert, list_insert, list_remove, list_remove_all, list_search, list_locate, list_copy, list_clear. Are toolkit functions member functions? - Answer- No, they are non-member functions that operate on nodes. What is a deep copy? - Answer- Creating new nodes with copied data instead of copying pointers. Why is head2 = head1 bad? - Answer- Both lists point to the same nodes, changes affect both lists. What is a bag container? - Answer- A container that stores items without order, allowing duplicates. What variables are in a linked-list bag? - Answer- head_ptr and many_nodes. What is an advantage of a linked list bag? - Answer- No capacity limit; nodes are dynamically allocated. When must the Big Three be implemented? - Answer- When a class uses dynamic memory. What are the Big Three? - Answer- Copy constructor, assignment operator, destructor. What is the purpose of the copy constructor? - Answer- Creates a deep copy of an object.

Content preview

DSA Exam Verified Questions and
Answers 100% Correct A+ Graded
What is a node? - Answer- A building block of a linked list that contains data and a link
(pointer to next node).

What two fields are inside a node? - Answer- Data and link (pointer to next node).

What does the head pointer store? - Answer- The address of the first node in the linked
list.

What does head_ptr == nullptr mean? - Answer- The linked list is empty.

What is a cursor pointer? - Answer- A temporary pointer used to walk through the list
without losing head_ptr.

What is the traversal pattern for linked lists? - Answer- node* cursor = head_ptr;
while(cursor != nullptr) { cursor = cursor->link; }

Why do we use cursor instead of head_ptr? - Answer- Moving head_ptr would lose
access to the start of the list.

What is the runtime of traversing a linked list? - Answer- O(n), as you must visit every
node.

What does list_length() do? - Answer- Counts the number of nodes in a linked list.

What is the runtime of list_length? - Answer- O(n).

What are the steps for inserting at head? - Answer- 1. Create node 2. Set data 3. Link to
old head 4. Move head pointer.

What is the insert head pointer pattern? - Answer- new_node->link = head_ptr; head_ptr
= new_node.

What is the runtime of inserting at head? - Answer- O(1), constant time.

What pointers are needed to insert in the middle? - Answer- Previous and current.

What is the insert after pointer pattern? - Answer- new_node->link = previous->link;
previous->link = new_node.

What are the steps to delete the head node? - Answer- 1. Save head 2. Move head
forward 3. Delete old node.

Document information

Uploaded on
March 27, 2026
Number of pages
4
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$13.34

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

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
ScholarExams
3.8
(74)
Sold
398
Followers
186
Items
11413
Last sold
8 hours ago



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