Competitive Programming
3.79K subscribers
1 photo
38 links
Experince a new world of algorithmic problems using C++
Channel link:
https://t.me/Competitive_Programming_Cpp

For any query contact me:
@saranyanaharoy
You can also share your experiences and ideas with us. We will share it in our channel.
Download Telegram
Channel created
Hi! Here We Will dicuss about various programming challenges using C++ Language
Hey there!!! Let's begin our journey with a very simple problem. You are given an array and you need to sort it. Try yourself. I will be posting different approaches to tackle it.
Well there, sorting is an important tool to solve many problems. You will never be asked to sort an array in any competitive programming contest but sometimes you might have to sort an array as per requirements. So , you need to master the art of sorting an array correctly and quickly.
Some of the popular sorting algorithms are:
1) Bubble sort - https://www.geeksforgeeks.org/bubble-sort
2) Selection sort - https://www.geeksforgeeks.org/selection-sort
3) Insertion sort - https://www.geeksforgeeks.org/insertion-sort
4) Quick Sort - https://www.geeksforgeeks.org/quick-sort
5)Merge sort - https://www.geeksforgeeks.org/merge-sort
6)Count sort - https://www.geeksforgeeks.org/counting-sort
Of these sortng algorithms, Quick sort and Merge sort is more used as time taken by these algorithm is quite less than compared to bubble sort, insertion sort or selection sort. So it is recommended to use one of the Merge or Quick sort.
BUT WAIT!!!!! You surely don't want to write such a huge code during an ongoing competition. There is an easy way...........
Use the in-built sorting function of C++. It's just the matter of a line now!!!!
The prototype of the function is:
sort(start address, end address)
Eg: Suppose you have to sort an array A[n]. Then you just have to simply write
sort(A , A+n ) ;
and there you go you have a sorted array with very few efforts.
Remember to include "bits/stdc++.h" header file at the begining of you code.
I will be posting more on this sorting function as soon as possible.
AND HAA....here is the solution of the problem given:
https://www.codechef.com/viewsolution/23726104
Try to submit by yourself!!!!!!!!!