Deck 13: Dynamic Data Structures

Full screen (f)
exit full mode
Question
Using an array of structures to insert and delete ordered structures is an efficient use of memory.
Use Space or
up arrow
down arrow
to flip the card.
Question
A linked list provides a convenient method for maintaining a constantly changing list without the need to reorder and restructure the complete list continually.
Question
Removal of a structure from an ordered linked list is the reverse process of adding a structure.
Question
Each structure in a linked list has the same format.
Question
In addition to an end-of-list sentinel value in a linked list, we must provide a special pointer for storing the address of the last structure in the list.
Question
C does not allow pointers to be members of structures.
Question
The dot operator has a lower precedence than the indirection operator.
Question
The precedence of the member operator and the structure pointer operator are equal.
Question
The member operator is evaluated from right to left.
Question
The structure pointer operator is evaluated from left to right.
Question
The addresses in a linked list of structures can be used to loop through the complete list.
Question
C provides the four functions, malloc(), calloc(), realloc(), and free() to control the dynamic allocation and release of memory space.
Question
The function prototype for malloc() is contained in the stdio.h header file.
Question
malloc() returns the address of the first reserved location, as an address of a void data type, or the program exits if sufficient memory is not available.
Question
The advantage to the calloc() function is that it initializes all newly allocated numeric memory to 0 and character allocated memory to NULL.
Question
In making requests for dynamic memory allocation, it is extremely important to always check the return value; otherwise, the program will crash when a subsequent access to nonexistent memory is made.
Question
You should never forget to restore the allocated block of storage back to the operating system using free(); otherwise, the allocated storage will be lost until you reboot the computer.
Question
In computer programming, stacks are used in all function calls to store and retrieve data input to and retrieved from the function, respectively.
Question
A stack requires a separate stack pointer that contains the address of the first structure added to the stack.
Question
Items are removed from a queue in the order in which they were entered.
Question
A queue is a LIFO structure.
Question
The operation of removing an item from a queue is formally referred to as serving.
Question
The functions isempty() and isfull()are required in any queue implementation.
Question
A dynamically linked list permits adding or deleting a structure from anywhere within the list.
Question
Deleting a structure in a linked list is essentially the reverse process of inserting a structure.
Question
____ memory allocation makes it unnecessary to reserve a fixed amount of memory for a scalar, array, or structure variable in advance.

A)Dynamic
B)Static
C)Partial
D)Advanced
Question
Dynamic memory allocation is also known as ____ allocation.

A)partial
B)static
C)run-time
D)advanced
Question
Structures that are "linked" together by including the address of the next structure in the structure immediately preceding it are known as ____ structures.

A)linked
B)self-referencing
C)dynamic
D)sequential
Question
All programming languages that support pointers provide a special pointer value, known as both NULL and ____, that acts as a sentinel or flag to indicate when the last structure has been processed.

A)FALSE
B)VOID
C)NIL
D)INVALID
Question
In C, the special NULL pointer value that acts as a sentinel or flag to indicate when the last structure has been processed has a numerical value of ____.

A)-1
B)0
C)1
D)255
Question
The indirection operator in C is ____.

A))
B)->
C)&
D)*
Question
The expression *emp.ptPay is equivalent to the expression ____.

A)*(emp.ptPay)
B)(*emp).ptPay
C)*emp->ptPay
D)*(emp.)ptPay
Question
Which of the following statements is correct with respect to the TeleType structure declaration?
Struct TeleType
{
Char name[30];
Char phoneNum[15];
Struct TeleType *nextaddr;
};

A)It is not valid in C
B)Can be used to create a linked list of TeleType structures
C)May be valid depending on the compiler
D)Generates a "self-referencing" compiler warning
Question
The following is an example of the creation of a(n) ____ in C.
First = &t1;
T1)nextaddr = &t2;
T2)nextaddr = &t3;
T3)nextaddr = NULL;

A)array
B)stack
C)linked list
D)queue
Question
The structure pointer operator is ____.

A))
B)->
C)&
D)*
Question
The expression t1.nextaddr->name is evaluated as ____.

A)t1(.nextaddr->name)
B)(t1.nextaddr->)name
C)t1.(nextaddr->name)
D)(t1.nextaddr)->name
Question
The expression t1.nextaddr->name can be replaced by the equivalent expression ____.

A)(*t1.nextaddr).name
B)(&t1.nextaddr).name
C)*(*t1.nextaddr).name
D)*((*t1.nextaddr).name)
Question
The following function cycles through a linked list and displays its contents. Line 3 can be replaced with ____.
1 void display(struct myStruct *contents)
2 {
3 while (contents != NULL)
4 {
5 printf("%-30s\n",contents->name, contents->phoneNum);
6 contents = contents->nextaddr;
7 }
8 }

A)while (isValid(contents))
B)while (contents != EOF)
C)while (!contents)
D)while (contents != NIL)
Question
____ reserves the number of bytes requested by the argument passed to the function.

A)malloc()
B)calloc()
C)realloc()
D)balloc()
Question
____ reserves space for an array of n elements of the specified size.

A)malloc()
B)calloc()
C)realloc()
D)nalloc()
Question
____ changes the size of previously allocated memory to a new size.

A)malloc()
B)calloc()
C)realloc()
D)free()
Question
The function call ____ requests enough memory to store 10 characters.

A)realloc(10,sizeof(char))
B)calloc(sizeof(char),10)
C)malloc(sizeof(char))
D)malloc(10 sizeof(char))
Question
A ____ is a special type of linked list in which objects can only be added to and removed from the top of the list.

A)heap
B)stack
C)queue
D)set
Question
The operation of placing a new structure on the top of a stack is called a ____.

A)PUSH
B)POP
C)INSERT
D)PUT
Question
Stacks and queues are two special forms of a more general data object called a(n) ____.

A)array
B)table
C)deque
D)heap
Question
The following pseudocode describes a stack's ____ function.
Move the structure contents pointed to by the top-of-stack pointer into a work area
Free the structure pointed to by the top-of-stack pointer
Move the address in the work area address field into the top-of-stack pointer

A)PUSH
B)POP
C)ISEMPTY
D)NEW
Question
Placing a new item on top of the queue is formally referred to as ____.

A)enqueueing
B)serving
C)pushing
D)inserting
Question
The operation of adding a new structure to a dynamically linked list is called a(n) ____.

A) PUSH
C) INSERT
B) ENQUEUE
D) ADD
Question
The operation of removing a structure from a dynamically linked list is called a(n) ____.

A) POP
C) REMOVE
B) SERVE
D) DELETE
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/49
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 13: Dynamic Data Structures
1
Using an array of structures to insert and delete ordered structures is an efficient use of memory.
False
2
A linked list provides a convenient method for maintaining a constantly changing list without the need to reorder and restructure the complete list continually.
True
3
Removal of a structure from an ordered linked list is the reverse process of adding a structure.
True
4
Each structure in a linked list has the same format.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
5
In addition to an end-of-list sentinel value in a linked list, we must provide a special pointer for storing the address of the last structure in the list.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
6
C does not allow pointers to be members of structures.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
7
The dot operator has a lower precedence than the indirection operator.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
8
The precedence of the member operator and the structure pointer operator are equal.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
9
The member operator is evaluated from right to left.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
10
The structure pointer operator is evaluated from left to right.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
11
The addresses in a linked list of structures can be used to loop through the complete list.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
12
C provides the four functions, malloc(), calloc(), realloc(), and free() to control the dynamic allocation and release of memory space.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
13
The function prototype for malloc() is contained in the stdio.h header file.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
14
malloc() returns the address of the first reserved location, as an address of a void data type, or the program exits if sufficient memory is not available.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
15
The advantage to the calloc() function is that it initializes all newly allocated numeric memory to 0 and character allocated memory to NULL.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
16
In making requests for dynamic memory allocation, it is extremely important to always check the return value; otherwise, the program will crash when a subsequent access to nonexistent memory is made.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
17
You should never forget to restore the allocated block of storage back to the operating system using free(); otherwise, the allocated storage will be lost until you reboot the computer.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
18
In computer programming, stacks are used in all function calls to store and retrieve data input to and retrieved from the function, respectively.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
19
A stack requires a separate stack pointer that contains the address of the first structure added to the stack.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
20
Items are removed from a queue in the order in which they were entered.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
21
A queue is a LIFO structure.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
22
The operation of removing an item from a queue is formally referred to as serving.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
23
The functions isempty() and isfull()are required in any queue implementation.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
24
A dynamically linked list permits adding or deleting a structure from anywhere within the list.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
25
Deleting a structure in a linked list is essentially the reverse process of inserting a structure.
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
26
____ memory allocation makes it unnecessary to reserve a fixed amount of memory for a scalar, array, or structure variable in advance.

A)Dynamic
B)Static
C)Partial
D)Advanced
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
27
Dynamic memory allocation is also known as ____ allocation.

A)partial
B)static
C)run-time
D)advanced
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
28
Structures that are "linked" together by including the address of the next structure in the structure immediately preceding it are known as ____ structures.

A)linked
B)self-referencing
C)dynamic
D)sequential
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
29
All programming languages that support pointers provide a special pointer value, known as both NULL and ____, that acts as a sentinel or flag to indicate when the last structure has been processed.

A)FALSE
B)VOID
C)NIL
D)INVALID
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
30
In C, the special NULL pointer value that acts as a sentinel or flag to indicate when the last structure has been processed has a numerical value of ____.

A)-1
B)0
C)1
D)255
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
31
The indirection operator in C is ____.

A))
B)->
C)&
D)*
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
32
The expression *emp.ptPay is equivalent to the expression ____.

A)*(emp.ptPay)
B)(*emp).ptPay
C)*emp->ptPay
D)*(emp.)ptPay
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
33
Which of the following statements is correct with respect to the TeleType structure declaration?
Struct TeleType
{
Char name[30];
Char phoneNum[15];
Struct TeleType *nextaddr;
};

A)It is not valid in C
B)Can be used to create a linked list of TeleType structures
C)May be valid depending on the compiler
D)Generates a "self-referencing" compiler warning
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
34
The following is an example of the creation of a(n) ____ in C.
First = &t1;
T1)nextaddr = &t2;
T2)nextaddr = &t3;
T3)nextaddr = NULL;

A)array
B)stack
C)linked list
D)queue
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
35
The structure pointer operator is ____.

A))
B)->
C)&
D)*
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
36
The expression t1.nextaddr->name is evaluated as ____.

A)t1(.nextaddr->name)
B)(t1.nextaddr->)name
C)t1.(nextaddr->name)
D)(t1.nextaddr)->name
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
37
The expression t1.nextaddr->name can be replaced by the equivalent expression ____.

A)(*t1.nextaddr).name
B)(&t1.nextaddr).name
C)*(*t1.nextaddr).name
D)*((*t1.nextaddr).name)
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
38
The following function cycles through a linked list and displays its contents. Line 3 can be replaced with ____.
1 void display(struct myStruct *contents)
2 {
3 while (contents != NULL)
4 {
5 printf("%-30s\n",contents->name, contents->phoneNum);
6 contents = contents->nextaddr;
7 }
8 }

A)while (isValid(contents))
B)while (contents != EOF)
C)while (!contents)
D)while (contents != NIL)
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
39
____ reserves the number of bytes requested by the argument passed to the function.

A)malloc()
B)calloc()
C)realloc()
D)balloc()
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
40
____ reserves space for an array of n elements of the specified size.

A)malloc()
B)calloc()
C)realloc()
D)nalloc()
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
41
____ changes the size of previously allocated memory to a new size.

A)malloc()
B)calloc()
C)realloc()
D)free()
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
42
The function call ____ requests enough memory to store 10 characters.

A)realloc(10,sizeof(char))
B)calloc(sizeof(char),10)
C)malloc(sizeof(char))
D)malloc(10 sizeof(char))
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
43
A ____ is a special type of linked list in which objects can only be added to and removed from the top of the list.

A)heap
B)stack
C)queue
D)set
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
44
The operation of placing a new structure on the top of a stack is called a ____.

A)PUSH
B)POP
C)INSERT
D)PUT
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
45
Stacks and queues are two special forms of a more general data object called a(n) ____.

A)array
B)table
C)deque
D)heap
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
46
The following pseudocode describes a stack's ____ function.
Move the structure contents pointed to by the top-of-stack pointer into a work area
Free the structure pointed to by the top-of-stack pointer
Move the address in the work area address field into the top-of-stack pointer

A)PUSH
B)POP
C)ISEMPTY
D)NEW
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
47
Placing a new item on top of the queue is formally referred to as ____.

A)enqueueing
B)serving
C)pushing
D)inserting
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
48
The operation of adding a new structure to a dynamically linked list is called a(n) ____.

A) PUSH
C) INSERT
B) ENQUEUE
D) ADD
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
49
The operation of removing a structure from a dynamically linked list is called a(n) ____.

A) POP
C) REMOVE
B) SERVE
D) DELETE
Unlock Deck
Unlock for access to all 49 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 49 flashcards in this deck.