Program segment for quick sort, Data Structure & Algorithms

Assignment Help:

Illustrates the program segment for Quick sort. It uses recursion.

Program 1: Quick Sort

Quicksort(A,m,n)

int A[ ],m,n

{

int i, j, k;

if m

{

i=m; j=n+1; k=A[m]; do

do

do

++i;

while (A[i] < k);

do

--j;

while (A[j] > k);

if (i < j)

{

temp = A[i];

A[i] = A[j];

A[j] = temp;

}

while (i

temp = A[m];

A[m] = A[j];

A[j] = temp;

Quicksort(A,m,j-1);

Quicksort(A,j+1,n);

}

The Quick sort algorithm uses the O(N Log2N) comparisons on average. The performance can be developed by keeping in mind the following points.

1.         Switch to a faster sorting scheme such as insertion sort while the sublist size becomes comparatively small.

2.      Employ a better dividing element in the implementations.


Related Discussions:- Program segment for quick sort

Sorted list followed by a few "random" elements, You have to sort a list L ...

You have to sort a list L having of a sorted list followed by a few "random" elements. Which sorting methods would be especially suitable for this type of task?   Insertion sort

Definition of algorithm, Definition of Algorithm Algorithm must have th...

Definition of Algorithm Algorithm must have the following five characteristic features: 1.      Input 2.      Output 3.      Definiteness 4.      Effectiveness 5

Representation of a sparse matrix, Let us assume a sparse matrix from stora...

Let us assume a sparse matrix from storage view point. Assume that the entire sparse matrix is stored. Then, a significant amount of memory that stores the matrix consists of zeroe

Multiple queue, What is multiple queue and explain them

What is multiple queue and explain them

B-TREE and AVL tree diffrance, Explain process of B-TREE and what differen...

Explain process of B-TREE and what difference between AVL Tree Using Algorithms

Which sorting algorithm is adaptable to singly linked list, Which sorting a...

Which sorting algorithm is easily adaptable to singly linked lists? Simple Insertion sor t is easily adabtable to singly linked list.

Data Mining and Neural Networks, I am looking for some help with a data min...

I am looking for some help with a data mining class with questions that are about neural networks and decision trees. Can you help? I can send document with questions.

Structural Induction, Let a be a well-formed formula. Let c be the number o...

Let a be a well-formed formula. Let c be the number of binary logical operators in a. (Recall that ?, ?, ?, and ? are the binary logical operators). Let s be the number of proposit

Write the algorithm to find input and output value, This algorithm inputs 5...

This algorithm inputs 5 values and outputs how many input numbers were positive and how many were negative. Data to be used: N = 1, -5, 2, -8, -7

Representation of linked list in memory, Representation of Linked list in M...

Representation of Linked list in Memory:- Each node has an info part and a pointer to the next node also known as link. The number of pointers is two in case of doubly linked

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd