Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1)Given a singly linked list contains 5 nodes, which simply shows as 5->4->3->2->1, what is the value that you can find in the second node

1)Given a singly linked list contains 5 nodes, which simply shows as 5->4->3->2->1, what is the value that you can find in the second node of the remaining list if the following statements are applied? Assume head reference refers the first node of the list.

Node prev = head;

Node curr = head. next;

while(curr.next!=null)

{

if(prev.element > 3)

{

prev = curr;

curr = curr.next;

}

else break;

}

head = prev.next;

Question 1 options:

3

2

4

1

2)

Which of the following is the code to insert a new node, referenced by newNode, into an empty queue implemented by a SinglyLinkedList with a head and tail references?

Question 2 options:

A)

newNode.setNext(tail); newNode = tail;

newNode = head;

B)

tail. setNext(tail); tail = newNode;

head = newNode;

C)

head. setNext(newNode); tail= newNode;

D)

newNode.setNext(tail);

head = newNode;

tail = newNode;

3)

Which of the following code fragments is used to delete the item at the front of a queue represented by a circular array?

Question 3 options:

A)

front = MAX_QUEUE - front; --count;

B)

front = (back+1) % MAX_QUEUE; --count;

C)

front = (front+1) % MAX_QUEUE; --count;

D)

front = front - back; --count;

4)

If a sequence of number 8, 12, 10, 6, 15 is added to a queue, in the order given, which number will be the second number to be removed from the queue?

Question 4 options:

A)

8

B)

15

C)

12

D)

6

5)

If a sequence of numbers 6, 2, 7, 13, 5, 4, 20 is added to a stack, in the order given, which number will be the last number to be removed from the stack?

Question 5 options:

A)

20

B)

6

C)

2

D)

4

6)Suppose an initially empty stack S has performed a total of 25 push operations, 12 top (or peek) operations, and 10 pop operations, 3 of which returned null to indicate an empty stack. What is the current size of S?

Question 6 options:

A)

18

B)

17

C)

15

D)

16

7)

Suppose an initially empty queue Q has performed a total of 32 enqueue operations, 10 first (or peek) operations, and 15 dequeue operations, 5 of which returned null to indicate an empty queue. What is the current size of Q?

Question 7 options:

A)

23

B)

27

C)

22

D)

25

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

Seven Databases In Seven Weeks A Guide To Modern Databases And The NoSQL Movement

Authors: Luc Perkins, Eric Redmond, Jim Wilson

2nd Edition

1680502530, 978-1680502534

More Books

Students also viewed these Databases questions