Giter Club home page Giter Club logo

palindrome's Introduction

#include #include using namespace std; void findMinAndMax(int arr[],int low,int high,int &min,int &max) { if (low==high) { if (max<arr[low]) max=arr[low]; if (min>arr[high]) min=arr[high]; return; }

if (high-low==1)			
{
	if (arr[low]<arr[high])	
	{
		if (min>arr[low])	
			min=arr[low];
    	if (max<arr[high])	
			max=arr[high];
	}
	else
	{
		if (min>arr[high])	
			min=arr[high];
        if (max<arr[low])	 
			max=arr[low];
	}
	return;
}


int mid=(low+high)/2;
findMinAndMax(arr,low,mid,min,max);
findMinAndMax(arr,mid+1,high,min,max);

}

int main() { int arr[]={ 7, 2, 9, 3, 1, 6, 7, 8, 4 }; int n=sizeof(arr)/sizeof(arr[0]); int max=INT_MIN,min=INT_MAX; findMinAndMax(arr, 0, n - 1, min, max); cout<<"The minimum element in the array is"<<min<<'\n'; cout<<"The maximum element in the array is"<<max; return 0; }

palindrome's People

Contributors

kumarantr avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.