Home » 8.3.1 Sorting in Arrays | Selection Sort | C++ Placement Course | Chia sẻ về chủ đề selection sort c++ |

8.3.1 Sorting in Arrays | Selection Sort | C++ Placement Course | Chia sẻ về chủ đề selection sort c++ |

Dường như bạn đang muốn tìm hiểu nội dung về selection sort c++ có phải không? Dường như bạn đang muốn tìm chủ đề 8.3.1 Sorting in Arrays | Selection Sort | C++ Placement Course đúng vậy không? Nếu đúng như vậy thì mời bạn xem nó ngay tại đây.

8.3.1 Sorting in Arrays | Selection Sort | C++ Placement Course | Xem thông tin về laptop tại đây.

[button color=”primary” size=”medium” link=”#” icon=”” target=”false” nofollow=”false”]XEM VIDEO BÊN DƯỚI[/button]

Ngoài xem những thông tin về laptop mới cập nhật này bạn có thể xem thêm nhiều thông tin liên quan khác do https://soyncanvas.vn/ cung cấp tại đây nha.

Kiến thức liên quan đến nội dung selection sort c++.

Ghi chú của video này: Apni Kaksha Instagram: …

Hình ảnh liên quan đếnchủ đề 8.3.1 Sorting in Arrays | Selection Sort | C++ Placement Course.

8.3.1 Sorting in Arrays | Selection Sort |  C++ Placement Course

8.3.1 Sorting in Arrays | Selection Sort | C++ Placement Course

>> Ngoài xem chủ đề này bạn có thể tìm hiểu thêm nhiều Kiến thức hay khác tại đây: Xem thêm kiến thức laptop tại đây.

Từ khoá liên quan đến chuyên mục selection sort c++.

#Sorting #Arrays #Selection #Sort #Placement.

[vid_tags].

8.3.1 Sorting in Arrays | Selection Sort | C++ Placement Course.

selection sort c++.

Chúng tôi mong rằng những Kiến thức về chủ đề selection sort c++ này sẽ mang lại kiến thức cho bạn. Chân thành cảm ơn.

45 thoughts on “8.3.1 Sorting in Arrays | Selection Sort | C++ Placement Course | Chia sẻ về chủ đề selection sort c++ |”

  1. thank me later

    #include<iostream>
    using namespace std;
    int main(){
    int moneyUhave;//money customer have
    cin>>moneyUhave;
    int chococlatePrice;// price of one chocolate
    cin>>chococlatePrice;
    int choco=moneyUhave/chococlatePrice;//chocolate u get out of money
    int wrapchoco;//variable for chocolate u can get from wrappers
    int wrap=choco;//number wrapper u have from number chocolate u get from money intially
    //calcualting chocolates from wrappers
    while(true)
    {
    if(wrap<3)break;//break if wrapper are less then 3 coz u cant get any chocolate.
    wrap=wrap-3;//subtract 3 wrappers to get one chocolate
    wrapchoco++;//increamenting chocolate we r getting from subtracting 3 wrappers
    wrap++;//increamenting wrapper of new chocolate u r getting by subtracting 3 wrappers
    }
    cout<<choco+wrapchoco;//total chocolates u can have
    return 0;
    }

  2. Correct Code is this.
    for(int i=0; i<size-1; i++){
    int min_index = i;
    for(int j=i+1; j<size; j++){
    if (arr[j] < arr[i]){
    min_index = j;
    }
    }
    int temp = arr[i];
    arr[i] = arr[min_index];
    arr[min_index] = temp;
    }

  3. mene as it is code copy kiya h lekin tb bhi nhi chal rha h , koi dekh k btayga ki kya problem h isme

    #include<iostream>

    using namespace std;

    int main(){

    int n;

    cin>>n;

    int array[n];

    for (int i = 0; i < n; i++)

    {

    cin>>array[n];

    }

    for (int i = 0; i < n-1; i++){

    for (int j = i+1; i < n; j++){

    if(array[j]<array[i]){

    int temp=array[j];

    array[j]=array[i];

    array[i]=temp;

    }

    }

    }

    for (int i = 0; i < n; i++)

    {

    cout<<array[i]<<" ";

    }cout<<endl;

    }

  4. I don't think what you taught and what ur code does is same .. u told to find the minimum element in the unsorted part of array and swap it with the 1st unsorted element .. but ur code swaps positions everytime it sees an element which is less than that the 1st unsorted element with its position ..

  5. Code for the last question

    #include <iostream>
    using namespace std;

    int main() {
    int c,n,r;
    cin>>n;
    c=n;
    r=n;
    while(r>=3){
    r=n%3+n/3;
    n=n/3;
    c=c+n;
    n=r;
    if(n/3<1 && r>=3){
    c=c+r%3;
    }

    }

    cout<<c;
    }

  6. Can you please tell aapne array mai size user define kaise kiya because user define arrays to malloc() se bante hain and aapne to usse user se Input dene ko bol diya how ??? please tell

  7. that's not an correct algorithm for selection sort because first of all we find the index of min element in array and then later on we replace it with first element of unsorted array, the algorithm you're using will also work but it'll does more swapping, so it's not that much efficient.

  8. //program on selection sort in c++

    #include <iostream>

    using namespace std;

    void print(int arr[], int n)

    {

    printf("the array=");

    for (int i = 0; i < n; i++)

    cout << arr[i] << " ";

    cout << endl;

    }

    void selection(int n, int arr[])

    {

    cout << "nn";

    int min, temp;

    for (int i = 0; i < n – 1; i++)

    {

    min = i;

    for (int j = i + 1; j < n; j++)

    {

    if (arr[min] > arr[j])

    min = j;

    }

    if (min != i)

    {

    temp = arr[i];

    arr[i] = arr[min];

    arr[min] = temp;

    }

    print(arr, n);

    }

    cout << "nn";

    }

    int main()

    {

    int n;

    cout << "Enter the size =";

    cin >> n;

    int arr[n];

    for (int i = 0; i < n; i++)

    cin >> arr[i];

    printf("Before Sorting ");

    print(arr, n);

    selection(n, arr);

    printf("After sorting ");

    print(arr, n);

    return 0;

    }

    OUTPUT:-
    Enter the size =6

    12 45 23 51 19 8

    Before Sorting the array=12 45 23 51 19 8

    the array=8 45 23 51 19 12

    the array=8 12 23 51 19 45

    the array=8 12 19 51 23 45

    the array=8 12 19 23 51 45

    the array=8 12 19 23 45 51

    After sorting the array=8 12 19 23 45 51

  9. this is not the selection sort!
    you are just swapping the first element which is less than the arr[i] element not the smallest element of the remaining unsorted array… The result is a sorted array but this is not selection sort!!!!!!!!!!😐😐😐

  10. Code for maximum chocolate

    #include<iostream>
    using namespace std;

    int main(){
        int n;
        cin>>n;
        int choco = n;
        int wrap = n;
        while(wrap>=3){
            choco += wrap/3;
            wrap = (wrap/3) + (wrap%3);
        }

        cout<<choco<<"n";

        return 0;
    }

  11. i coded for the puzzle… : ))

    int main(){
    int rupees;
    cin>>rupees;
    int chocolate=rupees;

    for(int i=1;i<rupees;i++){
    if(i%3==0){
    chocolate+=1;
    }
    if(chocolate%3==0){
    chocolate+=1;
    }
    }

    cout<<chocolate<<endl;

    }

  12. //you have x Rs (entered by user); 1 chocolate 1 Rs or 3 wrappers; how many can you eat?

    #include<iostream>

    using namespace std;

    int main()

    {

    int r,c,w,rem,nou;

    cin>>r;

    c=r;

    w=r;

    while(w>=3)

    {

    nou=w/3;

    c=c+nou;

    rem=w%3;

    w=rem+nou;

    }

    cout<<"you can buy "<<c<<" chocolates";

    return 0;

    }

  13. NOTE:
    At 4:51 Instead of selection sort bubble sort logic is used but selection sort logic was explained.
    Selection Sort Function is given below in c++:
    ************************************************
    void selectionSort(int a[], int n){

    for(int i = 0; i < n-1; i++){

    int min = i;

    for(int j = i+1; j < n; j++){

    if (a[min] > a[j])

    min = j;

    }

    int temp = a[i];

    a[i] = a[min];

    a[min] = temp;

    }

    }

  14. #include<iostream>

    using namespace std;

    const int rate=1;

    const int wrapper_rate=3;

    void sort(int*,int);

    int main(){

    cout<<"Enter the money you have($): "<<endl;

    int k{};

    cin>>k;

    int w{},n{};

    for(int i=k;i>0;i=i-rate){

    cout<<"Choclate"<<" "<<i<<endl;

    w++;

    if(w==wrapper_rate){

    i=i+rate;

    w=0;

    }

    n++;

    }

    cout<<"Total no of choclate you ate: "<<n;

    return 0;

    }

  15. The explanation os correct but the output of each iteration and the code explain in the vedio is not for selection sorting.
    Hope they might correct it.

Leave a Reply

Your email address will not be published. Required fields are marked *