JavaScript Data Structures
- 122Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
122 questions
- 1A stack of books illustrates which access pattern, in which the last item added is the first item removed?_____
Hint
Think about which book is exposed when the top book is removed.
Answer
last in first out
- 2In a stack, adding an item to the top is called_____.
Hint
This operation places new data onto the stack.
Answer
push
- 3In a stack, removing and returning the top item is called_____.
Hint
This operation removes the most recently added item.
Answer
pop
- 4The stack operation that displays the top element without removing it is called_____.
Hint
Unlike pop, this operation leaves the stack unchanged.
Answer
peek
- 5The stack operation that determines how many elements are stored is called_____or size.
Hint
JavaScript arrays use this property to report the number of elements.
Answer
length
- 6A browser back button can use a stack because the most recently visited URL is the first URL removed by a_____operation.
Hint
Going back removes the current most recent page from the history stack.
Answer
pop
- 7In JavaScript, an array can be used as a stack because arrays already provide the needed stack functions, including_____and pop.
Hint
This operation adds an element to the end of an array.
Answer
push
- 8A word that is spelled the same forwards and backwards is called a_____.
Hint
Examples include Bob and racecar.
Answer
palindrome
- 9To reverse a word with a stack, the letters are pushed in their original order and then_____in reverse order.
Hint
Items leave a stack in the opposite order from which they entered.
Answer
popped
- 10In a manually implemented stack, the variable that tracks how many items are stored is called_____.
Hint
It increases after pushing and decreases after popping.
Answer
count
- 11A stack pop operation returns_____when an attempt is made to remove an item from an empty stack.
Hint
This JavaScript value represents the absence of a stored result.
Answer
undefined
- 12The top item in a manually implemented stack is stored at the position represented by count_____.
Hint
Count points one position beyond the final valid element.
Answer
minus one
- 13A set differs from an ordinary array because it does not allow_____items.
Hint
Every value can occur at most once.
Answer
duplicate
- 14Unlike an array, the values in a set are not stored in any particular_____.
Hint
Set membership matters more than sequence.
Answer
order
- 15The main typical use of a set is checking for the_____of an item.
Hint
The question is whether a value is included.
Answer
presence
- 16The set method that checks whether an element exists and returns true or false is called_____.
Hint
Its name describes checking whether the collection contains something.
Answer
has
- 17The set method that returns all stored values is called_____.
Hint
It exposes the collection of elements.
Answer
values
- 18When adding an element to a custom set, the element should be pushed only if the set does not already_____it.
Hint
The membership-checking method provides this information.
Answer
have
- 19The custom set method that removes an element and returns true when successful is called_____.
Hint
The ES6 version uses a different name for the same general operation.
Answer
remove
- 20In the ES6 Set implementation, the operation corresponding to custom remove is called_____.
Hint
This is the built-in method name used to remove a value.
Answer
delete
- 21In an ES6 Set, size is a property rather than a_____.
Hint
It is accessed without parentheses.
Answer
method
- 22The union of two sets contains all values from both sets while leaving out_____.
Hint
The result contains each value only once.
Answer
duplicates
- 23The intersection of two sets contains values that occur in_____sets.
Hint
These are the elements shared by the two collections.
Answer
both
- 24The difference between two sets contains values in one set but not the_____set.
Hint
The comparison excludes values found in the second collection.
Answer
other
- 25A set is a subset of another set when every element of the first set is completely contained within the_____set.
Hint
The larger comparison collection is checked for every first-set value.
Answer
second
- 26A queue follows which access pattern, in which the first item added is the first item removed?_____
Hint
Think of people waiting in a line.
Answer
first in first out
- 27In a store line, the first person to enter is the first person to reach the_____.
Hint
This is where the person completes the purchase.
Answer
cash register
- 28A print queue normally processes documents in the order in which they were_____to the queue.
Hint
Earlier submitted documents are printed earlier.
Answer
sent
- 29The queue operation that adds an item is called_____.
Hint
It places an element at the back of the queue.
Answer
enqueue
- 30The queue operation that removes an item from the front is called_____.
Hint
It removes the oldest element.
Answer
dequeue
- 31In the described array implementation, enqueue adds items at the_____of the array.
Hint
The implementation uses push for insertion.
Answer
end
- 32In the described array implementation, dequeue removes items from the_____of the array.
Hint
The implementation uses shift for removal.
Answer
beginning
- 33The queue method that returns the front item without removing it is called_____.
Hint
It reads the element at index zero.
Answer
front
- 34A queue is empty when its collection length is equal to_____.
Hint
No elements remain in the collection.
Answer
zero
- 35A priority queue stores both an element and its_____.
Hint
This extra value determines placement in the queue.
Answer
priority
- 36In a priority queue, elements with a higher priority are moved toward the_____of the queue.
Hint
They are served before lower-priority elements.
Answer
beginning
- 37When two priority-queue elements have the same priority, they are processed like a normal_____.
Hint
Their insertion order is preserved.
Answer
queue
- 38In a tree, every data point is called a_____.
Hint
It is the basic unit that stores data.
Answer
node
- 39The top node of a tree is called the_____node.
Hint
All other branches descend from this node.
Answer
root
- 40A node with branches leading to other nodes is the_____of those nodes.
Hint
The connected nodes below it are its children.
Answer
parent
- 41A node at the end of a tree with no children is called a_____node.
Hint
It is like the terminal end of a branch.
Answer
leaf
- 42A binary tree allows each node to have at most_____branches.
Hint
The word binary refers to this limit.
Answer
two
- 43In a binary search tree, the left subtree is less than or equal to the_____node.
Hint
Smaller values are placed on the left.
Answer
parent
- 44In a binary search tree, the right subtree is greater than or equal to the_____node.
Hint
Larger values are placed on the right.
Answer
parent
- 45On average, lookup, insertion, and deletion in a binary search tree take time proportional to the_____of the number of stored items.
Hint
Binary search repeatedly eliminates about half the remaining tree.
Answer
logarithm
- 46In a binary search tree, duplicate data is not added when it is_____to an existing node.
Hint
The insertion logic handles values that are neither less nor greater.
Answer
equal
- 47The minimum value in a binary search tree is found by repeatedly following the_____child.
Hint
The smallest value is at the farthest position in the smaller-value direction.
Answer
left
- 48The maximum value in a binary search tree is found by repeatedly following the_____child.
Hint
The largest value is at the farthest position in the larger-value direction.
Answer
right
- 49The binary search tree find function returns a Boolean indicating whether the requested data is_____.
Hint
It answers whether the value occurs somewhere in the tree.
Answer
present
- 50Removing a leaf node from a binary search tree can be done by replacing that node with_____.
Hint
A leaf has no children to preserve.
Answer
null
- 51The distance from a tree's root node to a given leaf node is its_____.
Hint
Think of the number of levels from the top to the bottom.
Answer
height
- 52For a balanced tree, the minimum and maximum heights differ by at most_____.
Hint
The two paths are nearly the same length.
Answer
one
- 53Searching a balanced tree is more_____than searching a highly unbalanced tree.
Hint
Balanced branches reduce the amount of the tree that must be examined.
Answer
efficient
- 54In-order traversal visits a binary search tree's values from the leftmost node toward the_____node.
Hint
For a binary search tree, this produces sorted order.
Answer
rightmost
- 55Pre-order traversal processes a tree's_____nodes before their descendants.
Hint
The node is handled before the left and right recursive calls.
Answer
root
- 56Post-order traversal processes the_____nodes before their roots.
Hint
The recursive child calls occur before the current node is added.
Answer
leaf
- 57Level-order traversal is also called_____-first search.
Hint
It processes all nodes at one level before moving deeper.
Answer
breadth
- 58A linked list stores each element inside a_____.
Hint
Each node holds the value and a link.
Answer
node
- 59Each linked-list node contains the element and a reference to the_____node.
Hint
This reference points forward through the list.
Answer
next
- 60The pointer to the first node in a linked list is called the_____.
Hint
It marks where traversal begins.
Answer
head
- 61The next reference of the final node in a linked list points to_____.
Hint
There is no node after the final node.
Answer
null
- 62Unlike a traditionally fixed-size array, a linked list has a_____size.
Hint
Nodes can be added without preallocating a fixed capacity.
Answer
dynamic
- 63Compared with arrays, linked lists generally provide more efficient insertions and_____.
Hint
Changing links can avoid shifting many elements.
Answer
deletions
- 64Arrays provide random access, allowing a program to retrieve an item directly by its_____.
Hint
An array position such as 5 identifies the item.
Answer
index
- 65To reach index five in a linked list, the program must traverse the nodes_____.
Hint
It follows one next reference after another.
Answer
sequentially
- 66A linked list's size is tracked by its_____property.
Hint
This value increases when nodes are added.
Answer
length
- 67When removing the head node, the head pointer is changed to the current node's_____reference.
Hint
The second node becomes the new first node.
Answer
next
- 68A trie is sometimes called a_____tree.
Hint
Words sharing initial letters share paths.
Answer
prefix
- 69Each step or node in a trie generally represents one_____of a word.
Hint
A word is built one character at a time along a path.
Answer
letter
- 70Words in a trie branch when the order of their_____diverges.
Hint
Shared beginnings use the same path.
Answer
letters
- 71A marker indicating that a trie node ends a complete word is represented by the_____property.
Hint
It distinguishes a complete word from merely a prefix.
Answer
end
- 72The trie node structure uses a map called_____to connect letters to child nodes.
Hint
It stores letter-to-node key-value pairs.
Answer
keys
- 73A trie can validate dictionary membership efficiently because it checks one_____at a time.
Hint
The search follows the word's character path.
Answer
letter
- 74A binary heap is a partially ordered binary tree that satisfies the_____property.
Hint
This property defines the relationship between parents and children.
Answer
heap
- 75In a max-heap, every parent node is greater than or equal to its_____nodes.
Hint
The largest value is at the root.
Answer
child
- 76In a min-heap, every child node is greater than or equal to its_____node.
Hint
The smallest value is at the root.
Answer
parent
- 77A binary heap is a complete binary tree, meaning a partially filled last level is filled from_____to right.
Hint
New nodes occupy the earliest available positions.
Answer
left
- 78In an array representation of a heap, index zero is left as_____so the parent-child formulas work conveniently.
Hint
The first usable heap position is index one.
Answer
null
- 79For a heap element at index i, the left child is found at index_____.
Hint
Multiply the current index by two.
Answer
2i
- 80For a heap element at index i, the right child is found at index_____.
Hint
Start with the left-child formula and add one.
Answer
2i+1
- 81For a heap element at index i, the parent index is the floor of_____.
Hint
Divide the index by two and round down.
Answer
i/2
- 82When inserting into a min-heap, the new item is first placed at the_____of the array.
Hint
This preserves the complete-tree shape before reordering.
Answer
end
- 83When a newly inserted min-heap item is smaller than its parent, it is moved_____through the tree.
Hint
The item swaps with its parent.
Answer
up
- 84Removing from a min-heap returns the smallest item, which is stored at_____one.
Hint
The root is the first usable array position.
Answer
index
- 85Heap sort repeatedly removes values from a min-heap and places them into a new array in_____to greatest order.
Hint
The smallest remaining item is removed first.
Answer
least
- 86A hash table implements associative arrays or mappings of_____-value pairs.
Hint
A lookup identifier is paired with stored information.
Answer
key
- 87The average time complexity of hash-table search, insertion, and deletion is_____.
Hint
The average lookup time is constant with respect to the number of stored elements.
Answer
O(1)
- 88A hash function maps strings to_____that commonly correspond to array indexes.
Hint
The resulting value identifies a bucket.
Answer
numbers
- 89A hash function must be_____so the same key always produces the same number.
Hint
Repeated processing of an identical key must give an identical result.
Answer
consistent
- 90When two different keys produce the same hash-table index, the event is called a_____.
Hint
Two values have landed in the same bucket.
Answer
collision
- 91One way to handle a collision is to store multiple key-value pairs in the same_____.
Hint
A bucket is the collection at one array index.
Answer
bucket
- 92In the simple hash function, the final index is calculated using the hash value modulo the number of_____.
Hint
The remainder must fit within the storage array.
Answer
buckets
- 93If a hash table has five buckets, the possible indexes range from zero through_____.
Hint
Array indexing begins at zero.
Answer
four
- 94If a key already exists in a hash table, adding it should update its existing_____rather than create a duplicate entry.
Hint
The key identifies the stored information being replaced.
Answer
value
- 95When removing the only item in a hash-table bucket, the bucket's array index can be_____.
Hint
No other entries need to remain at that index.
Answer
deleted
- 96A graph's data points are called nodes or_____.
Hint
This is the formal graph-theory term for a node.
Answer
vertices
- 97The connections between graph nodes are called_____.
Hint
They represent relationships between vertices.
Answer
edges
- 98An undirected graph has edges without any_____.
Hint
The relationship works equally in both directions.
Answer
direction
- 99A directed graph has edges with a specified_____.
Hint
An edge can point from one node to another.
Answer
direction
- 100A social network can model people as nodes and their friendships as_____.
Hint
The relationships connect pairs of people.
Answer
edges
- 101A web page and its links to other pages are an example of a_____graph.
Hint
A link may point one way without a reciprocal link.
Answer
directed
- 102An adjacency list associates each vertex with its collection of neighboring_____.
Hint
It records which nodes are connected to each node.
Answer
vertices
- 103An adjacency matrix is a_____-dimensional array.
Hint
It consists of rows and columns.
Answer
two
- 104In an unweighted adjacency matrix, zero means no edge and one means a_____.
Hint
The one indicates that two nodes are connected.
Answer
relationship
- 105For a graph with three nodes, its adjacency matrix has dimensions_____by three.
Hint
The number of rows and columns matches the number of nodes.
Answer
three
- 106In an incidence matrix, rows represent nodes and columns represent unique_____.
Hint
This differs from an adjacency matrix, whose rows and columns both represent nodes.
Answer
edges
- 107In an undirected incidence matrix, an edge connecting two nodes is represented by a one in both corresponding_____.
Hint
Each connected node receives a one in that edge's column.
Answer
rows
- 108In a directed incidence matrix, an edge leaving a node is represented by_____.
Hint
The entering edge uses the negative value.
Answer
one
- 109In a directed incidence matrix, an edge entering a node is represented by_____one.
Hint
The sign distinguishes entering from leaving.
Answer
negative
- 110A graph edge with a numerical cost or distance is called a_____edge.
Hint
The edge stores more than simple presence or absence.
Answer
weighted
- 111Graph traversal algorithms are used to visit or_____graph nodes.
Hint
The word describes moving through the graph.
Answer
traverse
- 112The two main graph traversal methods discussed are breadth-first search and_____-first search.
Hint
This method explores one path as deeply as possible.
Answer
depth
- 113Breadth-first search first visits all neighbors that are_____edge away from the current node.
Hint
It explores the closest layer before moving farther.
Answer
one
- 114Breadth-first search is useful for determining how close nodes are to a_____node.
Hint
The search begins from this designated starting point.
Answer
root
- 115In the described BFS implementation, every node distance initially starts at_____.
Hint
This represents that a node has not yet been shown reachable.
Answer
infinity
- 116The distance from the BFS root node to itself is initialized to_____.
Hint
No edges must be traversed to reach the starting node.
Answer
zero
- 117BFS uses a simple_____to keep track of nodes waiting to be visited.
Hint
Nodes are processed in the order they are discovered.
Answer
queue
- 118The BFS loop continues while the queue contains nodes to_____.
Hint
The process ends when no waiting nodes remain.
Answer
traverse
- 119When BFS discovers a neighbor whose distance is still infinity, it sets that distance to the current distance plus_____.
Hint
Moving across one edge increases the distance by one hop.
Answer
one
- 120After assigning a distance to a newly discovered BFS neighbor, the neighbor is added to the_____.
Hint
It must later be processed to discover its own neighbors.
Answer
queue
- 121If a node remains at infinity after BFS completes, it is not_____from the start node.
Hint
No path was found from the selected root.
Answer
reachable
- 122The BFS result is an object whose keys identify nodes and whose values give their_____from the root.
Hint
The values count the number of hops.
Answer
distance

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