A program sorts an array of integer. Write down the code that tests the sorting algorithm of written in a program.

Bank, Interview Programming, JOB Exam

Combined Bank(HBFC and KB)

Assistant Programmer-2018

Description: given array of size number, write a program to check if it is sorted in Ascending order or not.

Description: given array of size number, write a program to check if it is sorted in Ascending order or not.

Input: 10, 11,12,13,14

Output: True

Input: 20, 21,22,23,24

Output: True

Input: 20, 11.19,13,12

Output: False

Source code

#include <bits/stdc++. h>

#include <iostream>

using namespace std;

int sortTest (int arraList[], int nunber)

{

    int i;

        if(nunber==1 || nunber==0)

        return true;

        for(i=0;i<nunber;i++)

        if(arraList[i-1]>arraList[i])

        return false;

    return true;

}

int main()

{

    int arraList[5] = {1,2,4,6,7};

    int number=5;

    if(sortTest(arraList,number))

    cout<<“True”;

    else

    cout<<“True”;

}

0 Comments

You may find interest following article

Complete Guide: Create Laravel Project in Docker Without Local Dependencies

Create Laravel Project Through Docker — No Need to Install PHP, MySQL, or Apache on Your Local Machine In this tutorial, I’ll show you how to create and run a full Laravel project using Docker containers. That means you won’t have to install PHP, MySQL, or Apache locally on your computer. By the end of this guide, you’ll have a fully functional Laravel development...