The array is sorted except the first one

Assignment Help C/C++ Programming
Reference no: EM13168499

the array is sorted except the first one. For example, I have a list{5, 4, 2, 3 ,1}, after sorting the list is {5,1,2,3,4}.

public static void segmentedInsertionSort(AnyType[] list, int n, int h)
    {
       int j;
       System.out.println("hello Nguyen");
       System.out.println("the value of n is " + n + " "+ h);
        AnyType temp;
        for(int i = h; i < n; i++)
        {
            System.out.println("hello Ashley");
            j = i - h;
            while(j >0)
            {
                if (list[j].isBetterThan(list[j + h]))
                {
                    temp = list[j];
                    list[j] = list[j + h];
                    list[j + h] = temp;
                    j = j - h;
                    System.out.println("hello Connie");
                
                }
                else
                {
                    j = 0;
                }
            }
        }
    }
    
   
    
    public static void shellSort(AnyType[] list, int n)
    {
        int h = 1;
        while (h < n/3)
        {
            h = h*3 +1;
        }
        
        while(h > 0)
        {
            segmentedInsertionSort(list, n, h);
            h = (h - 1)/3;
        }
    
    }

 

 

Reference no: EM13168499

Questions Cloud

Modify the program in 6a so that, in addition to the cents : Modify the program in 6a so that, in addition to the cents, the user enters the denomination of the coin to which to convert the pennies, such as 5 for nickles or 25 for quarters.
Which allows to input a year and when hit the check button : Create a JAVA GUI (With Frame), which allows to input a year and when hit the check button, will show the picture of Chinese zodiac animal! I am trying to make a calculator: i have the method for or the calculation method to show how to calculate:
Determine the formula for x : When the compound spontaneously decomposes, the piston moves up, the temperature of the water reaches a maximum of 29.52°C, and then it gradually decreases as the water loses heat to the surrounding air.
How many cro42- ions are present : A sample of silver chromate (Ag2CrO4) has a mass of 24.7 g. (a) How many Ag+ ions are present? ions (b) How many CrO42- ions are present? ions (c) What is the mass in grams of one formula unit of silver chromate? g/formula unit
The array is sorted except the first one : the array is sorted except the first one
Write a lisp program to evaluate lisp arithmetic : Write a Lisp program to evaluate Lisp arithmetic expressions. Assume four operators may be used in expressions and they are +, -, *, and /. All these operators are binary, i.e., they are applied in an expression in this format
Java is considered to be safe from buffer overflows : Java is considered to be safe from buffer overflows. Does that make it more appropriate to use as a s development language when security is concerned? Be sure and weight all if the risks involved in product development, not just the security aspec..
Describe an algorithm that takes as input a list of n : Describe an algorithm that takes as input a list of n distinct integers and finds the location of the largest even integer in the list or returns 0 if there are no even integers in the list.
That reads ten numbers from input and prints : Write a C program that reads ten numbers from input and prints them in reverse order. We assume that the data consists of integers. The program should conform to the following format

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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