Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 2 involves an analysis of the results that you obtained in first project. You are to submit a paper, written with Microsoft Word, that

Project 2 involves an analysis of the results that you obtained in first project. You are to submit a paper, written with Microsoft Word, that discusses the results of your analysis. Grading of the second part will be based on the following items: A brief introduction of the sorting algorithm that you have selected and how the two versions of the algorithm compare A discussion of the critical operation that you chose to count with an explanation of why you selected it A Big- analysis of the two versions of the algorithm A discussion of the results of your study, which should include o graphs of your results o a comparison of the performance of the two versions of the algorithm o a comparison of the critical operation results and the actual execution time measurements o a discussion of the significance of the standard deviation results and how it reflects the data sensitivity of your algorithm o how your results compare to your Big- analysis A conclusion that summarizes the important observations of your study Below are project 1 code ;

// Recursive APPROACH of the Quick Sort import java.util.ArrayList; import java.util.Iterator; import java.io.BufferedReader; import java.io.InputStreamReader; public class QuickSort { private static void swap(int[] a1, int in, int jn) { int temp = a1[in]; a1[in] = a1[jn]; a1[jn] = temp; } private static void Quicksort(int liste[], int from, int to) { if (from >= to) { return; } int pvot = liste[from]; int in = from - 1; int jn = to + 1; while (in < jn) { in++; while (liste[in] < pvot) { in++; } jn--; while (liste[jn] > pvot) { jn--; } if (in < jn) { swap(liste, in, jn); } } Quicksort(liste, from, jn); Quicksort(liste, jn + 1, to); } public static int[] Quicksort(int [] liste) { Quicksort(liste, 0, liste.len-1); return liste; } public static void main(String args[]) throws Exception { String liste=""; int in=0,n=0; QuickSort s= new QuickSort(); ArrayList arrlist=new ArrayList(); System.out.println(" "); System.out.println(" "); System.out.println("Enter the liste of elements,one element in line"); System.out.println(" write 'STOP' when liste is complete."); BufferedReader bf=new BufferedReader(new InputStreamReader(System.in)); while(!(liste=bf.readLine()).equalsIgnoreCase("stop")){ int intelement=Integer.parseInt(liste); arrlist.add(intelement); } int elementlist[] = new int[arrlist.size()]; Iterator iter = arrlist.iterator(); for (int jn=0;iter.hasNext();jn++) { elementlist[jn] = iter.next(); } elementlist=Quicksort(elementlist); System.out.println("the sorted value via recursive approach of Quicksort is: "); for (int jn=0;jn

// Iterative APPROACH of the Quick Sort

using System.Collections.Generic;

using System.Text;

using System;

namespace QuickSort

{

class Program

{

public static void Main(string[] args)

{

//user input size => 50 (DEMO DATA)

int[] arr = { 41, 99, 12, 33, 99, 10,1000,199,200,11,22,33,44,55,66,788,89,9,32,34,35,46,56,7,8,90,,12,2,1,23,45,6,7,77,78,98,90,97,43,23,25,23,334,55,443,45,456,674,1235,454};

QuickSort1(ref arr);

foreach (int i in arr)

{

Console.WriteLine(i);

}

}

public static void QuickSort1(ref int[] input)

{

System.Collections.Stack stack = new System.Collections.Stack();

int pivot;

int pivotIndex = 0;

int lefIn = pivotIndex + 1;

int rigtIn = input.Length - 1;

stack.Push(pivotIndex);

stack.Push(rigtIn);

int leftIndexOfSubSet, rightIndexOfSubset;

while (stack.Count > 0)

{

rightIndexOfSubset = (int)stack.Pop();

leftIndexOfSubSet = (int)stack.Pop();

lefIn = leftIndexOfSubSet + 1;

pivotIndex = leftIndexOfSubSet;

rigtIn = rightIndexOfSubset;

pivot = input[pivotIndex];

if (lefIn > rigtIn)

continue;

while (lefIn < rigtIn)

{

while ((lefIn <= rigtIn) && (input[lefIn] <= pivot))

lefIn++;

while ((lefIn <= rigtIn) && (input[rigtIn] >= pivot))

rigtIn--;

if (rigtIn >= lefIn)

SwapElement(ref input, lefIn, rigtIn);

}

if (pivotIndex <= rigtIn)

if( input[pivotIndex] > input[rigtIn])

SwapElement(ref input, pivotIndex, rigtIn);

if (leftIndexOfSubSet < rigtIn)

{

stack.Push(leftIndexOfSubSet);

stack.Push(rigtIn - 1);

}

if (rightIndexOfSubset > rigtIn)

{

stack.Push(rigtIn + 1);

stack.Push(rightIndexOfSubset);

}

}

}

private static void SwapElement(ref int[] arr, int lft, int rigt)

{

int tmp = arr[lft];

arr[lft] = arr[rigt];

arr[rigt] = tmp;

}

}

}

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_2

Step: 3

blur-text-image_3

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

Refactoring Databases Evolutionary Database Design

Authors: Scott Ambler, Pramod Sadalage

1st Edition

0321774515, 978-0321774514

More Books

Students also viewed these Databases questions

Question

=+2. Why is due process important?

Answered: 1 week ago