1. Home
  2. Explore
  3. Computer Science
  4. Computer Memory and Arrays

Study methods

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

Computer Memory and Arrays

  • 60Unfamiliar
  • 0Learning
  • 0Familiar
  • 0Mastered
Topic: Memory Foundations

Conceptually, what is computer memory most like?

60 questions

  1. 1

    Conceptually, what is computer memory most like?

    1. A

      A network of objects that cannot be accessed directly

    2. B

      A processor register that stores one value at a time

    3. C

      A linear array of individually addressable storage locations

    4. D

      A hierarchy of files organized only by their names

    Correct answer
    C

    A linear array of individually addressable storage locations

    Explanation

    Computer memory can be modeled as a large array of small storage locations, each identified by an address.

  2. 2

    What are the two fundamental operations supported by the memory interface?

    1. A

      Sorting data by address and deleting unused addresses

    2. B

      Writing data to an address and reading data from an address

    3. C

      Moving data automatically and repairing damaged values

    4. D

      Compressing data and encrypting its contents

    Correct answer
    B

    Writing data to an address and reading data from an address

    Explanation

    At the fundamental level, memory allows programs to write data to a particular address and read data from a particular address.

  3. 3

    In the array model of memory, what does a memory address represent?

    1. A

      An index into the array representing memory

    2. B

      The value currently stored in the entire array

    3. C

      The number of bytes allocated to a program

    4. D

      A description of the data type stored at the address

    Correct answer
    A

    An index into the array representing memory

    Explanation

    A memory address is another way of describing an index into the array that represents memory.

  4. 4

    Why can every program ultimately be viewed as using array operations?

    1. A

      Arrays automatically determine the best organization for every data set

    2. B

      All program data is built on memory, which supports indexed reads and writes

    3. C

      Programs are unable to store data outside the processor

    4. D

      Every programming language exposes only arrays to its users

    Correct answer
    B

    All program data is built on memory, which supports indexed reads and writes

    Explanation

    Because memory is modeled as an array and provides indexed reads and writes, higher-level data access strategies are built on those operations.

  5. 5

    How many possible orders are there for three distinct elements?

    1. A

      Six possible orders

    2. B

      One possible order

    3. C

      Nine possible orders

    4. D

      Three possible orders

    Correct answer
    A

    Six possible orders

    Explanation

    The number of arrangements of three distinct elements is 3!=63! = 63!=6.

  6. 6

    What mathematical concept describes the number of possible arrangements of elements in an array?

    1. A

      A remainder of the number of elements

    2. B

      A logarithm of the number of elements

    3. C

      A factorial of the number of elements

    4. D

      A square of the number of elements

    Correct answer
    C

    A factorial of the number of elements

    Explanation

    The number of possible arrangements of nnn distinct elements is described by the factorial n!n!n!.

  7. 7

    Why does checking an unsorted million-character array for a particular character require potentially examining every element?

    1. A

      The character can occur only at the final index

    2. B

      The array cannot be read at arbitrary indexes

    3. C

      No ordering information allows the search to eliminate unexamined elements

    4. D

      The array must be copied before any search can begin

    Correct answer
    C

    No ordering information allows the search to eliminate unexamined elements

    Explanation

    With no useful ordering, the search may need to inspect every character before finding the target or determining that it is absent.

  8. 8

    If characters are sorted in ascending alphabetical order, how can the presence of Z be checked most directly?

    1. A

      Inspect the first element of the array

    2. B

      Randomly inspect indexes until Z appears

    3. C

      Count every character before comparing them

    4. D

      Inspect the final element of the array

    Correct answer
    D

    Inspect the final element of the array

    Explanation

    In ascending alphabetical order, Z is the greatest possible character, so it can occur only at the end. The final element therefore determines whether Z is present.

  9. 9

    Why does sorting characters by frequency help find the most frequent character?

    1. A

      Sorting causes every character to occupy the same number of positions

    2. B

      The most frequent character is placed at a known position, such as the beginning

    3. C

      The most frequent character is always alphabetically last

    4. D

      Sorting removes all repeated characters from the array

    Correct answer
    B

    The most frequent character is placed at a known position, such as the beginning

    Explanation

    If elements are ordered by frequency, the most frequent character is placed at the beginning, making it immediately accessible.

  10. 10

    What is the central task underlying data access strategies in programming?

    1. A

      Converting every object into a character

    2. B

      Ensuring that all data is stored in alphabetical order

    3. C

      Determining the array index where the desired data can be found

    4. D

      Increasing the physical size of memory before each access

    Correct answer
    C

    Determining the array index where the desired data can be found

    Explanation

    Since array-based memory provides indexed access, data structures ultimately need a strategy for determining an appropriate array index.

  11. 11

    What two components define a data structure?

    1. A

      The data type and the amount of available memory

    2. B

      The ordering of elements and the logic for operating on them

    3. C

      The programming language and the processor architecture

    4. D

      The user interface and the input device

    Correct answer
    B

    The ordering of elements and the logic for operating on them

    Explanation

    A data structure consists of an arrangement or ordering of elements and logic for operations such as finding, inserting, and removing elements.

  12. 12

    What is a sorted array an example of?

    1. A

      A data structure organized to support access through sorted order

    2. B

      A memory system that cannot perform indexed reads

    3. C

      A linked structure in which every item has multiple parents

    4. D

      A queue that removes items from both ends simultaneously

    Correct answer
    A

    A data structure organized to support access through sorted order

    Explanation

    A sorted array is a data structure whose elements are arranged according to their values or a selected ordering criterion.

  13. 13

    How might an array of user objects be sorted for efficient lookup?

    1. A

      By a selected field such as the user's ID

    2. B

      By assigning every user the same array index

    3. C

      By deleting all fields except the user's name

    4. D

      Only by the physical address of the computer

    Correct answer
    A

    By a selected field such as the user's ID

    Explanation

    Composite objects can be sorted using a subfield, such as a user's ID, rather than the entire object as a single value.

  14. 14

    Why might a system maintain separate arrays of indexes for users?

    1. A

      To prevent users from being stored in the main array

    2. B

      To duplicate every user object in several physical locations

    3. C

      To make all lookups independent of the user's data

    4. D

      To support different orderings, such as lookup by name and by ID

    Correct answer
    D

    To support different orderings, such as lookup by name and by ID

    Explanation

    Separate index arrays can be sorted by different fields while pointing to the same underlying user objects.

  15. 15

    In the library analogy, what does a pointer most closely represent?

    1. A

      Directions to the stable location of the actual data

    2. B

      A complete duplicate of the physical book

    3. C

      A record that stores only the book's genre

    4. D

      A new building containing books in another order

    Correct answer
    A

    Directions to the stable location of the actual data

    Explanation

    A pointer identifies where the actual data is located, much like a library system returns directions to a book on a shelf.

  16. 16

    What distinguishes an array list from a basic fixed-length array?

    1. A

      An array list cannot read or write arbitrary indexes

    2. B

      An array list always removes elements without shifting any data

    3. C

      An array list can add elements and track a changing logical length

    4. D

      An array list stores elements without using memory addresses

    Correct answer
    C

    An array list can add elements and track a changing logical length

    Explanation

    An array list supports indexed access like an array but also provides operations such as adding and removing elements while maintaining a logical size.

  17. 17

    What is the capacity of an array list?

    1. A

      The number of elements removed since creation

    2. B

      The index of the first element in the list

    3. C

      The length of its underlying backing array

    4. D

      The number of elements currently stored in the list

    Correct answer
    C

    The length of its underlying backing array

    Explanation

    Capacity refers to the length of the backing array, which can be larger than the list's current number of elements.

  18. 18

    What does the size or count of an array list represent?

    1. A

      The highest possible index in all computer memory

    2. B

      The number of unused memory addresses in the system

    3. C

      The number of logical items currently in the list

    4. D

      The total number of locations in the backing array

    Correct answer
    C

    The number of logical items currently in the list

    Explanation

    The list's size or count is separate from capacity and records how many items are currently part of the logical list.

  19. 19

    How does an array list typically add an element to its end?

    1. A

      It changes the physical size of memory at the target index

    2. B

      It writes at the current count index and then increases the count

    3. C

      It deletes the final element and replaces it with the new value

    4. D

      It shifts every element toward the beginning before writing

    Correct answer
    B

    It writes at the current count index and then increases the count

    Explanation

    The current count serves as the next available logical index; the list writes there and increments the count.

  20. 20

    What happens when an element is removed from the middle of an array list?

    1. A

      Subsequent elements are shifted backward to fill the gap

    2. B

      The backing array automatically removes a physical memory cell

    3. C

      All earlier elements are shifted forward to the end

    4. D

      The list leaves the gap permanently and changes no indexes

    Correct answer
    A

    Subsequent elements are shifted backward to fill the gap

    Explanation

    To preserve contiguous ordering, every later element must be copied backward by one position.

  21. 21

    Why can a normal fixed-length array not directly remove one element?

    1. A

      Arrays can only contain elements in alphabetical order

    2. B

      Removing an element automatically changes every memory address

    3. C

      Removing it would require removing the corresponding physical memory location

    4. D

      Arrays cannot store zero or empty values

    Correct answer
    C

    Removing it would require removing the corresponding physical memory location

    Explanation

    An array's locations are fixed. A normal array can overwrite a value, but it cannot individually remove the physical location represented by an index.

  22. 22

    Why can removing an element from the middle of a large array list be slow?

    1. A

      Many subsequent elements must be read and rewritten

    2. B

      The operation requires searching all of computer memory

    3. C

      The list must recompute every possible element arrangement

    4. D

      The list must sort all elements alphabetically

    Correct answer
    A

    Many subsequent elements must be read and rewritten

    Explanation

    Removal from the middle requires copying each subsequent element backward, which becomes expensive for large lists.

  23. 23

    How does insertion into the middle of an array list preserve ordering?

    1. A

      It overwrites the target and discards all later elements

    2. B

      It shifts subsequent elements forward before writing the new element

    3. C

      It changes the meaning of every existing index

    4. D

      It places the new element at the end without changing other elements

    Correct answer
    B

    It shifts subsequent elements forward before writing the new element

    Explanation

    Insertion creates space by copying subsequent elements forward, then writes the new element into the target position.

  24. 24

    What determines whether an array-based data structure performs well?

    1. A

      Whether every operation uses the same array index

    2. B

      Whether the programming language hides its implementation

    3. C

      Whether the data's access pattern matches the structure's strengths

    4. D

      Whether the structure has the largest possible capacity

    Correct answer
    C

    Whether the data's access pattern matches the structure's strengths

    Explanation

    Each ordering and representation has strengths and weaknesses, so performance depends on how the program actually accesses the data.

  25. 25

    What is the defining access restriction of a stack?

    1. A

      Elements can be added or removed only at the beginning

    2. B

      Elements can be removed only from arbitrary middle positions

    3. C

      Elements can be added or removed only at the end called the top

    4. D

      Elements must always be accessed in sorted order

    Correct answer
    C

    Elements can be added or removed only at the end called the top

    Explanation

    A stack restricts modifications to its last element, called the top.

  26. 26

    Why is a stack described as last-in, first-out?

    1. A

      Elements are removed in alphabetical order of their values

    2. B

      The most recently added element is the first one available for removal

    3. C

      The oldest element is always removed before newer elements

    4. D

      Every element is removed immediately after insertion

    Correct answer
    B

    The most recently added element is the first one available for removal

    Explanation

    Like blocks in a vertical stack, the newest top element must be removed before earlier elements beneath it can be reached.

  27. 27

    How is adding an element to a stack implemented over an array?

    1. A

      Replace the top element without changing the count

    2. B

      Shift every element forward and write at the middle

    3. C

      Write after the current last element and increase the count

    4. D

      Write before the current first element and decrease the count

    Correct answer
    C

    Write after the current last element and increase the count

    Explanation

    Stack insertion is equivalent to adding at the end of an array list: write at the next position and increment the count.

  28. 28

    Why is popping from a stack especially efficient?

    1. A

      Popping reallocates the backing array after every operation

    2. B

      Removing the final element requires only decreasing the count

    3. C

      Popping shifts all earlier elements toward the end

    4. D

      Popping searches for the element throughout the backing array

    Correct answer
    B

    Removing the final element requires only decreasing the count

    Explanation

    There are no subsequent elements after the top, so no copying is needed; the count can simply be reduced by one.

  29. 29

    Which application naturally benefits from a stack?

    1. A

      Sorting users by two independent fields

    2. B

      Tracking undoable changes in a text editor

    3. C

      Finding a book by several library categories

    4. D

      Processing network requests in arrival order

    Correct answer
    B

    Tracking undoable changes in a text editor

    Explanation

    Undo operations usually reverse the most recent change first, matching stack behavior.

  30. 30

    How can redo functionality be implemented alongside an undo stack?

    1. A

      By maintaining a second stack for redoable changes

    2. B

      By duplicating the entire text after every keystroke

    3. C

      By storing every change in a sorted array by character

    4. D

      By removing the oldest change from the undo stack

    Correct answer
    A

    By maintaining a second stack for redoable changes

    Explanation

    A second stack can hold changes that were undone and may be reapplied. A new change clears that redo stack.

  31. 31

    What additional operation does a queue provide compared with a stack?

    1. A

      Removing an element from the front

    2. B

      Tracking the number of stored elements

    3. C

      Reading an element at an arbitrary index

    4. D

      Adding an element to the back

    Correct answer
    A

    Removing an element from the front

    Explanation

    Both structures can add at the back, but a queue additionally removes from the front.

  32. 32

    Why is a queue appropriate for processing web requests?

    1. A

      It processes requests in the order they arrive

    2. B

      It sorts requests alphabetically before processing

    3. C

      It permanently discards requests during heavy load

    4. D

      It always processes the newest request first

    Correct answer
    A

    It processes requests in the order they arrive

    Explanation

    Queues provide first-in, first-out processing, preventing older requests from being continually pushed behind newer ones.

  33. 33

    How does a circular queue prevent wasted space in a fixed-size array?

    1. A

      It reallocates a larger array after each dequeue

    2. B

      It stores every removed element in a second permanent array

    3. C

      It uses modulo arithmetic to wrap indexes back to zero

    4. D

      It shifts every remaining element toward the front after removal

    Correct answer
    C

    It uses modulo arithmetic to wrap indexes back to zero

    Explanation

    Taking each index modulo the array capacity causes indexes that pass the end to wrap around to the beginning.

  34. 34

    What does the start index represent in a circular queue?

    1. A

      The array position immediately after the last item

    2. B

      The total capacity of the backing array

    3. C

      The number of items that have ever been dequeued

    4. D

      The array position of the queue's first logical item

    Correct answer
    D

    The array position of the queue's first logical item

    Explanation

    The start index tracks where the first current queue element is located in the backing array.

  35. 35

    What is the main organizational idea of a linked list?

    1. A

      Elements must occupy consecutive array positions

    2. B

      Elements are kept in order by links to other elements

    3. C

      Elements are ordered only by their numerical values

    4. D

      Elements are always stored in separate physical arrays

    Correct answer
    B

    Elements are kept in order by links to other elements

    Explanation

    A linked list maintains logical order through links, rather than relying on the physical order of the underlying array.

  36. 36

    What information does a linked-list node typically store in addition to its data?

    1. A

      The index of every node in the entire list

    2. B

      The array index of the next node

    3. C

      The total capacity of computer memory

    4. D

      The sorted position of every possible future node

    Correct answer
    B

    The array index of the next node

    Explanation

    A simple array-based linked-list node stores its data and the index of the following node.

  37. 37

    Why can linked lists insert an element without shifting later elements?

    1. A

      They reserve a physical memory cell inside the existing node

    2. B

      They add the element elsewhere and update the relevant links

    3. C

      They automatically sort the entire array after insertion

    4. D

      They overwrite the target element and discard its successor

    Correct answer
    B

    They add the element elsewhere and update the relevant links

    Explanation

    The new node can be placed in another array location, while links are updated to place it logically between existing nodes.

  38. 38

    How can a linked-list element be removed efficiently when its predecessor is known?

    1. A

      Update the predecessor's next index to skip the removed element

    2. B

      Sort the remaining nodes before reconnecting them

    3. C

      Delete the physical array location and renumber all indexes

    4. D

      Shift every later node one position toward the beginning

    Correct answer
    A

    Update the predecessor's next index to skip the removed element

    Explanation

    Removing a node only requires changing the preceding node's link to point to the removed node's successor.

  39. 39

    What is the major cost of accessing the element at position nnn in a basic linked list?

    1. A

      The list must copy the entire backing array into a new array

    2. B

      The list must hash every element before reaching position nnn

    3. C

      The list may require following links from the first element nnn times

    4. D

      The list must shift all elements after position nnn

    Correct answer
    C

    The list may require following links from the first element nnn times

    Explanation

    Because physical array indexes do not necessarily match logical positions, a naive linked list must traverse links from the beginning.

  40. 40

    What performance trade-off does a linked list make compared with an array list?

    1. A

      It improves indexed access but requires more copying for every insertion

    2. B

      It improves insertion and removal with known neighbors but worsens indexed access

    3. C

      It improves memory locality but requires a fixed logical ordering

    4. D

      It improves sorting but prevents elements from being removed

    Correct answer
    B

    It improves insertion and removal with known neighbors but worsens indexed access

    Explanation

    Linked lists avoid shifting during insertion and removal when a nearby reference is known, but they cannot efficiently access the nth position.

  41. 41

    Why is iterating through a linked list often slower than iterating through an array?

    1. A

      Linked lists cannot store more than one element in memory

    2. B

      Arrays perform mathematical operations automatically during iteration

    3. C

      Linked lists require sorting before every sequential traversal

    4. D

      Linked-list nodes may be accessed in a scattered pattern with poor cache performance

    Correct answer
    D

    Linked-list nodes may be accessed in a scattered pattern with poor cache performance

    Explanation

    Linked-list nodes may be distributed across memory, producing less cache-friendly access than the contiguous pattern of an array.

  42. 42

    At the lowest software level, what is a pointer most closely equivalent to?

    1. A

      A sorting rule for an array

    2. B

      An index into memory

    3. C

      A copy of the referenced object

    4. D

      A count of unused memory locations

    Correct answer
    B

    An index into memory

    Explanation

    Because memory is modeled as an array, a pointer can be understood as an index identifying where data is located.

  43. 43

    What is the purpose of a hash function in a hashmap?

    1. A

      It removes duplicate values from the hashmap

    2. B

      It transforms a key into a number that can be mapped to an array index

    3. C

      It guarantees that every distinct key has a unique array index

    4. D

      It sorts all keys alphabetically before they are stored

    Correct answer
    B

    It transforms a key into a number that can be mapped to an array index

    Explanation

    A hash function converts arbitrary key data, such as a string, into a numeric value that can be reduced to a valid array index.

  44. 44

    Why is the hash value typically reduced modulo the backing-array length?

    1. A

      To convert the key back into its original string

    2. B

      To ensure that every array position remains empty

    3. C

      To map it into the valid index range from zero through the array length minus one

    4. D

      To guarantee that no two keys will ever collide

    Correct answer
    C

    To map it into the valid index range from zero through the array length minus one

    Explanation

    Taking the hash value modulo the array length produces an index within the valid range of the backing array.

  45. 45

    What is a collision in a hashmap?

    1. A

      Two different keys produce the same array index

    2. B

      The backing array reaches its maximum physical address

    3. C

      Two values have the same data but different keys

    4. D

      A key is removed before its value is read

    Correct answer
    A

    Two different keys produce the same array index

    Explanation

    A collision occurs when distinct keys map to the same calculated array index.

  46. 46

    How does an open-addressing hashmap commonly resolve a collision?

    1. A

      It deletes the item already occupying the index

    2. B

      It creates a separate building of duplicate data

    3. C

      It searches forward for an empty slot

    4. D

      It changes the key until the hash value becomes unique

    Correct answer
    C

    It searches forward for an empty slot

    Explanation

    One-array collision handling searches forward through the array until it finds an empty location.

  47. 47

    Why must an open-addressing hashmap store identifying information with each item?

    1. A

      The hashmap cannot store values without storing their data types

    2. B

      The calculated index may contain another key's item after a collision

    3. C

      The identifying information determines the array's physical capacity

    4. D

      The key is needed only to sort all values alphabetically

    Correct answer
    B

    The calculated index may contain another key's item after a collision

    Explanation

    After collisions, the initial hash index may not contain the desired item, so the stored key must be compared during probing.

  48. 48

    What are clusters in an open-addressing hashmap?

    1. A

      Separate arrays allocated for every individual key

    2. B

      Groups of keys that have identical values but different indexes

    3. C

      Long consecutive runs of occupied array positions

    4. D

      Empty regions created whenever an item is removed

    Correct answer
    C

    Long consecutive runs of occupied array positions

    Explanation

    Forward probing tends to create consecutive runs of stored items, known as clusters.

  49. 49

    How does a two-array hashmap handle collisions?

    1. A

      It copies every colliding item into every available array

    2. B

      It places all collisions at the final index of the first array

    3. C

      It links colliding items into a list stored in a second array

    4. D

      It discards keys that map to an occupied position

    Correct answer
    C

    It links colliding items into a list stored in a second array

    Explanation

    The first array identifies the initial item for a hash, while colliding items are stored in a second array and connected by links.

  50. 50

    What useful property of linked lists benefits the two-array hashmap design?

    1. A

      Multiple separate linked lists can be interleaved in one array

    2. B

      Every linked list must occupy one consecutive region of memory

    3. C

      Linked lists automatically resize every collision bucket equally

    4. D

      Linked lists guarantee that hash collisions cannot occur

    Correct answer
    A

    Multiple separate linked lists can be interleaved in one array

    Explanation

    Because linked lists follow explicit links rather than physical adjacency, many independent lists can share one underlying array.

  51. 51

    What relationship distinguishes a tree from a general graph?

    1. A

      Trees cannot contain links between nodes

    2. B

      Graphs allow only one outgoing link per node

    3. C

      Each child in a tree has only one parent

    4. D

      Each node in a tree must have multiple parents

    Correct answer
    C

    Each child in a tree has only one parent

    Explanation

    A tree allows a parent to have multiple children, but each child has only one parent.

  52. 52

    What are the elements of a tree called?

    1. A

      Buckets

    2. B

      Registers

    3. C

      Nodes

    4. D

      Clusters

    Correct answer
    C

    Nodes

    Explanation

    The elements in a tree are called nodes, and their relationships are parent-child relationships.

  53. 53

    In a tree, what is the node at the top of a relationship called?

    1. A

      The child

    2. B

      The terminal bucket

    3. C

      The vertex index

    4. D

      The parent

    Correct answer
    D

    The parent

    Explanation

    The node above another node in a tree relationship is the parent; the lower node is the child.

  54. 54

    How can a tree be implemented using two arrays?

    1. A

      Store nodes in one array and child relationships in a second linked-list array

    2. B

      Store only the root in one array and all values in the second

    3. C

      Store parents in one array and duplicate every child in another

    4. D

      Store every complete path in one array and delete the second array

    Correct answer
    A

    Store nodes in one array and child relationships in a second linked-list array

    Explanation

    One array holds the nodes, while another holds linked relationship records containing child-node indexes and links to additional children.

  55. 55

    When traversing a tree's children, what does a relationship record typically contain?

    1. A

      The parent's value and the total number of tree levels

    2. B

      The hash of the child and the capacity of the node array

    3. C

      The child node's index and the index of the next child relationship

    4. D

      The physical address of every descendant in the tree

    Correct answer
    C

    The child node's index and the index of the next child relationship

    Explanation

    A relationship record identifies a child in the node array and links to the next child relationship in the second array.

  56. 56

    How is a graph more general than a tree?

    1. A

      A graph permits links only from the root toward leaves

    2. B

      A graph requires every node to have exactly one parent

    3. C

      A graph removes all relationships between elements

    4. D

      A graph allows a node to have multiple parent connections

    Correct answer
    D

    A graph allows a node to have multiple parent connections

    Explanation

    A graph relaxes the tree constraint that each child has one parent, allowing multiple incoming relationships.

  57. 57

    What are the links between nodes in a graph called?

    1. A

      Capacities

    2. B

      Indexes

    3. C

      Edges

    4. D

      Buckets

    Correct answer
    C

    Edges

    Explanation

    Graph terminology calls the relationships between nodes edges; the nodes may also be called vertices.

  58. 58

    What is A* commonly used for?

    1. A

      Tracking the most recent edits in a text editor

    2. B

      Resizing an array without copying its elements

    3. C

      Finding a shortest or best path between two points

    4. D

      Sorting hashmap keys by their string length

    Correct answer
    C

    Finding a shortest or best path between two points

    Explanation

    A* is a pathfinding algorithm widely used to calculate routes between locations, including routes for characters in video games.

  59. 59

    How is a graph commonly represented using arrays?

    1. A

      Nodes are stored in one array and edges in a second linked-list array

    2. B

      Only the root node is stored, while edges are inferred from values

    3. C

      Every possible path is stored as a separate complete array

    4. D

      Edges are stored without any reference to their connected nodes

    Correct answer
    A

    Nodes are stored in one array and edges in a second linked-list array

    Explanation

    A common representation stores nodes in one array and edge records in another, with each node pointing to its first edge.

  60. 60

    What additional representation may be needed to traverse a graph in both directions?

    1. A

      A second root that replaces all existing parent relationships

    2. B

      A sorted copy of every node without any edge information

    3. C

      A duplicate vertex reference accessible from both connected nodes

    4. D

      A separate stack that stores every possible array index

    Correct answer
    C

    A duplicate vertex reference accessible from both connected nodes

    Explanation

    To traverse an edge in either direction, the connected vertex may need to be represented as accessible from both endpoints.

Question 1 of 60
Question 1 of 60

Ask anything

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

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent