Stacks, Queues, Linked Lists

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

True

For efficiency, an array-based stack implementation keeps the bottom of the stack at index 0.

A

How does a queue organize it items? a. according to the order in which they were added b. by priority c. alphabetically d. randomly

O(N)

If the capacity needs to be incremented to accommodate the new element, the performance of Push becomes: where N is the count

O(1)

Performance of Pushing and Popping

True

Stack can be implemented as array or linked list

True

You need two external references for a circular doubly linked chain, one for the firstNode and one for the lastNode.

True

A polymorphic reference uses the type of the object, not the type of the reference, to determine which version of a method to invoke.

True

A stack is the ideal data structure to use when evaluating a postfix expression.

D

A two-part circular linked chain implementation of a queue a. conceptually has two lists b. uses a freeNode reference for the first available node that follows the queue c. has nodes that form the queue followed by nodes that are available for use in the queue d. all of the above

A

After the following statements execute, what item is at the back of the queue? QueueInterface<String> zooDelivery = new LinkedQueue<>(); zooDelivery .enqueue("lion"); zooDelivery .enqueue("tiger"); zooDelivery .enqueue("cheetah"); String next = zooDelivery .dequeue(); next = zooDelivery .dequeue(); zooDelivery .enqueue("jaguar"); a. "jaguar" b. "cheetah" c. "tiger" d. "lion"

A

After the following statements execute, what item is at the front of the queue? QueueInterface<String> zooDelivery = new LinkedQueue<>(); zooDelivery .enqueue("lion"); zooDelivery .enqueue("tiger"); zooDelivery .enqueue("cheetah"); String next = zooDelivery .dequeue(); next = zooDelivery .dequeue(); zooDelivery .enqueue("jaguar"); a. "cheetah" b. "jaguar" c. "tiger" d. "lion"

C

If we use a chain of linked nodes with only a head reference to implement a queue which statement is true? a. You must traverse the entire chain to access the last node. b. Accessing the last node is very inefficient. c. Both a & b d. None of the above

True

Dealing with the first node in a linked list often requires special handling.

True

Each node in an ordinary linked chain references only the next node.

True

Errors and exceptions represent unusual or invalid processing.

A

In a ______ the last node references the first node. a. circular linked chain b. array based queue c. array based circular queue d. linked chain

False

In a circular array-based implementation of a queue, frontIndex is equal to one less than backIndex when the queue is full.

False

In a circular array-based implementation of a queue, frontIndex is equal to one more than backIndex when the queue is empty.

True

In a circular array-based implementation of a queue, the available locations are not contiguous.

A

In a circular array-based implementation of a queue, what is the performance when the enqueue operation does not resize the array? a. O(1) b. O(log n) c. O(n) d. O(n2)

True

In a circular array-based implementation of a queue, you cannot use only frontIndex to determine when a queue is full.

A

In a circular linked chain, when a node is removed from the queue a. it is deallocated b. it is moved to a separate list c. it is ignored d. none of the above

A

In a linked chain implementation of a queue, an external reference to the last node in the chain is called a(n) a. tail reference b. last node c. linked reference d. final node

False

In a linked chain implementation of a queue, the enqueue operation could potentially be dependent on the other entries and will require a search.

False

In a linked chain implementation of a queue, the enqueue operation requires a traversal to the end of the chain to insert a new entry onto the queue.

A

In a linked chain implementation of a queue, the performance of the enqueue operation is a. O(1) b. O(log n) c. O(n) d. O(n^2)

B

In a linked chain implementation of a queue, the performance of the getFront operation is a. O(log n) b. O(1) c. O(n) d. O(n2)

True

In a linked chain implementation of a queue, when both the firstNode and lastNode entries are null, the chain is empty.

C

In a linked chain implementation of a queue, when the queue is empty a. the firstNode is null b. the lastNode is null c. both a & b d. none of the above

True

In an array-based implementation of a queue, inserting and deleting entries is accomplished using modulo arithmetic.

True

In an array-based implementation of a queue, keeping the front entry of the queue at queue[0] is inefficient.

C

In order to modify the front entry of a queue a. you need a set method defined b. you need to dequeue the front entry, modify the contents, and then use the requeue method to place it back on the front of the queue c. you cannot modify it under any circumstances d. none of the above

A

In the linked chain implementation of a queue, the chain's first node contains a. the queue's front entry b. the queue's back entry c. both a & b d. none of the above

True

Object reference variables can be used to create linked structures

Underflow

Occurs when the stack pointer is -1 (Stack is empty) if the user attempts to pop an item from the stack.

Overflow

Occurs when the stack pointer is at the max size and the user attempts to push an item onto the list. Can be prevented by sending an error message to the user.

A

Pointer variables are designed to hold addresses. a. true b. false

A

The method for removing an item from the front of a queue is called a. dequeue b. enqueue c. getFront d. none of the above

True

The order in which references are changed is crucial to maintaining a linked list.

Data Structure

The set of objects necessary to implement an abstract data type.

A

To efficiently remove a node at the end of a linked chain implementation of a queue requires a a. tail reference b. traversal c. extra reference in the node pointing to the previous node d. none of the above

DFS

Traversal algorithm that uses queues

False

Unlike a stack, a queue does not restrict access to its entries.

push

adds a new item to the top of the stack.

False

adds object to top of stack

LIFO

last in, first out

isEmpty

test to see whether the stack is empty, and returns a boolean value

IsFull()

test to see whether the stack is full, and returns a boolean value

nodes

the objects stored in a linked list are referred to generically as the nodes of the list

True

The item most recently added to a queue is at the back of the queue.

True

A priority queue cannot have null entries

size

Determines the number of elements on the stack.

pop

removes and returns the top item from the stack.

Infix to Postfix expression (2 rules)

1) operand order does not change 2) operators are in order of evaluation

True

A Java interface defines a set of abstract methods and is useful in separating the concept of an abstract data type from its implementation

B

A common alias for the queue method dequeue is a. get b. remove c. delete d. all of the above

B

A common alias for the queue method enqueue is a. put b. add c. insert d. all of the above

priority queue

A data structure that is first in first out but allows things to "cut" in line is called a __________

Abstract Data Type

A data type that is not defined within the programming language and must be defined by the programmer.

A

A linked chain whose last node is null is sometimes called a(n) a. linear linked chain b. circular linked chain c. null terminated linked chain d. all of the above

True

A linked list dynamically grows as needed and essentially has no capacity limitations.

True

A linked list is composed of objects that each point to the next object in the list.

Linked List

A list where each item contains the data together with a pointer to the next item. There may be an additional pointer to the previous item. This means the items can be accessed in order even if they are not stored in order; they do not have to be stored in adjacent memory locations

Defining Stack Data Linked List Based

A pointer whichcontains theaddress for the top node in the stack.

True False

An array implementation uses less space per object since it only has to store the object and not an extra pointer. However, the array implementation will allocate exactly the space it needs initially.

Defining Stack Data Array Based

An array of some set size - this is where the stack data is kept. An integer field to be used to mark the top.

True

By using the interface name as a return type, the interface doesn't commit the method to the use of any particular class that implements a stack.

x y +z * a b + -

Convert FPE Infix: ( ( (x + y) * z) - (a + b) ) to Postfix:

AB+CE-*FG+/

Convert FPE Infix: ( (A + B) * (C - E) ) / (F + G) ) to Postfix:

c a b - *

Convert FPE Infix: (c * (a - b) ) to Postfix:

rear, front

Insertions to a queue occur at the ________ end and the removals occur at the ________ end

True

T/F Stacks are LIFO data structures.

True True

TT/FF/TF/FT A linked list has no capacity limitations, while an array does. However, arrays provide direct access to elements using indexes, whereas a linked list must be traversed one element at a time to reach a particular point in the list.

True True

TT/FF/TF/FT A singly linked list maintains a reference to the first element in the list and then a next reference from each node to the following node in the list. A doubly linked list maintains two references: front and rear. Each node in the doubly linked list stores both a next and a previous reference

A

The ADT priority queue organizes objects a. according to priority of the objects b. alphabetically c. from front to back d. from back to front

e

The ___, also known as the address operator, returns the memory address of a variable. a. exclamation point ( ! ) b. percent sign ( % ) c. None of these d. asterisk ( * ) e. ampersand ( & )

A

The ____ ADT organizes its entries according to the order in which they were added. a. queue b. stack c. list d. priority queue

A

The _____ ADT that has operations to add, remove, or retrieve entries at both the front and back of a queue is called a a. deque b. reversible queue c. reversible stack d. all of the above

Queue

The _______ is a data structure that operates on a first in first out basis

Abstraction

The concept of hiding the underlying implementation of operations and data storage

D

The dequeue method a. throws an exception if the queue is empty b. returns the item at the front of the queue c. removes the item at the front of the queue d. all of the above

C

What item is at the front of the list after these statements are executed? DequeInterface<String> waitingLine = new LinkedDeque<>(); waitingLine.addToBack("Adam"); waitingLine.addToFront("Rudy"); waitingLine.addToBack("Larry"); waitingLine.addToBack("Sam"); waitingLine.addtoFront("Jack"); String name = waitingLine.getFront(); name = getFront(); a. Adam b. Rudy c. Jack d. Sam

D

What item is at the front of the list after these statements are executed? DequeInterface<String> waitingLine = new LinkedDeque<>(); waitingLine.addToFront("Jack"); waitingLine.addToBack("Rudy"); waitingLine.addToBack("Larry"); waitingLine.addToFront("Sam"); String name = waitingLine.getFront(); name = getBack(); waitingLine.addtoBack("Adam"); a. Jack b. Rudy c. Adam d. Sam

O(n)

What would be the BigO of the push operation if we chose to push at the end of the list instead of the front?

True

When a circular linked chain has one node, the node references itself.

True

When a circular linked chain is used to represent a queue, it is not necessary to maintain a firstNode data field.

A

Where does a queue add new items? a. at the back b. at the front c. in the middle d. randomly

D

Where does the last pointer in a linked-list point to? a. to head b. we don't set the last pointer value c. to itself d. to null

A

Where will you find the item added earliest to a queue? a. at the front b. at the back c. in the middle d. randomly

D

Which of the following real-world events could be simulated using a queue? a. bank line b. a shared network printer c. restaurant reservation list d. all of the above

Stack

a Last in, First Out data structure. So like a stack of plates, items are added to the top and removed.

True

a linked list has no upper bound on its capacity other than the limitations of memory in the computer.

Data Type

a set of values and operations on those values defined within a programming language.

Stack

an algorithm to determine whether a text is a palindrome can be implemented using

pointer

an object reference variable holds the address of an object, indicating where the object is stored in memory.

self-referential

public class Person { private String name; private String address; private Person next; // a link to another Person object } Using only this one class, a linked structure can be created. One Person object contains a link to a second Person object. This second object also contains a reference to a Person, which contains another, and so on. This kind of relationship forms the basis of a linked list, which is a linked structure in which one object refers to the next, creating a linear ordering of the objects in the list.

peek

returns the top item from the stack but does not remove it.

10

solve this postfix expression 3 4 * 2 5 4 * 2


संबंधित स्टडी सेट्स

Fundamentals Test 7 Practice Questions

View Set

Lección 1 | Hola, ¿qué tal? 1.3 Present tense of ser 2 - Nosotros somos...

View Set

Medigap - Medicare Supplement Insurance (Lesson 24.6)

View Set

Chapter 2: Life Insurance Basics

View Set

Chapter 10 Quiz: Missouri statues, rules, and regulations common to all lines

View Set