Search Header Logo

ITSC 2214 Data Structures & Algorithms Test 2 Study Guide

Authored by Idk Anymore

Computers

University

Used 5+ times

ITSC 2214 Data Structures & Algorithms Test 2 Study Guide
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

23 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Assume you are adding an item, ‘F’, to the end of
this list. You’ve already created a linear node called
temp with a pointer to ‘F’. What lines of code update
this list?

back.setNext(temp);
back = temp;
numNodes++;

back.getNext(setNext(temp));
back = temp;
numNodes++;

back = temp;
back.getNext(setNext(temp));
numNodes++;

back = temp;
back.setNext(temp);
numNodes++;


2.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

A queue processes items in what order?

FIFO

LIFO

FILO

LILO

LIFO or FIFO

3.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

What are the contents of an ArrayList, myList,
after the following code is run:

myList.add("Ahab");
myList.add("Anitja");
myList.add("Yusef");
myList.add("Kelli");
myList.remove(1);
myList.remove(2);

["Ahab", "Anitja"]

["Ahab", "Kelli"]

["Ahab", "Yusef"]

["Yusef", "Kelli"]

["Anitja", "Kelli"]

4.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

What would be the complexity of the size()
method for a linked list if there was no count
variable?

O(1)

O(n)

O(log n)

O(n^2)

5.

MULTIPLE SELECT QUESTION

15 mins • 1 pt

Given the following information, select all the
asserts that would properly test a dequeue
operation if you’ve only added one object to the
queue.

• result is what the dequeue operation returns
• expdRslt is what you think should be returned
• myQueue is the queue of objects

assertEquals(result, expdRslt);

assertEquals(myQueue.size, 0);

assertTrue(myQueue.size == 0);

assertEquals(myQueue.size(),0);

assertTrue(result.equals(expdRslt));

6.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Given the following code, what is returned? Assume that ArrayQueue is a
correctly implemented class, with lots of capacity. Also note that we are
using Java's built-in queue which uses add/remove instead of
enqueue/dequeue, which is just a different vocabulary.

String s;
Queue<String> myQueue = new ArrayQueue<Integer>;
myQueue.add(“a”);
myQueue.add(“b”);
s = myQueue.remove();
s = myQueue.remove();
myQueue.add(“c”);
myQueue.add(“d”);
s = myQueue.remove();
s = myQueue.remove();
return s;

"a"

"b"

"c"

"d"

Nothing, this won't compile.

7.

MULTIPLE CHOICE QUESTION

15 mins • 1 pt

Given the following code using a queue X of
Integers, what is returned by a call to X.first()?

X.enqueue(new Integer(4));
X.enqueue(new Integer(3));
Integer y = X.dequeue();
X.enqueue(new Integer(7));
X.enqueue(new Integer(2));
X.enqueue(y);
y = X.dequeue();
X.enqueue(new Integer(3));
X.enqueue(new Integer(8));
? = X.first();

4

8

7

3

Nothing, an exception is thrown

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?

Discover more resources for Computers