Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please answer all of them if you can. Thank you Q.1 Suppose elements yellow, pink, blue, and red are pushed onto the stack in that

Please answer all of them if you can. Thank you

Q.1

Suppose elements "yellow", "pink", "blue", and "red" are pushed onto the stack in that order. Which orders of events could occur?

Group of answer choices

A. "blue" is popped after "pink"

B. "pink" is popped before "red"

C. "pink" is popped after "red"

D. "blue" is popped before "yellow"

E. "yellow" is popped first

Q.2

Suppose elements "yellow", "pink", "blue", and "red" are added to a queue that order. Which orders of events could occur?

Group of answer choices

A. "red" is dequeued before "blue"

B. "yellow" is dequeued first

C. "blue" is dequeud after "yellow"

D. "pink" is dequeued before "red"

E. "pink" is dequeued after "red"

Q.3

Analyze the following code, and from the statements below select those that are true.

public static double harmonicSum(int n) { if (n == 1) return 1; else return 1.0/n + harmonicSum(n - 1); }

Group of answer choices

A.The base case is n == 1

B. For all positive inputs n the output will be equal to 1 + 1/2 + 1/3 + ...+1/n

C. The method runs infinitely and causes a StackOverflowError for all inputs

D. The base case is n > 1

E. The base case is n <= 1

F. For all positive inputs the output will be 1.0

G. For all negative inputs the method runs infinitely and causes a StackOverflowError

Q.4

Which of the following statements about lists are true?

Group of answer choices

A. You can insert an element at any index in a linked list

B. Array list is more efficient than singly-linked list with tail reference at adding an element at the end of the list

C. You can insert an element at any index in an array list

D. Array list is more efficient than singly-linked list with tail reference at removing an element at the end of the list

E. Linked list is more efficient than array list for adding and removing elements at the beginning of a list

F. Array List is more efficient than doubly-linked list with tail reference at removing an element at the end of the list

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

Spomenik Monument Database

Authors: Donald Niebyl, FUEL, Damon Murray, Stephen Sorrell

1st Edition

0995745536, 978-0995745537

More Books

Students also viewed these Databases questions