ITSC 2214 Data Structures & Algorithms Test 2 Study Guide

ITSC 2214 Data Structures & Algorithms Test 2 Study Guide

University

23 Qs

quiz-placeholder

Similar activities

DS ADVANCED

DS ADVANCED

University

20 Qs

Basic Data Structures & Algorithms

Basic Data Structures & Algorithms

University

23 Qs

Queues

Queues

University

20 Qs

Data Structure Basics

Data Structure Basics

University

20 Qs

2.3.1 Graph Traversal & Path Finding Algorithms

2.3.1 Graph Traversal & Path Finding Algorithms

12th Grade - University

20 Qs

TEST-1

TEST-1

University

20 Qs

Quiz on Queue Operations

Quiz on Queue Operations

University

20 Qs

DS Mid Review

DS Mid Review

University

20 Qs

ITSC 2214 Data Structures & Algorithms Test 2 Study Guide

ITSC 2214 Data Structures & Algorithms Test 2 Study Guide

Assessment

Quiz

Computers

University

Medium

Created by

Idk Anymore

Used 5+ times

FREE Resource

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

Create a free account and access millions of resources

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?