Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. suppose you want to visit every element of a single linked list. You write a loop that repeatedly calls get on each list index-

1. suppose you want to visit every element of a single linked list. You write a loop that repeatedly calls get on each list index- list.get(O), list.get(1), list.get(2), and so on. What's the overall Big-O (tightest possible bound) of this loop?

A) O(1)

B) O(log n)

C) O(n)

D) O(n^2)

E) O(n!)

2. suppose you want to visit every element of a single linked list. You start by creating an iterator over the list, then repeatedly call the iterator's next method until it runs out of elements. What's the overall Big-O (tightest possible bound) of this loop?

A) O(1)

B) O(log n)

C) O(n)

D) O(n^2)

E) O(n!)

3. Suppose you have a Linked list queue that stores strings and is of string type.

class QueueX{

QNode front, rear;

public QueueX(){ //constructor to clear the front and rear

this.front = this.rear = null;

}

//method to add a key to the queue

void enqueue(String key)

{ ----- }

QNode dequeue()

{ --------- }

//both enqueue and dequeue look after it's corresponding front and rear of their nodes

public static void main(String [] args) {

String X = null;

QueueX q = new QueueX();

q.enqueue("AA");

q.enqueue("BB");

q.enqueue("CC");

q.enqueue("DD");

X = q.dequeue().key; //What is X?

q.enqueue("EE");

Y = q.rear.key; //What is Y?

q.enqueue("FF");

q.enqueue("GG");

Z.q.front.key; //What is Z?

3. What is X?

A) AA B) BB C) CC D) DD E) EE F) FF G) GG

4. What is Y?

A) AA B) BB C) CC D) DD E) EE F) FF G) GG

5. What is Z?

A) AA B) BB C) CC D) DD E) EE F) FF G) GG

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Online Systems For Physicians And Medical Professionals How To Use And Access Databases

Authors: Harley Bjelland

1st Edition

1878487442, 9781878487445

More Books

Students also viewed these Databases questions