Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java programming. 1. What is the order of each of the following tasks in the worst case? a. Computing the sum of the first n

java programming.

1. What is the order of each of the following tasks in the worst case?

a. Computing the sum of the first n even intgers by using a for loop

b. Displaying all n integers in an array

c. Displaying all n integers in a sorted linkedlist

d. Displaying all n names in a circular linkedlist

e. Displaying one array element

f. Displaying the last integer in a linkedlist

g. Searching an array of n integers for a particular value by using a binary search

h. Sorting an array of n integers into descending order by using a mergesort

i. Adding an item to a stack of n items

j. Adding an item to a queue of n items

.2. Consider a sequential search of n data items.

  1. If the data items are sorted into ascending order, how can you determine that your desired item is not in the data collection without always making n comparisons?

  1. What is the order of the sequential search algorithm when the desired item is not in the data collection? Do this for both sorted and unsorted data, and consider the best, average, and worst cases.

  1. Show that if the sequential search algorithm finds the desired item in the data collection, the algorithms order does not depend upon whether or not the data items are sorted.

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

12th edition

133544613, 978-0133544619

More Books

Students also viewed these Databases questions