Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write working java methods from descriptions and estimate their Big-O notation. Algorithm 1: Fill the array 'a' from a[0] to a[n-1] as follows: To fill

Write working java methods from descriptions and estimate their Big-O notation.

Algorithm 1: Fill the array 'a' from a[0] to a[n-1] as follows: To fill a[i], generate random numbers until you get one that is not already in a[0] to a[i-1].

Algorithm 2: Same as algorithm 1, but keep an extra array called the 'used' array. When a random number, 'ran', is first put into the array 'a', set used[ran] = true. Now, when chosing a random number, no longer check ever position in 'a' before the one you are filling, just check the 'used' array.

Algorithm 3: Fill the array such that a[i] = i+1. Then, for(i = 1; i < n; i++) swapReferences(a[i], a[random(0,i)]); *Note: Write your own swapReferences method to switch two given positions

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

Advanced MySQL 8 Discover The Full Potential Of MySQL And Ensure High Performance Of Your Database

Authors: Eric Vanier ,Birju Shah ,Tejaswi Malepati

1st Edition

1788834445, 978-1788834445

More Books

Students also viewed these Databases questions

Question

How is the NDAA used to shape defense policies indirectly?

Answered: 1 week ago