C Data Structures and Pointers
- 76Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
76 questions
- 1A variable that stores the address of another value in memory is called a_____.
Hint
It lets a program refer to a memory location by its address.
Answer
pointer
- 2In C, the operator that follows a pointer to access the value at its address is the_____operator.
Hint
It means going to the address stored in a pointer.
Answer
dereference
- 3The function that requests a chunk of memory dynamically is_____.
Hint
Its name abbreviates memory allocation.
Answer
malloc
- 4The operator that reports how many bytes a type or object requires is_____.
Hint
It can be used to request enough memory for a particular type.
Answer
sizeof
- 5A safe way to request enough memory for a variable of a particular type is to use_____with that type.
Hint
This operator avoids having to assume the type's byte count.
Answer
sizeof
- 6If a pointer has not been assigned a valid address, dereferencing it may cause a_____.
Hint
This error can occur when a program accesses an invalid memory address.
Answer
segmentation fault
- 7The special pointer value used to represent that a pointer points to nothing is_____.
Hint
It is commonly used to mark an empty list or the end of a linked list.
Answer
NULL
- 8The value returned by malloc should be checked against_____before the allocated memory is used.
Hint
This return value can indicate that the allocation failed.
Answer
NULL
- 9The function used to return dynamically allocated memory to the computer is_____.
Hint
It takes the address of the memory that is no longer needed.
Answer
free
- 10Assigning one pointer to another copies the_____they store, so both pointers can refer to the same memory.
Hint
It is the location in memory represented by a pointer.
Answer
address
- 11When two pointers refer to the same pointee, changing that pointee through either pointer changes the same_____.
Hint
The pointers are aliases for one underlying location.
Answer
memory
- 12In a structure, the notation used to access a field through a structure variable is the_____operator.
Hint
It appears between the structure variable's name and a field name.
Answer
dot
- 13A programming construct that groups information in a defined arrangement, such as a number and a pointer, can be created in C with_____.
Hint
It is the C keyword used to define a custom structure.
Answer
struct
- 14When a dynamically allocated block is no longer reachable because its address was overwritten, the program has created a memory_____.
Hint
The allocated memory is lost and cannot be properly freed.
Answer
leak
- 15A fixed-size array requires its size to be specified_____.
Hint
The size must be chosen before the array is used.
Answer
upfront
- 16The values in an array are stored in a_____chunk of memory.
Hint
The values occupy adjacent memory locations.
Answer
contiguous
- 17If a fixed-size array has no room for an additional value, one way to grow it is to allocate a larger chunk and_____the existing values.
Hint
The old elements must be transferred to the new memory.
Answer
copy
- 18Copying all n existing elements when growing an array takes_____time.
Hint
The work increases in proportion to the number of elements copied.
Answer
O(n)
- 19For a sorted array that supports direct indexing, binary search can find a value in_____time.
Hint
Each comparison eliminates roughly half of the remaining search space.
Answer
O(logn)
- 20The C function that resizes an existing dynamically allocated memory block is_____.
Hint
Its name suggests allocating the block again at a new size.
Answer
realloc
- 21A temporary pointer is useful when reallocating because overwriting the original pointer too soon could lose the old block's_____.
Hint
The pointer is needed to keep track of where the original allocation is.
Answer
address
- 22After realloc succeeds, the program should update its pointer to the_____address returned for the resized block.
Hint
The resized allocation may be located somewhere different in memory.
Answer
new
- 23For a pointer to integers, square-bracket indexing advances by the size of an_____rather than by one byte.
Hint
The indexed elements have this C type.
Answer
int
- 24A dynamically allocated block can be used with square-bracket notation because it is a contiguous chunk of_____.
Hint
The block consists of adjacent locations that can be indexed.
Answer
memory
- 25A linked list is made up of nodes connected by_____.
Hint
They store addresses that lead from one node to another.
Answer
pointers
- 26A linked-list node in the example contains an integer field and a pointer field called_____.
Hint
This field indicates where to continue traversing the list.
Answer
next
- 27A pointer to a node can be declared as a_____.
Hint
In C notation, the type combines the node type with an asterisk.
Answer
node star
- 28The address of the first node is enough to begin accessing the rest of a linked list because its nodes link to one another through_____.
Hint
Following these connections lets a program move through the list.
Answer
pointers
- 29The pointer that represents an initially empty linked list should be initialized to_____.
Hint
An empty list has no first node to point to.
Answer
NULL
- 30The final node in a linked list typically has its next pointer set to_____.
Hint
This value marks the end of the chain.
Answer
NULL
- 31The C arrow notation for accessing a field through a pointer is equivalent to dereferencing the pointer and using the_____operator.
Hint
This field-access operator is used directly with a structure variable.
Answer
dot
- 32To add a node dynamically, a program can use malloc with_____to request enough bytes for the whole node.
Hint
This operator calculates the memory required by a type.
Answer
sizeof
- 33Before using fields of a node returned by malloc, a program should check that its pointer is not_____.
Hint
This value can signal that allocating the node failed.
Answer
NULL
- 34When adding a new node at the beginning of a list, first make the new node point to the list's_____first node.
Hint
Preserving this connection prevents the existing nodes from becoming unreachable.
Answer
current
- 35After linking a new first node to the existing list, update the list pointer to point to the_____node.
Hint
This node has just been inserted at the front.
Answer
new
- 36When inserting a node in the middle of a linked list, update the new node's next pointer before redirecting the previous node's pointer; otherwise the remaining nodes could become_____.
Hint
They would no longer be reachable by following the list.
Answer
orphaned
- 37To find a value or insertion point in a linked list, a program generally must follow the nodes one by one, so the operation can take_____time.
Hint
In the worst case, the program may examine every node.
Answer
O(n)
- 38Unlike an array, a linked list does not provide_____access to an arbitrary indexed element.
Hint
This kind of access lets an array jump directly to an index.
Answer
random
- 39A major advantage of linked lists over fixed-size arrays is that they can grow dynamically without_____all existing elements to a new block.
Hint
New nodes can be allocated separately and linked in.
Answer
moving
- 40Because linked-list nodes can be located throughout memory, the link between nodes is represented by a stored_____rather than by their physical adjacency.
Hint
It contains the address of the next node.
Answer
pointer
- 41A binary search tree is a tree in which each node has at most_____children.
Hint
The prefix in its name refers to this maximum number.
Answer
two
- 42In a binary search tree, values in a node's left subtree are_____than the node's value.
Hint
This ordering rule tells a search which direction to take for a lower target.
Answer
smaller
- 43In a binary search tree, values in a node's right subtree are_____than the node's value.
Hint
This ordering rule directs a search for a higher target.
Answer
greater
- 44The top node from which the rest of a tree can be reached is called the_____.
Hint
It is the starting point for traversing the tree.
Answer
root
- 45When searching a binary search tree, a target smaller than the current node's value directs the search to the_____subtree.
Hint
The tree's ordering places smaller values on this side.
Answer
left
- 46When searching a binary search tree, a target greater than the current node's value directs the search to the_____subtree.
Hint
The tree's ordering places greater values on this side.
Answer
right
- 47If a search reaches a NULL tree pointer without finding the target, the recursive search should return_____.
Hint
An empty subtree cannot contain the sought value.
Answer
false
- 48If the target is neither smaller nor greater than the current node's value, the search has found an_____.
Hint
The target matches the value stored at the node.
Answer
equal value
- 49Searching a balanced binary search tree takes_____time.
Hint
Each step can rule out a substantial part of the remaining tree.
Answer
O(logn)
- 50If values are repeatedly added to only one side of a binary search tree, the tree can become_____and lose its efficient height.
Hint
The tree becomes much taller on one side than the other.
Answer
unbalanced
- 51A hash table combines an array with_____to store multiple items that map to the same bucket.
Hint
These structures can chain together values within a bucket.
Answer
linked lists
- 52A hash function takes an input and produces an output that determines which_____receives the item.
Hint
It is one location in the array used by a hash table.
Answer
bucket
- 53In a simple name-based hash function, the first letter of a name can determine its_____in the array.
Hint
The letter is used to choose a storage location.
Answer
bucket
- 54When two inputs map to the same hash-table bucket, the event is called a_____.
Hint
The bucket already contains an item when another item is mapped there.
Answer
collision
- 55Storing colliding items in a linked list is one method of_____collisions.
Hint
The method provides a way to handle multiple items assigned to one bucket.
Answer
resolving
- 56Using only the first letter of names can create long bucket lists when many names share that_____.
Hint
Names beginning alike are sent to the same location by this simple hash function.
Answer
letter
- 57If many items collide in one bucket, searching a hash table can take_____time in the worst case.
Hint
The bucket may require checking every stored item.
Answer
O(n)
- 58Using more characters from each name in a hash function can reduce the probability of_____.
Hint
More detailed inputs are less likely to map to the same bucket.
Answer
collisions
- 59Increasing the number of buckets may reduce collisions, but it also uses more_____.
Hint
The larger array must occupy additional memory.
Answer
space
- 60The tension between using more memory and reducing the time needed for operations is a time-space_____.
Hint
Improving one resource can require spending more of another.
Answer
trade-off
- 61Under favorable distribution, hash-table operations can be much faster on average than the_____-time worst case.
Hint
This describes the worst-case behavior when items pile into one bucket.
Answer
linear
- 62A trie is a tree whose nodes are essentially_____.
Hint
Each node provides an indexed choice for the next character.
Answer
arrays
- 63To look up a name in a trie, the search follows a path determined by_____in the name.
Hint
The path uses the name's full sequence, not just its first few characters.
Answer
each letter
- 64When a trie needs a branch for a letter that has not yet been represented, a new_____is allocated.
Hint
In this trie, the new structure contains an array for further letters.
Answer
node
- 65A trie can share initial branches among names that have the same_____.
Hint
These are the starting letters common to multiple words.
Answer
prefix
- 66A trie needs a marker at the node where a complete word or name_____.
Hint
The marker distinguishes a complete entry from a prefix of a longer one.
Answer
ends
- 67For a fixed upper bound on word length, searching a trie takes time proportional to that length, often described as_____time.
Hint
The number of steps depends on the word's length rather than how many other words are stored.
Answer
constant
- 68A trie can offer fast lookup even as the number of stored words grows, but it pays for this speed with greater_____use.
Hint
Its many array nodes require substantial storage.
Answer
memory
- 69A queue follows the rule_____in, first out.
Hint
The earliest item added is the earliest one removed.
Answer
first
- 70The operation that adds an item to a queue is called_____.
Hint
It corresponds to joining the end of a line.
Answer
enqueue
- 71The operation that removes an item from a queue is called_____.
Hint
It corresponds to leaving the line after being served.
Answer
dequeue
- 72A stack follows the rule_____in, first out.
Hint
The newest item added is removed first.
Answer
last
- 73The operation that adds an item to a stack is called_____.
Hint
It places an item onto the top of the stack.
Answer
push
- 74The operation that removes the top item from a stack is called_____.
Hint
It removes the most recently added item.
Answer
pop
- 75A dictionary is a data structure that associates_____with values.
Hint
A word can serve as one of these labels for retrieving its associated information.
Answer
keys
- 76A programming data structure that provides an interface for a kind of behavior without specifying its low-level implementation is an_____data structure.
Hint
It describes what the structure does rather than its internal plumbing.
Answer
abstract

Ask anything
We've read this whole study set, so questions about it get the best answers.