Java

TOPIC 28 – DATA STRUCTURE QUIZ REVIEW

 

 

SOLUTIONS

 

 

REVIEW SOLUTIONS (FOR QUESTION 1)


QUESTION 1


a) In Java, the method used to add an element to a queue is called ______________.  Traditionally, it is often called enqueue.

add (I know, very lame!)
 

b) The traditional method used to add an element to a stack is called _______________ (although Java also supports the add method.).

push

 

c) In Java, the method used to get and remove an element from a queue is called _______________.  Traditionally, it is often called dequeue.

poll

d) The method used to get and remove an element from a stack is called _______________.

pop

 

e) FIFO refers to ____________ ___________ ____________ ____________.  It is the same as LILO.

First In First Out

 

f) FILO refers to ____________ ___________ ____________ ____________.  It is the same as LIFO.

First In Last Out

 

g) _______________ is the type of data structure that is FIFO.

Queue

 

h) _______________ is the type of data structure that is FILO.

Stack

 

i) ____________ is a data structure where all elements are stored together sequentially in memory.  This structure cannot be resized.

array

j) A(n) ____________ is a linear data structure that stores elements in different nodes.  Each node is stored in a different location in memory.  This structure can be resized efficiently.

Linked List

k) A(n) ______________ is like a normal array but with the ability of being resized.  It could be implemented using an array or a linked list.

List (could also have said Dynamic Array)

l) A data structure that allows you to add and remove elements only at the one end of it is called _____________.

Stack

m) A data structure that allows you to add elements at one end and get/remove from the other end is called _______________.

Queue

n) A data structure's efficiency is measured by both the ______________ and the _______________ to manipulate the structure.

memory usage

time required

o) A(n) ____________ is a data structure that stores elements in no specific order and makes sure that there are no duplicates.  In Java, both implementations that we looked at do store elements in alphanumeric order.

Set

p) Java _________________ is the framework that contains many different implementations of data structures including lists, sets and maps.

Collections

q) With regards to Data Structures, ADT stands for _______________ ________________ ________________.

Abstract Data Type

r) A(n) __________________ is a data structure that stores both a key and value. The key is used to access the value.  It is also called an associative array.

Map

s) Java implementations of List ADTs include _______________ and ________________.

ArrayList
LinkedList


t) Java implementations of Map ADTs include ________________ and _______________.

TreeMap
HashMap


u) Java implementations of Set ADTs include ________________ and ________________.

TreeSet
HashSet


v) The enhanced for loop can be used with data structures that implement the ____________ interface.

Iterable


w) A normal array has a _______________ size.

static


x) A(n) ______________ for loop can be used on any object that implements the Iterable interface.

enhanced

 

y) Both the Stack and Queue implementations that we looked at have a __________ method that allows you to see the element that could be popped or polled next but doesn’t actually remove the element from the structure.

 

peek

 

QUESTION 2 - 6

No solutions provided.