Java Data Structures and Algorithms
- 85Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
85 questions
- 1In the phrase “data structure,” the information that a computer stores is called_____.
Hint
It is the information that a computer stores.
Answer
data
Explanation
Data is the information a computer stores; a data structure defines how that information is arranged.
- 2In a data structure, the way information is arranged in a computer is its_____.
Hint
Think about the way information is organized.
Answer
structure
Explanation
A structure describes how data is arranged in a computer.
- 3The organization of stored information, together with the information itself, is described by_____.
Hint
These choices determine how information is organized and used.
Answer
data structures
Explanation
Choosing how data is arranged can affect algorithm efficiency, memory use, and CPU use.
- 4The measure used to describe how an algorithm’s running time grows with input size is_____.
Hint
It concerns how much time an algorithm takes as the problem grows.
Answer
time complexity
Explanation
Time complexity describes how the work or running time of an algorithm changes with the size of its input.
- 5A structure that stores elements sequentially, one after another, is a_____.
Hint
Its elements follow an ordered sequence rather than a hierarchy.
Answer
linear data structure
Explanation
A linear data structure arranges its elements sequentially, one after another.
- 6A structure that can arrange data hierarchically rather than in one sequence is a_____.
Hint
Trees and graphs are examples of this broad category.
Answer
non-linear data structure
Explanation
A non-linear data structure can organize elements hierarchically or in other arrangements that are not a single sequence.
- 7The memory requirement that distinguishes arrays from linked lists is_____.
Hint
The required locations must be adjacent rather than scattered.
Answer
contiguous memory allocation
Explanation
An array requires its elements to occupy a continuous block of memory.
- 8When available memory is scattered into separate chunks, a linked list can still use that memory_____.
Hint
Linked lists can make use of scattered free memory locations.
Answer
memory efficiently
Explanation
A linked list can use separate available memory chunks, while an array requires one contiguous block.
- 9When all values in an array must be of the same data type, the array’s contents are_____.
Hint
The elements share the same kind of data.
Answer
homogeneous
Explanation
An array stores elements of a single data type, so its elements are homogeneous.
- 10In Java, the index of the first element in an array is_____.
Hint
The first index is one less than the number one.
Answer
zero
Explanation
Java arrays use zero-based indexing, so the first element is at index zero.
- 11For an array, the elements occupy_____.
Hint
An array’s memory locations are adjacent.
Answer
contiguous memory locations
Explanation
Array elements are stored one after another in a continuous region of memory.
- 12Using an index to access an array element directly is called_____.
Hint
The index allows direct access to a position.
Answer
random access
Explanation
An array’s index lets a program directly access a chosen position without traversing all earlier elements.
- 13In the array address calculation described, the starting address is represented by_____.
Hint
It refers to the beginning of the array in memory.
Answer
the array name
Explanation
In the address calculation described in the content, the array name represents the starting address of the array.
- 14In the address example, accessing the next integer array element advances by_____.
Hint
Use the size assumed for an integer in the example.
Answer
four bytes
Explanation
The example assumes an integer occupies four bytes, so moving one array index advances the address by four bytes.
- 15To access an element of a two-dimensional array, Java uses_____.
Hint
A table uses a row position and a column position.
Answer
two subscripts
Explanation
A two-dimensional array is accessed using two indices, one for each dimension.
- 16Filling a two-dimensional array across each row before moving to the next follows a_____order.
Hint
The traversal completes one row before moving to another.
Answer
row-major
Explanation
The example fills a two-dimensional array by moving across each row before proceeding to the next row.
- 17A linked list’s ability to grow or shrink as needed is called its_____.
Hint
Its capacity changes as the number of nodes changes.
Answer
dynamic size
Explanation
Unlike an array with a fixed capacity, a linked list can grow or shrink as nodes are added or removed.
- 18The array operations that may require shifting other elements are_____.
Hint
These operations can require moving neighboring array elements.
Answer
insertion and deletion
Explanation
In an array, inserting or deleting an element may require shifting other elements, making these operations difficult.
- 19A stack follows the principle of_____.
Hint
The top item is the newest item and is removed first.
Answer
last in, first out
Explanation
A stack removes the most recently inserted element before elements beneath it.
- 20The stack position used to track the accessible element is called the_____.
Hint
It tracks the accessible end of the stack.
Answer
top
Explanation
A stack’s top identifies the end from which elements are inserted and removed.
- 21The stack operation used to insert an element is called_____.
Hint
It adds an item to the stack.
Answer
push
Explanation
The push operation inserts an element at the top of a stack.
- 22The stack operation used to remove the top element is called_____.
Hint
It removes the item currently at the stack’s accessible end.
Answer
pop
Explanation
The pop operation removes the top element of a stack.
- 23The stack operation that examines the top element without removing it is_____.
Hint
It lets you inspect the top item while leaving it in place.
Answer
peek
Explanation
Peek returns or examines the top element without removing it.
- 24In the described stack implementation, push and pop each take_____.
Hint
The operation time does not grow with the number of stack elements.
Answer
constant time
Explanation
Stack push and pop operations access only the top, so they take constant time in the described implementation.
- 25The programming technique whose function calls are managed internally with a stack is_____.
Hint
A function calls itself, and its pending calls are tracked internally.
Answer
recursion
Explanation
Recursive calls are managed using a stack of activation records, which tracks calls that have not yet returned.
- 26A queue follows the principle of_____.
Hint
The earliest arrival is served first.
Answer
first in, first out
Explanation
A queue removes elements in the same order in which they were inserted.
- 27In a queue, new elements are inserted at the_____.
Hint
New arrivals join at this end of the queue.
Answer
rear
Explanation
In the described queue, insertion happens at the rear.
- 28In a queue, elements are deleted from the_____.
Hint
The element that has waited longest is removed from this end.
Answer
front
Explanation
In the described queue, deletion happens at the front.
- 29Operating systems use queues in process_____.
Hint
Operating systems use queues to organize which processes run.
Answer
scheduling algorithms
Explanation
Queues are used in operating-system scheduling, including first-in, first-out and round-robin scheduling.
- 30One application of queues in operating systems is_____.
Hint
It organizes work waiting for an interrupt-related task to finish.
Answer
interrupt handling
Explanation
A queue can hold processes waiting while an interrupt is handled, allowing them to be processed afterward.
- 31The reference to the first node of a linked list is called the_____.
Hint
It points to the beginning of the list.
Answer
head
Explanation
The head is the reference to the first node of a linked list and is needed to access the list.
- 32A singly linked-list node contains_____.
Hint
One part stores the value; the other points onward.
Answer
data and a link
Explanation
A singly linked-list node contains its stored value and a link to the next node.
- 33In a singly linked list, the link field stores_____.
Hint
This is what lets traversal continue through the list.
Answer
the address of the next node
Explanation
The link field in a singly linked list points to the next node.
- 34A doubly linked-list node links to_____.
Hint
One link supports backward movement and the other supports forward movement.
Answer
the previous and next nodes
Explanation
A doubly linked-list node has links that allow traversal in both directions.
- 35The next link of the last node in a standard singly linked list is_____.
Hint
This value marks the end when there is no next node.
Answer
null
Explanation
In a singly linked list, the final node’s next link is null because there is no following node.
- 36In a circular linked list, the last node’s link points to_____.
Hint
The last node loops back to the beginning.
Answer
the head
Explanation
In a circular linked list, the last node links back to the first node, which is referenced by the head.
- 37Unlike arrays, linked lists do not support_____; nodes must be traversed sequentially.
Hint
To reach a later node, you must follow earlier links.
Answer
random access
Explanation
Linked lists do not support direct indexed access in the way arrays do; nodes must be traversed in sequence.
- 38Linked-list insertion and deletion can often be performed by_____instead of shifting many elements.
Hint
The operation changes connections between nodes rather than moving every later element.
Answer
manipulating links
Explanation
Insertion and deletion in a linked list can often be done by changing links rather than shifting many elements.
- 39The topmost node in a tree is called the_____.
Hint
It is the starting node from which the tree branches.
Answer
root
Explanation
The root is the first or topmost node of a tree.
- 40Nodes in a tree that have no children are called_____.
Hint
They are the terminal nodes at the ends of branches.
Answer
leaf nodes
Explanation
Leaf nodes have no children.
- 41Two tree nodes with the same parent are called_____.
Hint
They have a common parent.
Answer
siblings
Explanation
Nodes that share the same parent are siblings.
- 42A node in a binary tree can have at most_____children.
Hint
The prefix “bi” indicates the maximum number of children per node.
Answer
two
Explanation
A binary tree restricts each node to at most two children.
- 43A binary tree that places smaller values on the left and larger values on the right is a_____.
Hint
This binary-tree variant organizes values to support searching.
Answer
binary search tree
Explanation
In a binary search tree, smaller values go in the left subtree and larger values go in the right subtree.
- 44In a binary search tree, values smaller than a node belong in its_____.
Hint
Compare the value with its parent: smaller values go to this side.
Answer
left subtree
Explanation
For the binary search tree property described, values smaller than a node belong in its left subtree.
- 45In a binary search tree, values larger than a node belong in its_____.
Hint
Compare the value with its parent: larger values go to this side.
Answer
right subtree
Explanation
For the binary search tree property described, values larger than a node belong in its right subtree.
- 46In-order traversal visits nodes in the sequence_____.
Hint
The root is visited between its two subtrees.
Answer
left, root, right
Explanation
In-order traversal visits the left subtree, then the root, and then the right subtree.
- 47Preorder traversal visits nodes in the sequence_____.
Hint
The root is visited before either subtree.
Answer
root, left, right
Explanation
Preorder traversal visits the root before its left and right subtrees.
- 48Postorder traversal visits nodes in the sequence_____.
Hint
The root is visited after both subtrees.
Answer
left, right, root
Explanation
Postorder traversal visits the left subtree and right subtree before the root.
- 49When applied to a binary search tree, in-order traversal produces values in_____.
Hint
The left-root-right order respects the tree’s smaller-left, larger-right property.
Answer
increasing order
Explanation
In-order traversal of a binary search tree visits its values in increasing order.
- 50A step-by-step approach for solving a problem is an_____.
Hint
It specifies a sequence of steps for reaching a solution.
Answer
algorithm
Explanation
An algorithm is a step-by-step approach to solving a problem.
- 51The measure of how an algorithm’s operation count grows with input size is its_____.
Hint
It concerns the growth of an algorithm’s work as more data is processed.
Answer
time complexity
Explanation
Time complexity measures how the number of operations grows as input size changes.
- 52The measure of an algorithm’s memory requirements is its_____.
Hint
It concerns how much memory an algorithm uses.
Answer
space complexity
Explanation
Space complexity describes the memory required by an algorithm, including auxiliary memory.
- 53The analysis that considers an algorithm’s maximum resource requirements is the_____.
Hint
It considers the most demanding input situation.
Answer
worst case
Explanation
Worst-case analysis estimates the maximum resources an algorithm may require for inputs of a given size.
- 54The worst-case time complexity of linear search is_____.
Hint
The work increases in proportion to the input length.
Answer
O(n)
Explanation
Linear search may inspect every element, so its worst-case time grows proportionally to the number of elements.
- 55The described linear-search implementation uses_____.
Hint
Its extra memory does not grow with the number of array elements.
Answer
constant space
Explanation
The described linear-search implementation examines the given array without creating an additional data structure that grows with the input.
- 56For standard binary search, the input array must be_____.
Hint
The array’s order makes it possible to choose which half to search.
Answer
sorted
Explanation
Binary search relies on an ordering that lets it discard the half that cannot contain the target.
- 57The strategy used by binary search is_____.
Hint
The algorithm reduces a problem by splitting its search space.
Answer
divide and conquer
Explanation
Binary search repeatedly halves its search interval and continues in the half that can contain the target.
- 58The worst-case time complexity of binary search is_____.
Hint
The number of steps grows with the number of times the input can be halved.
Answer
O(logn)
Explanation
Each binary-search step roughly halves the remaining search interval, producing logarithmic worst-case time.
- 59In the described linear-search method, the return value indicating that a key was not found is_____.
Hint
It is a sentinel value indicating that no matching index exists.
Answer
minus one
Explanation
The described search method returns minus one when it scans the array without finding the target.
- 60The approach that repeatedly chooses a locally optimal feasible option is called_____.
Hint
It makes an appealing choice at each stage rather than reconsidering all earlier choices.
Answer
greedy programming
Explanation
Greedy programming chooses a locally best feasible option at each step in an attempt to build a solution.
- 61A greedy algorithm chooses a_____optimum at each step, which may not be the overall best solution.
Hint
It describes a choice that is best at the current stage, not necessarily overall.
Answer
local
Explanation
A greedy algorithm selects the best available choice for the current step, which is a local optimum and may not be globally optimal.
- 62The approach that reuses previously computed subproblem solutions is_____.
Hint
Past subproblem results are stored and reused.
Answer
dynamic programming
Explanation
Dynamic programming uses results from previously solved subproblems when finding solutions to later subproblems.
- 63The method of exploring possible paths and retreating from unsuccessful choices is_____.
Hint
When a choice reaches a dead end, the method retreats to try another.
Answer
backtracking
Explanation
Backtracking explores possible paths and returns to earlier choices when a path cannot lead to a solution.
- 64The condition that terminates recursive calls is the_____.
Hint
It identifies when recursion should stop rather than make another call.
Answer
base condition
Explanation
A base condition stops recursive calls from continuing indefinitely.
- 65The records created to track active recursive function calls are called_____.
Hint
These records store information about function calls that are still in progress.
Answer
activation records
Explanation
Each active function call has an activation record that keeps information needed to resume the call when a deeper call returns.
- 66The knapsack variant that allows selecting part of an item is the_____.
Hint
Unlike the zero-one version, this problem permits taking part of an item.
Answer
fractional knapsack problem
Explanation
In the fractional version, a fraction of an item may be selected when its full weight does not fit.
- 67In the fractional knapsack method described, items are ranked using the ratio_____.
Hint
Compare the gain from an item with the amount of capacity it uses.
Answer
profit by weight
Explanation
The described greedy solution ranks items by their profit-to-weight ratio before selecting them.
- 68The fractional knapsack method arranges profit-to-weight ratios in_____before selecting items.
Hint
The largest ratios are considered first.
Answer
descending order
Explanation
After calculating each item’s profit-to-weight ratio, the method considers items from the highest ratio to the lowest.
- 69The sorting algorithm that partitions an array around a pivot is_____.
Hint
Its partitioning step is organized around a chosen value.
Answer
QuickSort
Explanation
QuickSort selects a pivot and partitions values so that smaller values lie on one side and larger values on the other.
- 70In QuickSort, the element used to divide values into smaller and larger groups is the_____.
Hint
It is the chosen element that divides the array into two sides.
Answer
pivot
Explanation
The pivot is the value used to partition the array; after partitioning, it is placed between values smaller and larger than it.
- 71The worst-case time complexity of QuickSort is_____.
Hint
Highly unbalanced partitions can make the work grow quadratically.
Answer
O(n2)
Explanation
QuickSort’s worst case can occur when partitions are highly unbalanced, leading to quadratic time.
- 72The divide-and-conquer sorting algorithm that combines sorted subarrays is_____.
Hint
Its name reflects the operation that combines sorted subarrays.
Answer
merge sort
Explanation
Merge sort divides an array into smaller parts, sorts them, and merges the sorted parts.
- 73A sorting algorithm that preserves the relative order of equal elements is_____.
Hint
Equal keys retain their original relative order.
Answer
stable
Explanation
A stable sort preserves the relative order of equal-valued elements from the original input.
- 74Because the described merge sort uses additional arrays, it is an_____algorithm.
Hint
It uses extra memory instead of rearranging everything only within the original array.
Answer
out-of-place
Explanation
The described merge sort uses additional arrays to merge values, so it requires auxiliary space rather than sorting entirely in place.
- 75In graph terminology, a node is also called a_____.
Hint
It is one of the points that an edge can connect.
Answer
vertex
Explanation
A graph consists of vertices, also called nodes, connected by edges.
- 76The connection between two vertices in a graph is an_____.
Hint
It is the connection drawn between two graph points.
Answer
edge
Explanation
An edge connects two vertices and represents a relationship between them.
- 77A graph whose edges indicate direction is a_____.
Hint
Its edges have an orientation.
Answer
directed graph
Explanation
A directed graph has edges with specified directions, so a connection from one vertex to another does not necessarily imply a connection in reverse.
- 78The graph representation that stores connections in a two-dimensional array is an_____.
Hint
It records vertex-to-vertex connections in rows and columns.
Answer
adjacency matrix
Explanation
An adjacency matrix represents which pairs of vertices are connected using a two-dimensional array.
- 79The graph representation that stores each vertex’s neighboring vertices is an_____.
Hint
Each vertex has a collection of its neighbors.
Answer
adjacency list
Explanation
An adjacency list records, for each vertex, the vertices connected to it.
- 80The graph traversal that visits vertices level by level is_____.
Hint
It explores across a level before proceeding deeper.
Answer
breadth-first search
Explanation
Breadth-first search visits vertices level by level, exploring neighbors before moving farther away.
- 81The data structure used to manage the order of vertices in breadth-first search is a_____.
Hint
The next vertex processed is the one that was added earliest.
Answer
queue
Explanation
Breadth-first search uses a queue to process discovered vertices in first-in, first-out order.
- 82The graph traversal that explores a path deeply before backtracking is_____.
Hint
It explores deeply along one route before returning to alternatives.
Answer
depth-first search
Explanation
Depth-first search follows a path as far as possible before backtracking to explore another path.
- 83The data structure used in the described depth-first search implementation is a_____.
Hint
This data structure supports returning to the most recently reached branch.
Answer
stack
Explanation
Depth-first search can use a stack to track vertices to visit, following last-in, first-out order.
- 84A spanning tree with minimum total edge weight is a_____.
Hint
It is a spanning tree with the least possible sum of edge weights.
Answer
minimum spanning tree
Explanation
A minimum spanning tree connects all vertices without cycles while minimizing the total edge weight.
- 85The minimum-spanning-tree algorithm that expands from a starting vertex by choosing a light edge is_____.
Hint
It builds outward from a selected starting vertex.
Answer
Prim’s algorithm
Explanation
Prim’s algorithm grows a spanning tree from a starting vertex by repeatedly choosing a minimum-weight edge that expands the tree.

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