Exam 3 Flashcards

1
Q

is one of the most commonly used data structures in computer science

A

A stack

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

The stack’s storage policy is:

A

Last-In, First Out , or LIFO

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

boolean empty()

A

Returns true if the stack is empty; otherwise, returns false.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

E peek()

A

Returns the object at the top of the stack without removing it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

E pop()

A

Returns the object at the top of stack and removes it.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

E push (E obj)

A

Pushes an item onto the top of the stack and returns the item pushed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

a string that reads identically in either direction , letter by letter (ignoring case )

A

Palindrome

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When analyzing arithmetic expressions, it is important to determine whether an expression is:

A

balanced with respect to parentheses

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

The problem is further complicated if braces or brackets are used in ________ with _________.

The solution is to use:

A

conjunction

parentheses

Stacks

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

PITFALL: attempting to pop an empty stack will throw an ______________ . You can guard against this by either:

A

EmptyStackexception

testing for an empty stack or catching the exception

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Stacks are so common in computing, that Java included a Stack class in its early versions :

A

import java.util.Stack;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q
BUT, the Java Stack class extends Vector (a deprecated class which extends AbstractList) ... THEREFORE the class provides methods \_\_\_\_\_\_\_ to Stacks 
Its use is:
A

not traditional

no longer recommended

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

like the stack, is a widely used data structure

A

The queue

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A queue differs from a stack in one important way:

A

stack is a LIFO list Last-In, First-Out

while a queue a is FIFO list - First-In, First -Out

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Operating systems use queues to:

A

Keep track of tasks waiting for a scarce resource

ensure that the tasks are carried out in FIFO order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Printing queue:

A

Printing is so much slower than the process of selecting pages to print, so a queue is used

17
Q

remove() and poll() differ only on what happens when the queue is empty.

A

remove() removes the entry at the front and return NoSuchElementException

poll() removes the entry at the front and returns null

We use remove()

18
Q

peek() and element() differ only on what happens when the queue is empty.

A

peek() returns entry at the front and returns null

element() returns the entry at the front and returns NoSuchElementException

We use peek()

19
Q

The __________ class provides methods for inserting and removing elements at either end of a linked list, which means all _______ methods can be implemented easily

A

LinkedList

Queue

20
Q

The Java ________ class implements the _____ interface

A

Linkedlist

Queue