Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Part-1

Sorting Algorithms & Analysis
Objectives from the Unit Outline
Apply complexity theory to algorithms;
Discuss the relative merits of sort techniques using various abstract data types;
------------------------------------------------- ------------------------------------------------- ------------------------------------------------- ------------------------------------------------- ------------------------------------------------- ------------------------------------------------- -------------------------------------------------
The Tasks:

Question 1:

You are required to create a detailed analysis for each of the following array-based sorting algorithms:

(a) bubble sort in ascending order;
(b) quick_sort in ascending order, with partition choosing pivot in the middle of the sub-array;
(c) shell_sort in ascending order, with initial increment = n/2, then increment /=2;
(d) heap_sort in ascending order;

To analyse each of the abovementioned algorithms, please

1)provide a description of the algorithm in pseudocode;
2)conduct time complexity analysis of the algorithm (and also mention best case and worst caseanalysis if applicable);
3)conduct space complexity analysis of the algorithm;
4)Hand test your algorithm using your allocated 10-element long list of alphabetic charactersas an illustrative example (see the Data Set below, and treat them as an array),
ocount the number of comparisons;

ore-arrange your data set so as to achieve the best-case sorting of the algorithm;
ore-arrange your data set so as to achieve the worst-case sorting of the algorithm.

Question 2:

You are required to provide a detailed analysis of the following sorting algorithm applied to sorting linked list-based data structures.
merge_sort in ascending order

Similar to the case of Question 1, analyse the algorithms by

1)providing a description of the algorithm in pseudocode;
2)conducting time complexity analysis of the algorithm (and also mention best and worst caseanalysis if applicable);
3)conducting space complexity analysis of the algorithm;
4)hand testing your algorithm using your allocated 10-element long list of alphabeticcharacters as an illustrative example (see the Data Set below, and treat them as sequentialelements of an linked list),
ocount the number of comparisons;

ore-arrange your data set so as to achieve the best-case sorting of the algorithm;
ore-arrange your data set so as to achieve the worst-case sorting of the algorithm.

Data set

Allocated a 10-element array of alphabetic characters, which will be used for his/herillustrative hand testing of the algorithms.
Find his/her Dataset (or, Individual list to be sorted), of string format, ABCDEFGHIJ, which represents an array (or linked-list of) { A, B, C, D, E, F, G, H, I, J} (marked red).

Notes and awards:

The main objective of this assignment part is of algorithm analysis. As such, it doesn't require Java implementation of individual algorithms. However you are encouraged to implement them in Java if you have time to do so. If you attempt to do so, please save your executable java code/s separately, and submit them with your main document.
Your string will be KIMZUTONLV

Part-2

(a)    Bubble sort in ascending order.

1.      Pseudo code:

FUNCTION BubbleSortIMPORT array EXPORT array

FOR pass ¬ 0 TO (array.length-1)-1 DO¬Need N-1 passes to guarantee sorted

FOR ii ¬ 0 TO (array.length-1 - pass)-1 DO¬NOTE: 0-based array indexing

IF (array[ii] > array[ii+1]) THEN¬Avoid >= to keep the sort stable

temp ¬ array[ii]¬Swap out-of-order elements ii and ii+1

array[ii] ¬ array[ii+1]

array[ii+1] ¬ temp

ENDIF

ENDFOR

ENDWHILE

 

(b)   Quick sort in ascending order, with partition choosing pivot in the middle of the sub-array.

2.      Pseudo code:

 

FUNCTION QuickSort IMPORT array, leftIdx, rightIdx EXPORT array

IF (rightIdx > leftIdx) THEN¬Check that the array is > one element in size

pivotIdx¬ (leftIdx+rightIdx) / 2¬Pivot selection strategy: middle element

newPivotIdx¬ doPartitioning(array, leftIdx, rightIdx, pivotIdx)

QuickSort(array, leftIdx, newPivotIdx-1)¬Recurse: Sort left partition

QuickSort(array, newPivotIdx+1, rightIdx)¬Recurse: Sort right partition

//ELSE

// Base case: array is 1 element or smaller in size - already sorted

ENDIF

ENDFUNCTION

 

 

FUNCTION doPartitioning IMPORT array, leftIdx, rightIdx, pivotIdx EXPORT newPivotIdx

pivotVal¬ array[pivotIdx]

array[pivotIdx] ¬ array[rightIdx]¬Swap the pivotVal with the right-most element

array[rightIdx] ¬ pivotVal

 

// Find all values that are smaller than the pivot

// and transfer them to the left-hand-side of the array

currIdx¬ leftIdx

FOR (ii ¬ leftIdx TO rightIdx-1)

IF (array[ii]

temp¬ array[ii]¬Put this value to the left-hand-side

array[ii] ¬ array[currIdx]

array[currIdx] ¬ temp

currIdx¬ currIdx + 1

ENDIF

ENDFOR

newPivotIdx¬ currIdx

array[rightIdx] ¬ array[newPivotIdx]¬Put the pivot into its rightful place (the value at

array[newPivotIdx] ¬ pivotVal[newPivotIdx] is >= pivotVal, so it can be put to the end)

ENDFUNCTION

 

(c)    Shell sort in ascending order, with initial increment = n/2, then increment /=2.

3.      Pseudo code:

 

 

FUNCTIONShellSortIMPORTsize

   for (inc¬size/2 inc>0inc /= 2)

 

      for (i¬inci< sizei++)

 

         j¬i - inc

         while (j >= 0)

 

            if (a[j] > a[j+inc])

 

               swap a[j] and a[j+inc]

               j -¬inc

            else

               j¬-1

ENDFUNCTION

 

 

 

 

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M9888599
  • Price:- $60

Priced at Now at $60, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Risky business how can us companies protect their digital

Risky Business: How Can U.S. Companies Protect their Digital Assets Overseas? Prepare a 3 to 5 paragraph briefing statement that can be used to answer the above question. Your audience will be attendees at a conference f ...

The business model for jpmorgan chase was change in 2008

The business model for JPMorgan Chase was change in 2008. Could the upside of the strategy have been achieved without exposing JPMorgan Chase the bank?

A random sample of n data values is obtained from a process

A random sample of n data values is obtained from a process having an absolutely continuous cdf of unknown shape. The metallurgist wants to select the best fitting distribution among several candidate cdfs. She decides t ...

In a competitive market the market demand is qd 60- 6p and

In a competitive market, the market demand is Qd= 60- 6P and the market supply is the Qs= 4P the full economic price under a price ceiling of $3 is:?

Create login form to enter user name and a password textbox

Create login form to enter user name and a password textbox to enter password, and write procedure to simulate the process of triggering the login process after hitting the Enter Key.

Question why most of the researchers in the field of arabic

Question : Why most of the researchers in the field of Arabic text classification collected their own corpus and what is In-house Arabic corpus. The response must be typed, single spaced, must be in times new roman font ...

Write a matlab code to solve thisit seems that the math

Write a matlab code to solve this It seems that the Math department at a rival university has once again dropped the ball, and forgotten the value of n. You are to write a script which consumes a number that specifies th ...

Suppose you have the new zarnex vq-120 computer which has a

Suppose you have the new Zarnex VQ-120 computer which has a 64-bit architecture. Further, the boss has told you to ‘‘max out the memory,'' which, on that machine, means you can install all the memory the architecture sup ...

The interest rate on one-year treasury bonds is 1 the rate

The interest rate on one-year treasury bonds is 1%, the rate on two-year treasury bonds is 0.9%, and the rate on three-year treasury bonds is 0.8%. Using the expectations theory, compute the expected one-year interest ra ...

Whats the difference between a bigfile tablespace and a

What's the difference between a Bigfile tablespace and a Smallfile tablespace? Explain which you would use for your database and why.

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As