1. Home
  2. Explore
  3. Computer Science
  4. JavaScript Data Structures

Study methods

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

JavaScript Data Structures

  • 122Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Stack Concepts
A stack of books illustrates which access pattern, in which the last item added is the first item removed?

122 questions

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

  2. 2
    In a stack, adding an item to the top is called
    _____
    .
    Hint

    This operation places new data onto the stack.

    Answer

    push

  3. 3
    In a stack, removing and returning the top item is called
    _____
    .
    Hint

    This operation removes the most recently added item.

    Answer

    pop

  4. 4
    The stack operation that displays the top element without removing it is called
    _____
    .
    Hint

    Unlike pop, this operation leaves the stack unchanged.

    Answer

    peek

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

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

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

  8. 8
    A word that is spelled the same forwards and backwards is called a
    _____
    .
    Hint

    Examples include Bob and racecar.

    Answer

    palindrome

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

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

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

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

  13. 13
    A set differs from an ordinary array because it does not allow
    _____
    items.
    Hint

    Every value can occur at most once.

    Answer

    duplicate

  14. 14
    Unlike an array, the values in a set are not stored in any particular
    _____
    .
    Hint

    Set membership matters more than sequence.

    Answer

    order

  15. 15
    The main typical use of a set is checking for the
    _____
    of an item.
    Hint

    The question is whether a value is included.

    Answer

    presence

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

  17. 17
    The set method that returns all stored values is called
    _____
    .
    Hint

    It exposes the collection of elements.

    Answer

    values

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

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

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

  21. 21
    In an ES6 Set, size is a property rather than a
    _____
    .
    Hint

    It is accessed without parentheses.

    Answer

    method

  22. 22
    The union of two sets contains all values from both sets while leaving out
    _____
    .
    Hint

    The result contains each value only once.

    Answer

    duplicates

  23. 23
    The intersection of two sets contains values that occur in
    _____
    sets.
    Hint

    These are the elements shared by the two collections.

    Answer

    both

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

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

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

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

  28. 28
    A print queue normally processes documents in the order in which they were
    _____
    to the queue.
    Hint

    Earlier submitted documents are printed earlier.

    Answer

    sent

  29. 29
    The queue operation that adds an item is called
    _____
    .
    Hint

    It places an element at the back of the queue.

    Answer

    enqueue

  30. 30
    The queue operation that removes an item from the front is called
    _____
    .
    Hint

    It removes the oldest element.

    Answer

    dequeue

  31. 31
    In the described array implementation, enqueue adds items at the
    _____
    of the array.
    Hint

    The implementation uses push for insertion.

    Answer

    end

  32. 32
    In the described array implementation, dequeue removes items from the
    _____
    of the array.
    Hint

    The implementation uses shift for removal.

    Answer

    beginning

  33. 33
    The queue method that returns the front item without removing it is called
    _____
    .
    Hint

    It reads the element at index zero.

    Answer

    front

  34. 34
    A queue is empty when its collection length is equal to
    _____
    .
    Hint

    No elements remain in the collection.

    Answer

    zero

  35. 35
    A priority queue stores both an element and its
    _____
    .
    Hint

    This extra value determines placement in the queue.

    Answer

    priority

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

  37. 37
    When two priority-queue elements have the same priority, they are processed like a normal
    _____
    .
    Hint

    Their insertion order is preserved.

    Answer

    queue

  38. 38
    In a tree, every data point is called a
    _____
    .
    Hint

    It is the basic unit that stores data.

    Answer

    node

  39. 39
    The top node of a tree is called the
    _____
    node.
    Hint

    All other branches descend from this node.

    Answer

    root

  40. 40
    A node with branches leading to other nodes is the
    _____
    of those nodes.
    Hint

    The connected nodes below it are its children.

    Answer

    parent

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

  42. 42
    A binary tree allows each node to have at most
    _____
    branches.
    Hint

    The word binary refers to this limit.

    Answer

    two

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

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

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

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

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

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

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

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

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

  52. 52
    For a balanced tree, the minimum and maximum heights differ by at most
    _____
    .
    Hint

    The two paths are nearly the same length.

    Answer

    one

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

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

  55. 55
    Pre-order traversal processes a tree's
    _____
    nodes before their descendants.
    Hint

    The node is handled before the left and right recursive calls.

    Answer

    root

  56. 56
    Post-order traversal processes the
    _____
    nodes before their roots.
    Hint

    The recursive child calls occur before the current node is added.

    Answer

    leaf

  57. 57
    Level-order traversal is also called
    _____
    -first search.
    Hint

    It processes all nodes at one level before moving deeper.

    Answer

    breadth

  58. 58
    A linked list stores each element inside a
    _____
    .
    Hint

    Each node holds the value and a link.

    Answer

    node

  59. 59
    Each linked-list node contains the element and a reference to the
    _____
    node.
    Hint

    This reference points forward through the list.

    Answer

    next

  60. 60
    The pointer to the first node in a linked list is called the
    _____
    .
    Hint

    It marks where traversal begins.

    Answer

    head

  61. 61
    The next reference of the final node in a linked list points to
    _____
    .
    Hint

    There is no node after the final node.

    Answer

    null

  62. 62
    Unlike a traditionally fixed-size array, a linked list has a
    _____
    size.
    Hint

    Nodes can be added without preallocating a fixed capacity.

    Answer

    dynamic

  63. 63
    Compared with arrays, linked lists generally provide more efficient insertions and
    _____
    .
    Hint

    Changing links can avoid shifting many elements.

    Answer

    deletions

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

  65. 65
    To reach index five in a linked list, the program must traverse the nodes
    _____
    .
    Hint

    It follows one next reference after another.

    Answer

    sequentially

  66. 66
    A linked list's size is tracked by its
    _____
    property.
    Hint

    This value increases when nodes are added.

    Answer

    length

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

  68. 68
    A trie is sometimes called a
    _____
    tree.
    Hint

    Words sharing initial letters share paths.

    Answer

    prefix

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

  70. 70
    Words in a trie branch when the order of their
    _____
    diverges.
    Hint

    Shared beginnings use the same path.

    Answer

    letters

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

  72. 72
    The trie node structure uses a map called
    _____
    to connect letters to child nodes.
    Hint

    It stores letter-to-node key-value pairs.

    Answer

    keys

  73. 73
    A trie can validate dictionary membership efficiently because it checks one
    _____
    at a time.
    Hint

    The search follows the word's character path.

    Answer

    letter

  74. 74
    A binary heap is a partially ordered binary tree that satisfies the
    _____
    property.
    Hint

    This property defines the relationship between parents and children.

    Answer

    heap

  75. 75
    In a max-heap, every parent node is greater than or equal to its
    _____
    nodes.
    Hint

    The largest value is at the root.

    Answer

    child

  76. 76
    In a min-heap, every child node is greater than or equal to its
    _____
    node.
    Hint

    The smallest value is at the root.

    Answer

    parent

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

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

  79. 79
    For a heap element at index iii, the left child is found at index
    _____
    .
    Hint

    Multiply the current index by two.

    Answer

    2i2i2i

  80. 80
    For a heap element at index iii, the right child is found at index
    _____
    .
    Hint

    Start with the left-child formula and add one.

    Answer

    2i+12i + 12i+1

  81. 81
    For a heap element at index iii, the parent index is the floor of
    _____
    .
    Hint

    Divide the index by two and round down.

    Answer

    i/2i / 2i/2

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

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

  84. 84
    Removing from a min-heap returns the smallest item, which is stored at
    _____
    one.
    Hint

    The root is the first usable array position.

    Answer

    index

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

  86. 86
    A hash table implements associative arrays or mappings of
    _____
    -value pairs.
    Hint

    A lookup identifier is paired with stored information.

    Answer

    key

  87. 87
    The 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)O(1)O(1)

  88. 88
    A hash function maps strings to
    _____
    that commonly correspond to array indexes.
    Hint

    The resulting value identifies a bucket.

    Answer

    numbers

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

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

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

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

  93. 93
    If a hash table has five buckets, the possible indexes range from zero through
    _____
    .
    Hint

    Array indexing begins at zero.

    Answer

    four

  94. 94
    If 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

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

  96. 96
    A graph's data points are called nodes or
    _____
    .
    Hint

    This is the formal graph-theory term for a node.

    Answer

    vertices

  97. 97
    The connections between graph nodes are called
    _____
    .
    Hint

    They represent relationships between vertices.

    Answer

    edges

  98. 98
    An undirected graph has edges without any
    _____
    .
    Hint

    The relationship works equally in both directions.

    Answer

    direction

  99. 99
    A directed graph has edges with a specified
    _____
    .
    Hint

    An edge can point from one node to another.

    Answer

    direction

  100. 100
    A social network can model people as nodes and their friendships as
    _____
    .
    Hint

    The relationships connect pairs of people.

    Answer

    edges

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

  102. 102
    An adjacency list associates each vertex with its collection of neighboring
    _____
    .
    Hint

    It records which nodes are connected to each node.

    Answer

    vertices

  103. 103
    An adjacency matrix is a
    _____
    -dimensional array.
    Hint

    It consists of rows and columns.

    Answer

    two

  104. 104
    In an unweighted adjacency matrix, zero means no edge and one means a
    _____
    .
    Hint

    The one indicates that two nodes are connected.

    Answer

    relationship

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

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

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

  108. 108
    In a directed incidence matrix, an edge leaving a node is represented by
    _____
    .
    Hint

    The entering edge uses the negative value.

    Answer

    one

  109. 109
    In a directed incidence matrix, an edge entering a node is represented by
    _____
    one.
    Hint

    The sign distinguishes entering from leaving.

    Answer

    negative

  110. 110
    A graph edge with a numerical cost or distance is called a
    _____
    edge.
    Hint

    The edge stores more than simple presence or absence.

    Answer

    weighted

  111. 111
    Graph traversal algorithms are used to visit or
    _____
    graph nodes.
    Hint

    The word describes moving through the graph.

    Answer

    traverse

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

  113. 113
    Breadth-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

  114. 114
    Breadth-first search is useful for determining how close nodes are to a
    _____
    node.
    Hint

    The search begins from this designated starting point.

    Answer

    root

  115. 115
    In the described BFS implementation, every node distance initially starts at
    _____
    .
    Hint

    This represents that a node has not yet been shown reachable.

    Answer

    infinity

  116. 116
    The distance from the BFS root node to itself is initialized to
    _____
    .
    Hint

    No edges must be traversed to reach the starting node.

    Answer

    zero

  117. 117
    BFS uses a simple
    _____
    to keep track of nodes waiting to be visited.
    Hint

    Nodes are processed in the order they are discovered.

    Answer

    queue

  118. 118
    The BFS loop continues while the queue contains nodes to
    _____
    .
    Hint

    The process ends when no waiting nodes remain.

    Answer

    traverse

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

  120. 120
    After 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

  121. 121
    If 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

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

1 of 122
Question 1 of 122

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent