COMPUTER SCIENCE
, "What do we mean by "the list is an abstraction"? - CORRECT ANSWER This means
that a list is a conceptual representation of a collection of elements, rather than a
physical or tangible object. A list is a way of organizing and managing data that can be
implemented in various ways using programming languages."
"Contrast the space complexity of list operations in a linked list against list operations in
an array based list. - CORRECT ANSWER In a linked list, the space complexity is
linear to the number of nodes in the list. Each node requires additional memory to store
the value and the pointers to the previous and next nodes.
In an array based list, the space complexity is also linear to the number of elements in
the list. However, in addition to the elements, an array-based list also requires additional
memory to store the underlying array structure."
"Justify why a while loop is recommended for iteration in a linked list instead of a for
loop? - CORRECT ANSWER A while loop is recommended for iteration in a linked list
instead of a for loop because a linked list does not have a fixed length that can be easily
expressed as an index range. A while loop allows us to traverse"
"What is an iterator? - CORRECT ANSWER An iterator is an object that enables the
traversal of a data structure and access to its elements without exposing its underlying
implementation."
"How does using an iterator for iteration differ from indexed based iteration? -
CORRECT ANSWER Using an iterator for iteration differs from indexed based iteration
in that iterator-based iteration does not rely on index values to access elements, but
instead uses a next() method to move through the elements of the data structure one by
one. In contrast, indexed based iteration relies on accessing elements by their index
position."
"Why should iterator based iteration be used for linked lists over index based iteration? -
CORRECT ANSWER Iterator based iteration should be used for linked lists over index
based iteration because linked lists are not indexed-based data structures, meaning that
accessing elements by their index position would require iterating through the list until
the desired element is reached. This process can be inefficient and time-consuming,
especially for large lists. In contrast, using an iterator allows for efficient traversal of a
linked list, since it moves from one element to the next without the need to iterate
through the entire list."
"Why do we create abstraction layers? - CORRECT ANSWER Abstraction layers are
used to simplify complex systems by breaking them down into smaller, more
manageable components. Each layer provides a simplified interface to the layer below
it, while hiding the internal workings of that layer. This can help to make systems more
modular, flexible, and easier to maintain."
1