Beruflich Dokumente
Kultur Dokumente
Finished
4.25/8.00
Grade
Feedback
Question 1
Correct
Mark 1.00 out of 1.00
Flag question
The correct answer is: The average time complexity over a number of calls to the function.
Question 2
Correct
Mark 1.00 out of 1.00
Flag question
The function foo operates on a linked list containing n > 1 elements. What is the time complexity of this
algorithm given in Pseudocode?
Function foo( list, x )
p <- list.head
p <- p.next
Select one:
a. O(x)
b. O(n)
directly.
Yes, it will iterate over all n nodes in the list. It would be better to access the tail
c. O(log n)
d. O(log x)
e. Do not know
Question 3
Incorrect
Mark -0.25 out of 1.00
Flag question
What is the time complexity of adding an element at the head of a singly linked list of length n?
Select one:
a. O(log n)
b. O(n)
c. Do not know
d. O(1)
e. O(n log n)
Question 4
Correct
Mark 1.00 out of 1.00
Flag question
What is the time complexity of appending an element at the tail of a singly linked list (with tail pointer)
of length n?
Select one:
1. O(n log n)
2. O(1)
pointers.
Yes, using the tail pointer, we just need to create a new node and rearrange two
3. Do not know
4. O(n)
5. O(log n)
Question 5
Correct
Mark 1.00 out of 1.00
Flag question
Function foo - given in Pseudocode below - operates on a singly linked list list containing n > 1
elements. How much additional memory is needed to execute it (additional meaning excluding the
memory consumed by list itself)?
4. O(log n).
5. O(n).
Question 6
Incorrect
Mark -0.25 out of 1.00
Flag question
2. x.compareTo( z ) == 0
3. Do not know
4. x.compareTo( y ) == 0
5. x != z
Question 7
Incorrect
Mark -0.25 out of 1.00
Flag question
Assume that list is a singly linked list with more than 1 element.
What does the following pseudocode do with list?
Function foo( list, x ):
p <- list.head
IF NOT(p = NULL) AND p.info = x THEN
list.head = p.next
WHILE NOT (p = null OR p.next = NULL)
IF p.next.info = x
p.next = p.next.next
ELSE p = p.next
Select one:
a. It stops when p.info = NULL.
No, the loop condition does not check the contents of p.info.
b. Do not know
c. It removes the last node containing x.
d. It removes the first node containing x.
e. It removes all nodes containing x.
Question 8
Correct
Mark 1.00 out of 1.00
Flag question
Assume that list is a singly linked list with more n > 1 elements.
What is the time complexity of the following pseudocode?
Function foo( list, x ):
p <- list.head
IF NOT(p = NULL) AND p.info = x THEN
list.head = p.next
Select one:
a. O(n).
b. O(log n).
c. O(n log n).
d. Do not know
e. O(1).
Finish review