100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.2 TrustPilot
logo-home
Exam (elaborations)

Chapter 5 Data Structures Exam Questions with Answers

Rating
-
Sold
-
Pages
9
Grade
A+
Uploaded on
12-04-2025
Written in
2024/2025

Chapter 5 Data Structures Exam Questions with Answers linked list - Correct Answers: A sequence of items arranged one after another, with each item connected to the next by a link is called a(n) head pointer - Correct Answers: A pointer to the first node in a linked list is called the tail pointer - Correct Answers: A pointer to the last node in a linked list is called the an empty list - Correct Answers: A linked list that contains no nodes is called what? null pointer - Correct Answers: A special C++ constant used for any pointer value that has no place to point is called a nodes - Correct Answers: A collection of _______ makes up a linked list. (*p).m - Correct Answers: If p is a pointer to a class, and m is a member of the class, then p->m means the same as A. (*p).m B. *p.m C. (p.)m D. (*p.)m E. p.m node - Correct Answers: What is the data type of *head_ptr in Figure 5.3 on page 224? A. node B. pointer to a node C. value_type D. data_field pointer to node - Correct Answers: What is the data type of head_ptr in Figure 5.3 on page 224? A. pointer to a node B. node C. value_type D. data_field - Correct Answers: What is the data type of head_ptr->data( ) in Figure 5.3 on page 224? (The definition of data( ) is on page 226.) A. data_field B. pointer to a node C. node D. value_type - Correct Answers: What will the following function return? int calculate(const node* head_ptr) { const node *ptr; int n = 0; for (ptr = head_ptr->get_next(), ptr != NULL; ptr = ptr->get_next()) n++; return n; } A. the length of the list plus 1 B. the length of the list plus 2 C. the length of the list minus 2 D. the length of the list E. the length of the list minus 1 the beginning of the linked list - Correct Answers: The two lines of code below will insert a new node into a linked list at which location? node *ptr = new node(x, head_ptr); head_ptr = ptr; A. after the node pointed to by head_ptr B. the end of the linked list C. the beginning of the linked list D. after the node pointed to by ptr - Correct Answers: The two lines of code below will insert a new node into a linked list at which location? node *ptr = new node(x, previous_ptr->get_next()); previous_ptr->set_next(ptr); A. before the node pointed to by previous_ptr B. after the node pointed to by previous_ptr C. after the node pointed to by ptr D. after the node pointed to by previous_ptr->get_next() E. the end of the linked list a pointer to the node containing the value of x or the NULL pointer - Correct Answers: What does the following function return? node* list_search(node *head_ptr, double x) { node *ptr; for (ptr = head_ptr; ptr != NULL; ptr = ptr->get_next()) if (x == ptr->get_value()) return ptr; return NULL; } A. the value of x B. TRUE or FALSE C. the position in the linked list of the node containing the value of x D. a pointer to the node containing the value of x or the NULL pointer deletes the first node in the linked list - Correct Answers: What action does the following code segment perform? node *ptr = head_ptr; head_ptr = head_ptr->get_next(); delete ptr; A. deletes the node pointed to by head_ptr->get_next( ) B. deletes the first node in the linked list C. deletes the node that comes immediately after the node pointed to by head_ptr D. deletes the last node in the linked list deletes the node that comes after the node initially pointed to by previous_ptr - Correct Answers: What action does the following code segment perform? node *ptr = previous_ptr->get_next(); previous_ptr->set_next(ptr->get_next()); delete ptr; A. deletes the node initially pointed to by previous_ptr B. deletes the node that comes before the node initially pointed to by previous_ptr C. deletes the node that comes after the node initially pointed to by previous_ptr 12 - Correct Answers: For the linked list shown below, what will the code segment display? Head_ptr -> 4 -> 6 -> 12, NULL node *ptr = head_ptr->get_next( ); ptr = ptr->get_next( ); cout << ptr->get_value( ); A. 6 B. 4 C. nothing D. 12 10 - Correct Answers: For the linked list shown below, what will the code segment display? Head_ptr -> 4 -> 6 -> 12 -> 20, NULL node *ptr; int sum = 0; for (ptr = head_ptr; ptr->get_value( ) < 10; ptr = ptr->get_next( )) sum += ptr->get_value( ); cout << sum << endl; A. 42 B. 6 C. 10 D. 4 E. 22 32 - Correct Answers: For the linked list shown below, what will the code segment display? Head_ptr -> 4 -> 6 -> 12 -> 20,NULL node *ptr1, *ptr2; ptr1 = head_ptr; ptr2 = ptr1; ptr2 = ptr2->get_next( ); ptr2 = ptr2->get_next( ); ptr1 = ptr2->get_next( ); cout << ptr1->get_value( ) + ptr2->get_value( ) << endl; A. 10 B. 32 C. 24 D. 18 E. 26 - Correct Answers: For the linked list shown below, what will the code segment display? Head_ptr -> 4 -> 6 -> 12,NULL node *ptr; for (ptr = head_ptr->get_next( ); ptr != NULL; ptr = ptr->get_next( )) cout << ptr->get_data( ); A. 46 B. 46120 C. 612 D. 4612 E. nothing

Show more Read less
Institution
Data Structures And Algorithm Analysis In C+
Course
Data Structures and Algorithm Analysis in C+









Whoops! We can’t load your doc right now. Try again or contact support.

Written for

Institution
Data Structures and Algorithm Analysis in C+
Course
Data Structures and Algorithm Analysis in C+

Document information

Uploaded on
April 12, 2025
Number of pages
9
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Content preview

Chapter 5 Data Structures
Exam Questions with Answers
linked list - Correct Answers: A sequence of items arranged one after another, with each item connected
to the next by a link is called a(n)



head pointer - Correct Answers: A pointer to the first node in a linked list is called the



tail pointer - Correct Answers: A pointer to the last node in a linked list is called the



an empty list - Correct Answers: A linked list that contains no nodes is called what?



null pointer - Correct Answers: A special C++ constant used for any pointer value that has no place to
point is called a



nodes - Correct Answers: A collection of _______ makes up a linked list.



(*p).m - Correct Answers: If p is a pointer to a class, and m is a member of the class, then p->m means
the same as



A. (*p).m

B. *p.m

C. (p.)m

D. (*p.)m

E. p.m



node - Correct Answers: What is the data type of *head_ptr in Figure 5.3 on page 224?



A. node

, B. pointer to a node

C. value_type

D. data_field



pointer to node - Correct Answers: What is the data type of head_ptr in Figure 5.3 on page 224?



A. pointer to a node

B. node

C. value_type

D. data_field



- Correct Answers: What is the data type of head_ptr->data( ) in Figure 5.3 on page 224? (The definition
of data( ) is on page 226.)



A. data_field

B. pointer to a node

C. node

D. value_type



- Correct Answers: What will the following function return?



int calculate(const node* head_ptr)



{



const node *ptr;



int n = 0;
$16.99
Get access to the full document:

100% satisfaction guarantee
Immediately available after payment
Both online and in PDF
No strings attached

Get to know the seller
Seller avatar
EXAMSTUVIA

Also available in package deal

Thumbnail
Package deal
Data Structures and Algorithm Analysis Bundle Compilation Grade A+
-
15 2025
$ 254.55 More info

Get to know the seller

Seller avatar
EXAMSTUVIA stuvia
View profile
Follow You need to be logged in order to follow users or courses
Sold
2
Member since
1 year
Number of followers
2
Documents
1102
Last sold
3 months ago
Stuvia Exam

Assignments, Case Studies, Research, Essay writing service, Questions and Answers, Discussions etc. for students who want to see results twice as fast. I have done papers of various topics and complexities. I am punctual and always submit work on-deadline. I write engaging and informative content on all subjects. Send me your research papers, case studies, psychology papers, etc, and I’ll do them to the best of my abilities. Writing is my passion when it comes to academic work. I’ve got a good sense of structure and enjoy finding interesting ways to deliver information in any given paper. I love impressing clients with my work, and I am very punctual about deadlines. Send me your assignment and I’ll take it to the next level. I strive for my content to be of the highest quality. Your wishes come first— send me your requirements and I’ll make a piece of work with fresh ideas, consistent structure, and following the academic formatting rules. For every student you refer to me with an order that is completed and paid transparently, I will do one assignment for you, free of charge!!!!!!!!!!!!

Read more Read less
0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

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

Frequently asked questions