Quiz 4

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

If the sequence of operations - push (5), push (0), pop, push (9), push (2), pop, pop, pop, push (2), pop are performed on an initially empty stack, the sequence of popped out values is:

02952

What is the postfix version of the infix expression 12 / 3 * (50 / 3 * (3 / 4)) / 2 * 10

12 3 / 50 3 / 3 4 / * * 2 / 10 *

6 (top) 2 7 3 The following code is then executed: i nt x = S.pop(); int y = S.pop(); int z = S.pop(); S.push(x + y); int w = S.pop(); S.push(w + z);

15, 3

Given a 5 element queue Q (from front to back: 1, 3, 5, 7, 9), and an empty stack S, remove the elements one-by-one from Q and insert them into S, then remove them one-by-one from S and re-insert them into Q.

9, 7, 5, 3, 1

What is the correct postfix version of the infix expression A * (B + C * D) + E

ABCD*+*E+

What is the Postfix version of the following expression: ( ( AX + ( B * CY ) ) / ( D E ) )

AX B CY * + D E /

What is the need for a circular array compared to a non-circular array-based implementation of a queue?

Effective usage of memory

Finding the max element in an unordered stack would require

O(n) operations

Which of the following statements about stacks is incorrect? a; Stacks can be implemented using linked lists. b: Stacks are first-in, first-out (FIFO) data structures. c: New nodes can only be added to the top of the stack. d: The last node (at the bottom) of a stack has a null (0) link

b: Stacks are first-in, first-out (FIFO) data structures.

You have a singly linked list constructed out of nodes defined as follows: public class Node { public int datum; public Node next; } In all of functions shown below, the parameter first refers to the first node in the linked list, if there is one, and has the value null otherwise. Which of the following functions correctly inserts a value x at the front of the linked list and returns a reference to the new front of the linked list? a: public Node insertFront(Node first, int x) { first = new Node(); first.datum = x; first.next = first; return first; } b: public Node insertFront(Node first, int x) { Node n = new Node(); n.datum = x; n.next = first; return n; } c: both d: none

b: public Node insertFront(Node first, int x) { Node n = new Node(); n.datum = x; n.next = first; return n; }

Which of the following is true about linked list implementation of queue? a: In push operation, if new nodes are inserted at the beginning of linked list, then in pop operation, nodes must be removed from end. b: In push operation, if new nodes are inserted at the end, then in pop operation, nodes must be removed from the beginning. c: Both of the above d: None of the above

c: both of the above

The diagram below suggests how we could implement a double-ended linked list, in which we maintain a reference to both the first and last nodes in the linked list. front[] -> [35] -> [17] -> [29, null] <- []rear Which one of the following operations would be inefficient to carry out when there are a large number of elements in the linked list? a: insertion at the end to which front refers b: deletion from the end to which front refers test for an empty linked list c: insertion at the end to which rear refers d: deletion from the end to which rear refers

d: deletion from the end to which rear refers

The stack data type is restrictive in a sense that you cannot

remove the bottom element

Every node (except of the last node) in a singly linked list contains

the address of the next node

The postfix expression 14 2 5 + = will generate an error, because

there will be too many elements in the stack when the equal sign is encountered

How would you access elements of an aggregated object (think of a collection) sequentially without exposing the underlying structure of the object?

using an iterator


Set pelajaran terkait

Switched Digital Video Overview and Components

View Set

Financial Accounting Midterm Exam

View Set

Go further with you Google Analytics Data

View Set

Ch 6: strengthen a company's competitive positions

View Set

REL 130 - Periodic Exam 2 - Fall20

View Set