Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Help: 6) A circularly linked list is used to represent a Queue . A single variable P is used to access the Queue .

JAVA Help:

6) A circularly linked list is used to represent a Queue. A single variable P is used to access the Queue. To which Node should P point such that both the operations enqueue (item) and item = dequeue() can be performed in constant time: O(1) no looping necessary?

7)

Show what is written by the following segment of code:

stack = new MyStack();

String item0 = ;

String item1 = EE;

String item2 = B + item1;

String item3 = P;

push (item2);

push (item1);

push (item3 + item1);

item0 = stack.peek();

pop();

push (item2 + item3);

push (item0);

push (item0 + item3);

item0 = stack.peek();

pop();

print (Item0: + item0);

print (Item1: + item1);

print (Item2: + item2);

print (Item3: + item3);

while (!stack.isEmpty())

item0 = stack.peek();

pop();

print (Item: + item0);

8)

A single array, stk[MAXELEMS], is used to implement two stacks. The two stacks are grown in an array one from each end. Two variables, head1 and head2 (head1 < head2), hold the index of the location of the top element in each of the stacks. Which of the following is the best for implementing the check for a full stack, given we want a space efficient algorithm.

A) (head1 = MAXELEMS / 2) and (head2 = MAXELEMS / 2+1)

B) head1 + head2 = MAXELEMS

C) (head1 = MAXELEMS / 2) or (head2 = MAXELEMS)

D) head1 = head2 1

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

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions