1. Home
  2. Explore
  3. Computer Science
  4. Java Data Structures and Algorithms

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Java Data Structures and Algorithms

  • 85Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Data Foundations
In the phrase “data structure,” the information that a computer stores is called
.

85 questions

  1. 1
    In 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.

  2. 2
    In 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.

  3. 3
    The 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.

  4. 4
    The 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.

  5. 5
    A 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.

  6. 6
    A 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.

  7. 7
    The 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.

  8. 8
    When 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.

  9. 9
    When 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.

  10. 10
    In 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.

  11. 11
    For 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.

  12. 12
    Using 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.

  13. 13
    In 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.

  14. 14
    In 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.

  15. 15
    To 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.

  16. 16
    Filling 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.

  17. 17
    A 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.

  18. 18
    The 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.

  19. 19
    A 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.

  20. 20
    The 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.

  21. 21
    The 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.

  22. 22
    The 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.

  23. 23
    The 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.

  24. 24
    In 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.

  25. 25
    The 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.

  26. 26
    A 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.

  27. 27
    In 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.

  28. 28
    In 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.

  29. 29
    Operating 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.

  30. 30
    One 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.

  31. 31
    The 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.

  32. 32
    A 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.

  33. 33
    In 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.

  34. 34
    A 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.

  35. 35
    The 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.

  36. 36
    In 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.

  37. 37
    Unlike 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.

  38. 38
    Linked-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.

  39. 39
    The 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.

  40. 40
    Nodes 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.

  41. 41
    Two 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.

  42. 42
    A 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.

  43. 43
    A 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.

  44. 44
    In 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.

  45. 45
    In 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.

  46. 46
    In-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.

  47. 47
    Preorder 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.

  48. 48
    Postorder 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.

  49. 49
    When 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.

  50. 50
    A 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.

  51. 51
    The 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.

  52. 52
    The 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.

  53. 53
    The 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.

  54. 54
    The worst-case time complexity of linear search is
    _____
    .
    Hint

    The work increases in proportion to the input length.

    Answer

    O(n)O(n)O(n)

    Explanation

    Linear search may inspect every element, so its worst-case time grows proportionally to the number of elements.

  55. 55
    The 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.

  56. 56
    For 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.

  57. 57
    The 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.

  58. 58
    The 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(log⁡n)O(\log n)O(logn)

    Explanation

    Each binary-search step roughly halves the remaining search interval, producing logarithmic worst-case time.

  59. 59
    In 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.

  60. 60
    The 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.

  61. 61
    A 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.

  62. 62
    The 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.

  63. 63
    The 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.

  64. 64
    The 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.

  65. 65
    The 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.

  66. 66
    The 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.

  67. 67
    In 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.

  68. 68
    The 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.

  69. 69
    The 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.

  70. 70
    In 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.

  71. 71
    The worst-case time complexity of QuickSort is
    _____
    .
    Hint

    Highly unbalanced partitions can make the work grow quadratically.

    Answer

    O(n2)O(n^2)O(n2)

    Explanation

    QuickSort’s worst case can occur when partitions are highly unbalanced, leading to quadratic time.

  72. 72
    The 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.

  73. 73
    A 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.

  74. 74
    Because 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.

  75. 75
    In 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.

  76. 76
    The 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.

  77. 77
    A 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.

  78. 78
    The 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.

  79. 79
    The 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.

  80. 80
    The 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.

  81. 81
    The 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.

  82. 82
    The 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.

  83. 83
    The 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.

  84. 84
    A 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.

  85. 85
    The 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.

1 of 85
Question 1 of 85

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent