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.
NỘI DUNG BÀI VIẾT
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.
>> 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.
code is wrong
Write an algorithm to find the longest sequence in order(ascending) from the given array: {23, 65, 15, 43, 10, 25, 35, 42, 18} and print the sequence. Write a C program for the same.
Didi ek baat batao agar
i<n-1 ke place pr i<n hii use kiya jaye toh bhi toh wohi result aa rha hai toh confusion ho rha hai
this is not selection sort
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;
}
I guess this is not selection sort
.The complexity is greater than expected. I am confused 🙄
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;
}
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;
}
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 ..
Bhai koi to batao inko ki ye galat hai, bubble sort ki algo mai selection explain karke chali gai ye ladki……..wtf man!!!!!!!!!!!!!!!!!1
Finally its Bubble Sort or Selection Sort? 🙄
Aise aadhe aadhe videos ke hi notes hai baki ke nahi aisa kyu?
We need another variable to store the minimum index.
In for loop why we take i is less than n-1. Please reply
Max 21 chocolate
This Video Tutorial is best for beginners. Who started learning C++. This tutorial also best for BCA/MCA B.scIT , M.sc IT and enginearing students.
https://youtu.be/hB8KYbKHnM8
You have done it by bubble sort not by selection sort..
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;
}
Mam but we have only 15 ₹..so apne last ek chocolate kha se kahridi
The way you explain is amazing. you make the concepts so easy understand. Thanks
This is bubble sort, not selection sort
I guess total 22 chocolates
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
wrong approach
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.
It's the code for bubble sort not of selection sort
The logic thought doesn't match with the code
maja aa gaya aaj to
//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
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!!!!!!!!!!😐😐😐
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;
}
End part puzzle was amazing 💥
Galat code
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;
}
this is wrong!!
This wasted lot of my time it wasn't selection sort bro 🙁
code wrong for selection sort
//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;
}
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;
}
}
Thank you
kya rappers paisa kama pa rhe he
#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;
}
From where we are getting money to buy the wrappers????
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.
why in first for loop there is i<n-1…plz answer ASAP