Question

a) (25 points) Suppose that you are asked to analyze the performance. Algorithms operate on 1D array of size nor 2D a of the
please check my answers if it wrong answer me
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Solution:

4) Binary search for a target value in an unsorted array : NA.(Binary searches require the arrays to be sorted)

5)Find the maximum element in a 2-D array of size n x n: O(n2). (It is equal to the complexity of a linear search in the 2-D array)

6)Check if a 2-D array is symmetric: O(nlogn). (The number of comparisons go on decreasing by 1 for every row)

7)Find all combinations of the n elements in an array of size n: O(n!). (Similar to finding all combinations of strings from a string)

8)Sort an array of size n using merge sort: O(nlogn). (The array is broken down into halves and each is sorted and then merged)

The rest are all correct!

Add a comment
Know the answer?
Add Answer to:
please check my answers if it wrong answer me a) (25 points) Suppose that you are...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Comparison of Sorting Algorithms You are required to implement all the sorting algorithms (Bubble, Selection, Insertion...

    Comparison of Sorting Algorithms You are required to implement all the sorting algorithms (Bubble, Selection, Insertion, Quick, Merge). Take help from lecture slides and welb . You will then create arrays of different sizes as instructed below, test each algorithm on each array and record the execution times of each individual algorithm on each array. . You will report these execution times in a table and then write a report explaining the execution times of the sorting algorithms according to...

  • Selection Sort is a common algorithm to sort the elements of an array. First, it scans...

    Selection Sort is a common algorithm to sort the elements of an array. First, it scans the elements of the array to find the smallest value and places it at index 0, thus creating a sorted “subarray” of size 1 that contains the smallest value. Then it scans the remaining unsorted values for the new smallest value and places it at index 1, creating a sorted subarray of size 2 that contains the 2 smallest values. It continues in this...

  • Interfaces 1. What is inside an interface definition? What does a class do to an interface...

    Interfaces 1. What is inside an interface definition? What does a class do to an interface and what keyword is involved? How does a class do this to an interface (what should we find in the class)? Can an interface have a generic parameter? How do you instantiate an interface as an object? What methods can’t you use on an interface type? Abstract Data Types 2. What does an ADT define? Does an ADT specify programming language and/or data structures...

  • DESCRIPTION Implement a program in C++ that generates a specified number of random integers, records them...

    DESCRIPTION Implement a program in C++ that generates a specified number of random integers, records them in three arrays, then sorts the arrays with Insertion Sort, Merge Sort, and Quick Sort, respectively. Augment the three sorting algorithms with counters and report the number of characteristic operations each performs in sorting the (same) random values. INPUT The program reads from the terminal the number of random integers to generate, a seed value for the pseudo-random number generator, and a character that...

  • 1. Which is the best sorting algorithm for larger arrays if all the items can not...

    1. Which is the best sorting algorithm for larger arrays if all the items can not fit in main memory? selection sort insertion sort quicksort Merge sort 2. Which sorting algorithm sorts items without comparing them? quick sort radix sort merge sort Insertion sort 3 What is the average running time for quicksort? O(n2) O(logn) O(nlogn) O(n) O(n2logn) 4. Examine the steps of the following algorithm and write the name of the algorithm described in the blank provided: Recursively divide...

  • Please give a output Linux/Ubuntu and how to run it (compile) this program ,my assigment is below...

    Please give a output Linux/Ubuntu and how to run it (compile) this program ,my assigment is below : : Merge Sort algorithm using 2 processes a.) Define an integer array of 100 integers. Populate this array with random numbers. You can use int rand(void); function. Do not forget to initialize this function. You will sort the numbers in the array using merge-sort algorithm. In merge sort algorithm the half of the array will be sorted by one process and second...

  • I need help In the lecture you got acquainted with the median algorithm, which calculates the median of an unsorted array with n∈N elements in O (n). But the algorithm can actually do much more: it is...

    I need help In the lecture you got acquainted with the median algorithm, which calculates the median of an unsorted array with n∈N elements in O (n). But the algorithm can actually do much more: it is not limited to finding only the median, but can generally find the ith element with 0≤i <n. Implement this generic version of the median algorithm by creating a class selector in the ads.set2.select package and implementing the following method: /** * Returns the...

  • Given two arrays A and B of n integers both of which are sorted in ascending...

    Given two arrays A and B of n integers both of which are sorted in ascending order. Write an algorithm to check whether or not A and B have an element in common. Find the worst case number of array element comparisons done by this algorithm as a function of n and its Big-O complexity

  • Hello I have an automata question could you help me? [1Points] Give a formal description of a Tu...

    Hello I have an automata question could you help me? [1Points] Give a formal description of a Turing Machine M  that takes two parameters: an integer and an array of integers and decides whether the given integer is an element of the array or not. You can assume that all the integers are between 0 and 9. The input string will be written on the tape of the Turing machine. The first square of the tape contains the integer, the...

  • Please answer in Java for an immediate upvote :) Given the following array of 8 elements,...

    Please answer in Java for an immediate upvote :) Given the following array of 8 elements, trace the merge sort algorithm. Assume the array is to be sorted in ascending order.                        81          16          4        6             34          11          23        67 ANSWER: (Hint 6 – lines): Why don’t we select the median element of all the n-entries in the array to be our pivot point? ANSWER:

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT