• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 9 páginas
Examen

Chapter 5 Data Structures Exam Questions with Answers

Document preview thumbnail
Vista previa 2 fuera de 9 páginas

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

Vista previa del contenido

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;

Información del documento

Subido en
12 de abril de 2025
Número de páginas
9
Escrito en
2024/2025
Tipo
Examen
Contiene
Preguntas y respuestas
$17.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Vendido
2
Seguidores
2
Artículos
1670
Última venta
1 año hace




Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes