Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Which one of the pseudo-codes is the right choice for adding a cell at the end o

ID: 3702971 • Letter: W

Question

Which one of the pseudo-codes is the right choice for adding a cell at the end of the linked list?

Function(Cell: top, Cell: new_cell) new_cell.Next = top.Next top.Next = new_cell End Function

Function(Cell: top, Cell: new_cell) While (top.Next != null) top = top.Next End While top.Next = new_cell new_cell.Next = null End Function

Function(Cell: top) While (top != null) Print top.Value top = top.Next End While End Function

Function(Cell: top, Value: target) While (top != null) If (top.Value == target) Then Return top top = top.Next End While Return null End Function

Activity : 1 point(s)

Given the following sequence of stack operations, what is the top item on the stack when the sequence is complete?
m = Stack()
m.push('x')
m.push('y')
m.push('z')
m.pop()
m.peek()

'x'

'y'

'z'

The stack is empty

Activity : 1 point(s)

Given the following sequence of queue operations, what is the front item on the queue when the sequence is complete?
q = Queue()
q.enqueue('a')
q.enqueue('b')
q.enqueue('c')
q.dequeue()

'a'

'b'

'c'

The queue is empty

Activity : 1 point(s)

Given the following sequence of queue operations, what is the front item on the queue when the sequence is complete?
q = Queue()
q.enqueue('a')
q.dequeue()
q.enqueue('b')
q.enqueue('c')
q.dequeue()

'a'

'b

'c'

The queue is empty

Activity : 1 point(s)

What does the following Python Script do?
def function(node):
    if node.next == None: return True
    elif node.next.next == None: return True
    node = node.next
    while (node.next != None):
        if node.value > node.next.value:
            return False
        node = node.next
    return True

Checking linked list to find min value

Checking linked list if it’s sorted or not

None of them

Checking linked list’s size

Explanation / Answer

***NOTE: All the answers are in bold

Which one of the pseudo-codes is the right choice for adding a cell at the end of the linked list?

Function(Cell: top, Cell: new_cell) new_cell.Next = top.Next top.Next = new_cell End Function

Function(Cell: top, Cell: new_cell) While (top.Next != null) top = top.Next End While top.Next = new_cell new_cell.Next = null End Function

Function(Cell: top) While (top != null) Print top.Value top = top.Next End While End Function

Function(Cell: top, Value: target) While (top != null) If (top.Value == target) Then Return top top = top.Next End While Return null End Function

Activity : 1 point(s)

Given the following sequence of stack operations, what is the top item on the stack when the sequence is complete?
m = Stack()
m.push('x')                   x
m.push('y')                   y<-x    
m.push('z')                   z<-y<-x
m.pop()                        y<-x
m.peek()                      y => top is y

The stack is empty

Activity : 1 point(s)

Given the following sequence of queue operations, what is the front item on the queue when the sequence is complete?
q = Queue()
q.enqueue('a')   a
q.enqueue('b')   a<-b
q.enqueue('c')   a<-b<-c
q.dequeue() b<-c => front is b

The queue is empty

Activity : 1 point(s)

Given the following sequence of queue operations, what is the front item on the queue when the sequence is complete?
q = Queue()
q.enqueue('a')   a
q.dequeue()   null
q.enqueue('b') b
q.enqueue('c') b<-c
q.dequeue()   c=> front is c

The queue is empty

Activity : 1 point(s)

What does the following Python Script do?
def function(node):
    if node.next == None: return True
    elif node.next.next == None: return True
    node = node.next
    while (node.next != None):
        if node.value > node.next.value:
            return False
        node = node.next
    return True

Checking linked list to find min value

Checking linked list if it’s sorted or not

None of them

Checking linked list’s size