Saturday, 1 September 2012

Selection Sorting

Sorting means to sort an array of data. Say you had an array of numbers [2,4,6,1,3,5] and you sorted it (in ascending order), you'd get [1,2,3,4,5,6].

There are many different types of sorting, refered to as sorting algorithms. You can find out about some of the primary ones (bubble, selection, insertion, merge).




 Selection Sorting in Ascending Manner
 #include<iostream.h>
 #include<conio.h>

 void main()

 {  clrscr();
 int i,j ,s,temp,p;
 int a[5]={5,9,3,7,1};

 cout<<"\n";
 cout<<"corginal array is: \n";
 for(i=0;i<5;i++)
  cout<<a[i];

 for(i=0;i<5;i++)
  {
    s=a[i];
    p=i;

    for(j=i;j<5;j++)
    {
    if(s>a[j])
    {
     s=a[j];
     p=j;
    }
    }
    temp=a[i];
    a[i]=a[p];
    a[p]=temp;
    }

    cout<<"\n";
 cout<<"sorted array is: \n";
 for(i=0;i<5;i++)
  cout<<a[i];
     getch();
    }

OUTPUT:



24 comments:

  1. i love it
    a great site for c++

    ReplyDelete
  2. Lovely explanation of a language with a complicated task in a very simple program.
    mobile service center in vadapalani

    ReplyDelete
  3. Wonderful Blog post, great article that you have provided for peoples. Its really good. Nice information.



    Data Science Courses in Bangalore

    ReplyDelete
  4. I finally found great post here.I will get back here. I just added your blog to my bookmark sites. thanks.Quality posts is the crucial to invite the visitors to visit the web page, that's what this web page is providing.
    date analytics certification training courses
    data science courses training
    data analytics certification courses in Bangalore
    ExcelR Data science courses in Bangalore

    ReplyDelete
  5. I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post. Hats off to you! The information that you have provided is very helpful.





    BIG DATA COURSE MALAYSIA

    ReplyDelete

  6. I am really enjoying reading your well written articles. It looks like you spend a lot of effort and time on your blog. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work.Data Science Courses

    ReplyDelete
  7. Thanks for sharing useful information. I learned something new from your bog. Its very interesting and informative. keep updating. If you are looking for any Data science related information, please visit our website bigdata training institute in bangalore.

    ReplyDelete
  8. Really nice and interesting post. I was looking for this kind of information and enjoyed reading this one. Keep posting. Thanks for sharing.

    Correlation vs Covariance

    ReplyDelete
  9. Such a very useful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article. data scientist courses

    ReplyDelete

  10. ExcelR provides Data analyst course. It is a great platform for those who want to learn and become a Data Analyst. Students are tutored by professionals who have a degree in a particular topic. It is a great opportunity to learn and grow.

    Data analyst course

    ReplyDelete
  11. In the wake of perusing your article, I was astounded. I realize that you clarify it well overall. What's more, I trust that different perusers will likewise encounter how I feel in the wake of perusing your article.
    data scientist training and placement

    ReplyDelete
  12. Really an awesome blog, With informative and knowledgeable content. Thanks for sharing this blog with us. Keep sharing more stuff again.
    Data Science Online Training

    ReplyDelete
  13. Pleasant data, important and incredible structure, as offer great stuff with smart thoughts and ideas, loads of extraordinary data and motivation, the two of which I need, because of offer such an accommodating data here.
    data analytics training in hyderabad

    ReplyDelete
  14. Thank you so much for doing the impressive job here, everyone will surely like your post.
    full stack web development course malaysia

    ReplyDelete
  15. You completed certain reliable points there. I did a search on the subject and found nearly all people will agree with your blog.
    data science training in hyderabad

    ReplyDelete
  16. "Great post! Data science is a booming field, and Kochi offers some excellent courses to help you get started or advance your career. For more details on the courses available, check out Data science courses in Kochi. The hands-on training and real-world projects make them a great option for anyone looking to break into the industry."

    ReplyDelete
  17. "Appreciate the time and effort you put into creating this valuable content!"

    Data science course in mumbai.

    ReplyDelete
  18. Well researched and beautifully written! I’m definitely sharing this one with my friends
    Data science Courses in London

    ReplyDelete
  19. Great explanation of selection sort! It's such a simple yet useful algorithm to understand when getting started with sorting techniques. I’d love to see a comparison of selection sort with other sorting algorithms like bubble sort or insertion sort. How do they stack up in terms of efficiency
    Data science courses in Glasgow

    ReplyDelete
  20. "Great explanation of selection sorting! The step-by-step breakdown makes it easy to understand how the algorithm works. Thanks for sharing!"
    Data science Courses in Canada

    ReplyDelete