What will be the output of the following code for a DLL containing:
1 → 3 → 5 → 7 → 9?
1 pt
E temp = header.getElement();
Q15
Given a circular linked list with tail pointing to node
1 (order: 1→3→5→7→9→back). After
C.rotate(); C.rotate();, the tail will point to which
value?
1 pt
Q16
In the implementation of a circular linked list discussed in class,
how can you tell if you've
completed traversing a full cycle?
1 pt
Q17
In a singly linked list that contains a
single node:
1 pt
Q18
Deleting a node in the middle of a doubly linked
list requires…
1 pt
Written / CodeAll Instructors
Q19
List the main attributes of a node in a
doubly linked list.
1 pt
Q20
Write an algorithm search(x) to search a
singly linked list for the first occurrence of
value x and return its (abstract) position number. The first element
has position 1, second has position 2, etc. If the element does not
exist return -1.
2 pts
Q21
Sketch (draw) the work needed to swap 2 nodes in a
doubly linked list, then write the algorithm
swap(DLL, p1, p2). Include predecessor and successor
pointers.
2 pts
Drawing required on paper - describe your algorithm and key pointer
assignments below.
Q22
Sketch how to create a linked list from an array A
= [a, b, c, d]. List the steps involved.
2 pts
Drawing required on paper - describe your steps below.
Q23
Assume you have a doubly-linked list (DLL) with an
odd number of elements. Write a method that returns
a pointer to the middle node. Note: you
cannot use the size() method and you
cannot count the number of nodes in the list.
3 pts
Q24
Quiz 1 Summer
Sketch (draw) how to remove the 3rd node from a
doubly linked list L. Your answer should include drawings and
explanations.
2 pts
Drawing required on paper - describe your approach below.
Q25
Quiz 1 Summer
Assume you have a single-linked list A where all
nodes contain positive and negative values. Write a method that
returns the number of nodes with negative values.
3 pts
Q26
Show how to
add a node in a singly linked list at position x.
Your answer should include a drawing and explanation (coding is not
required).
2 pts
Drawing required on paper - explain the key steps below.
Q27
Assume you have a doubly linked list of Integers.
Write a method that returns the average of those
elements.
3 pts
Q28
Write an implementation for the method
sumEven(int[] myArray) - which finds the
summation of the even numbers in an array.
Example:
array A = <10, 3, 7, 6, 10, 53>, then sumEven(A) shall return:
26
1 pt
Q29
Suppose a Singly Linked List is implemented with only
head and size variables (no tail).
Write an implementation for insertLast(E e) - which
inserts the new element at the end of the list. Handle all special
cases. This method is inside the SLL class.
2 pts
Q30
Write an implementation for the method
findKthFromEnd(int k) - which finds the kth node
from the end of a doubly linked list. Handle all special cases. This
method is inside the DLL class.
2 pts
Your Score
- %
- / - points
0
Correct
0
Incorrect
0
Partial
Scroll up to see detailed feedback under each question.