Someone help please
Let A be an array of 5 integers, whose contents are as
follows:
3, 2, 1, 5, 4
We will apply quick sort to sort this array. Show all of the
element-wise comparisons made by the algorithm in the correct
order. Here an element-wise comparison means the comparison of one
element of the array with another element of the array or the key
set in a particular step of the algorithm. Since the algorithm may
move the elements of the array, you need to show the values of the
elements being compared (rather than the form of A[i]). The first
element-wise comparison is 3 ≤ 4? You should start with this
element-wise comparison to write out all element-wise comparisons,
one comparison per row.
Draw the portion of the decision tree for insertion sort on 5 elements a1,a2,a3,a4,a5 that contains the path from the root node to the permutation < a3,a2,a1,a5,a4 >.
Draw the portion of the decision tree for quicksort on 5
elements a1,a2,a3,a4,a5 that contains the path from the root node
to the permutation < a3,a2,a1,a5,a4 >.
T(n) = 6·T(n/2)+n3. Use the master method to solve T(n). You
need to specify a, b, logb a, and decide the case. You also need to
write the derived conclusion.
Quick Sort follows divide and conquer method. That means it divides the problem into sub problems and find out the solution
In our example 3,2, 1,5,4
consider pivot element is 3 again leftmost element is= 3 and rightmost=4
pivot is 3 that means 3 must be in sorted position that means leftside of 3 contains elements less than 3 and rightside contains elements greater than 3
increment leftmost now its =2 which is less than pivot element then keep it as it is.
increment rightmost now its =4 which is greater than pivot element then keep it as it is .
increment leftmost now its =1 which is less than pivot element then keep it as it is.
increment rightmost now its =5 which is greater than pivot element then keep it as it is
increment rightmost now its =1 which is less than pivot element then exchange it with 3
now our list is = 1,2,3 ,5,4
Now divide the list into 2 parts and apply quick sort recurrsively .leftmost part of the 3 is already sorted right part contains elements 5 and 4
now consider pivot as =5 and leftmost element is also 5 rightmost element=4
now 4<5 therefore exchange it
now we get list= 1,2,3,4,5 which is in sorted order
Decision tree for insertion sort
Someone help please Let A be an array of 5 integers, whose contents are as follows:...
(7 pts) Draw the portion of the decision tree for insertion sort on 5 elements a1, a2, a3, a4, a5 that contains the path from the root node to the permutation < a3, a2, a1, a5, a4>.
6. (7 pts) Draw the portion of the decision tree for insertion sort on 5 elements a1; a2; a3; a4; a5 that contains the path from the root node to the permutation < a2; a3; a1; a5; a4 >.
4. (7 pts) Let A be an array of 5 integers, whose contents are as follows: 3, 2, 1, 5, 4. We will apply insertion sort to sort this array. Show all of the element-wise comparisons made by the algorithm in the correct order. Here an element-wise comparison means the comparison of one element of the array with another element of the array or the key set in a particular step of the algorithm. Since the algorithm may move the...
similar to this format shown at bottom this is an example of what the answer should look like NOT related to this question 1. (10 pts) There is a unique decision tree T for insertion sort on five element a1, a2, a3, a4, a5 Draw the portion of the tree T showing the path from the root node to the leave node a5, a4, a3, a2, a1 For each node, you need to show the comparison made. For each edge,...
There is a unique decision tree T for quicksort on five element a_1, a_2, a_3, a_4, a_5. Draw the portion of the tree T showing the path from the root node to the leave node < a_5, a_4, a_3, a_2, a_1 >. For each node, you need to show the comparison made. For each edge, you need to label it with either YES or NO.
the two problems are related. Please explain your answer in full detail Problem 1: On input a Binary Search Tree T show how to output an array that contains all the elements in T in sorted order. What's the running time of your algorithm? Does it perform any comparisons? Problem 2: Your classmate claims that they have an algorithm that on input n elements, constructs a Binary Search Tree T with those n elements using only O(n) comparisons. Can you...
The purpose of this assignment is to familiarize you with sort algorithms. Problem Description is as follows: 8. Search Benchmarks Write a program that has at least 20 250 integers stored in an array in ascending order. It should call a function that uses the linear search algorithm to locate one of the values. The function should keep a count of the number of comparisons it makes until it finds the value. The program then should call a function that...
Could someone please summarize the following for my programming class? They are study questions for java What an association list is. How to test if an association list is empty. How to find the value associated with a key in an association list. How to add a key-value pair to an association list. How to delete a key-value pair from an association list. How efficient an association list is (using O notation). What a circular list is. What a circular...
Need help with program. I'm stuck Objectives: In this assignment, we will practice manipulating lists of data and arranging items in an ascending/descending order. you will also explore storing lists/arrays using different sorting algorithms including, the selection sort, bubble sort, and insertion sort algorithm. Comparison between the three algorithms are made based on the number of comparisons and item assignments (basic operations) each algorithms executes. Background: Ordering the elements of a list is a problem that occurs in many computer...
The purpose of this assignment is to familiarize you with sort algorithms. Problem Description is as follows: 8. Search Benchmarks Write a program that has at least 20 250 integers stored in an array in ascending order. It should call a function that uses the linear search algorithm to locate one of the values. The function should keep a count of the number of comparisons it makes until it finds the value. The program then should call a function that...