Stacks and Queues
- 61Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
61 questions
- 1Python is described as a_____programming language compared with C.
Hint
Think about which language hides more low-level implementation details.
Answer
higher level
- 2Compared with C, Python can often solve the same problems more quickly for_____, although the resulting code may not run as quickly.
Hint
Think about who benefits from writing fewer low-level instructions.
Answer
Humans
- 3The general theme involving choices such as speed, memory use, and programming effort is called_____.
Hint
A gain in one resource often requires sacrificing another.
Answer
trade-offs
- 4A data type defined by its operations and behavior rather than by its implementation details is an_____.
Hint
Focus on what a structure does, not how it is built internally.
Answer
abstract data type
- 5Stacks and queues can each be implemented in multiple ways because they are_____data types.
Hint
Their behavior is specified separately from their concrete memory layout.
Answer
abstract
- 6A concrete definition of how a program uses computer memory to lay out data is called a_____.
Hint
This term refers to an implementation rather than an abstract behavior.
Answer
data structure
- 7When programmers use a feature of Python, Java, or C++ that implements a familiar structure, they are usually benefiting from code written by_____.
Hint
High-level languages commonly provide prewritten implementations.
Answer
someone else
- 8The amount of memory used by a program is commonly called its_____cost.
Hint
This contrasts with the time required to run an algorithm.
Answer
space
- 9A queue is intended to provide a fairness property in which the person who enters first is served_____.
Hint
Think about ordinary lines at stores or events.
Answer
first
- 10The ordering property of a queue is abbreviated_____.
Hint
Expand the phrase as first in, first out.
Answer
FIFO
- 11The queue operation that adds an item to the line is called_____.
Hint
This is the operation analogous to getting in line.
Answer
NQ
- 12The queue operation that removes an item from the front of the line is called_____.
Hint
This is the operation analogous to getting out of line.
Answer
DQ
- 13A stack removes the item that was added most recently, giving it a_____property.
Hint
Expand the phrase as last in, first out.
Answer
LIFO
- 14The stack operation that places an item on the top is called_____.
Hint
Think of pushing a tray onto the top of a stack.
Answer
push
- 15The stack operation that removes an item from the top is called_____.
Hint
Think of taking the uppermost tray away.
Answer
pop
- 16A stack is convenient for objects such as cafeteria trays because gravity makes the_____item easiest to remove.
Hint
The bottom tray would require disturbing the trays above it.
Answer
top
- 17New email commonly appears at the_____of an inbox, illustrating LIFO behavior.
Hint
Recent messages are displayed before older messages by default.
Answer
top
- 18A fixed-size array requires its total size to be decided at_____time.
Hint
The size is hard-coded before the program runs.
Answer
compilation
- 19An array stores its values_____in memory.
Hint
The values are placed back to back.
Answer
contiguous
- 20The first element of a C array is located at index_____.
Hint
C arrays are zero indexed.
Answer
0
- 21The main limitation of a fixed-size array is that its capacity must be chosen_____.
Hint
This phrase means before the program runs or before compilation.
Answer
a priori
- 22Allocating too much unused array space wastes_____.
Hint
The unused locations still occupy computer storage.
Answer
memory
- 23The C function used to request a dynamically sized block of memory is_____.
Hint
Its name abbreviates memory allocation.
Answer
malloc
- 24The C function used to return dynamically allocated memory to the operating system is_____.
Hint
It reverses the ownership obtained through malloc.
Answer
free
- 25When malloc or realloc fails to allocate memory, it returns_____.
Hint
This value indicates that no valid address was returned.
Answer
NULL
- 26The function that can resize an existing dynamically allocated block is_____.
Hint
Its name combines reallocation with memory allocation.
Answer
realloc
- 27A temporary pointer is needed when using realloc so that a failure does not cause the program to lose the address of the_____block.
Hint
The old allocation must remain reachable if resizing fails.
Answer
original
- 28A memory leak occurs when a program loses track of an allocated block before calling_____on it.
Hint
The operating system cannot reclaim a block through the program if its address is lost.
Answer
free
- 29A linked list avoids the requirement that all values be_____in memory.
Hint
Its nodes may be located in separate regions of memory.
Answer
contiguous
- 30The extra information stored alongside a linked-list value to help connect nodes is called_____.
Hint
It is data that helps maintain the data of interest.
Answer
metadata
- 31A linked-list node usually contains data and a pointer to the_____node.
Hint
The pointer creates the path through the list.
Answer
next
- 32The pointer value used to mark the end of a linked list is_____.
Hint
It indicates that there is no subsequent node.
Answer
NULL
- 33A linked list can be represented by storing a pointer to its first node, commonly called_____.
Hint
This pointer serves as the entry point to the entire structure.
Answer
list
- 34The C operator that combines dereferencing a pointer with accessing a structure field is the_____operator.
Hint
It is written using two characters that visually resemble an arrow.
Answer
arrow
- 35Adding a new node to the beginning of a linked list is called_____the node.
Hint
The new node becomes the first node.
Answer
prepending
- 36Inserting a node at the end of a linked list is called_____it.
Hint
The new node follows the current final node.
Answer
appending
- 37With a linked list implementation that always prepends, insertion takes_____time.
Hint
The number of existing nodes does not affect the pointer updates at the front.
Answer
big O of 1
- 38Searching, traversing, and deleting in the discussed linked-list implementation each take_____time in the worst case.
Hint
The operation may need to examine every node.
Answer
big O of N
- 39A linked list with pointers in both directions is called a_____linked list.
Hint
The name contrasts with a singly linked list.
Answer
doubly
- 40A tree is a data structure with_____dimensions, unlike an array or linked list in the discussion.
Hint
It branches rather than forming one linear sequence.
Answer
two
- 41The top node of a tree is called the_____.
Hint
It is analogous to the top of a family tree.
Answer
root
- 42A node in a binary search tree has at most_____child pointers.
Hint
The structure distinguishes left and right children.
Answer
two
- 43In a binary search tree, every node is greater than its_____child and less than its right child.
Hint
Smaller values are placed on one particular side.
Answer
left
- 44The nodes at the edge of a tree that have no children are called_____.
Hint
The term is borrowed from real-world trees.
Answer
leaves
- 45Searching a balanced binary search tree takes_____time.
Hint
Each comparison approximately halves the remaining search space.
Answer
big O of log N
- 46If values are inserted into a binary search tree in an unfortunate order, the tree can degenerate into a_____.
Hint
Each node may end up with only one child.
Answer
linked list
- 47A binary search tree can be kept efficient by_____the tree after insertions or deletions.
Hint
The goal is to preserve logarithmic height.
Answer
rebalancing
- 48The recursive search function returns false immediately when the tree pointer is_____.
Hint
This represents an empty tree or a missing subtree.
Answer
NULL
- 49The theoretical goal of a search that takes the same number of steps regardless of data-set size is_____time.
Hint
This is represented by a flat running-time line.
Answer
constant
- 50Hashing maps values from an infinite domain to a_____range.
Hint
The outputs correspond to a limited number of buckets.
Answer
finite
- 51The function that maps an input key to a bucket is called a_____function.
Hint
It produces the location used by a hash table.
Answer
hash
- 52When different keys map to the same hash-table location, the situation is called a_____.
Hint
Multiple values are competing for one bucket.
Answer
collision
- 53A hash table combines an array with linked lists to handle multiple values in one bucket; this arrangement is called an array of_____.
Hint
Each array position points to a chain of nodes.
Answer
linked lists
- 54Using only the first letter of a name as a hash function produces_____possible buckets for the English alphabet.
Hint
Count the letters from A through Z.
Answer
26
- 55A hash function that uses the first three letters of names reduces collisions but requires_____memory.
Hint
There are many more possible combinations of three letters than single letters.
Answer
more
- 56A hash table with uniformly distributed keys can reduce a linked list of N items to chains averaging roughly N divided by K items, where K is the number of_____.
Hint
K represents the number of available hash locations.
Answer
buckets
- 57A trie is a tree made out of_____.
Hint
Each node contains one position for each possible next character.
Answer
arrays
- 58In a trie for English names, each node's character array has_____positions.
Hint
There is one position for each letter of the alphabet.
Answer
26
- 59A boolean marker in a trie indicates that a stored name_____at that node.
Hint
It distinguishes a complete word from merely a prefix.
Answer
ends
- 60Searching for a name in a trie takes a number of steps determined primarily by the name's_____rather than by the number of stored names.
Hint
The search follows one pointer for each character.
Answer
length
- 61The main trade-off of a trie is that it achieves fast lookup by using a large amount of_____.
Hint
Most character pointers in trie arrays may remain unused.
Answer
memory

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