Linear searching
#include<iostream>
using namespace std;
int linear_Searching(int[] ,int,int);
int main()
{
int list[]={1,6,8,9,0};
int n=sizeof(list)/sizeof(list[0]);
int key=0;
cout<<linear_Searching(list,n,key);
return 0;
}
int linear_Searching(int list[],int n,int key){
int index =0;
int found=0;
do{
if(key==list[index])
found=1;
else
index++;
}while(found==0 && index<n);
if (found==0)
return index =-1;
else
return index;
}
Binary searching alogrithm
#include<iostream>
using namespace std;
int Binary_Searching(int[],int,int);
int main()
{
int list[]= {1,2,3,4,7};
int key=7;
int size =sizeof(list)/sizeof(list[0]);
int n=Binary_Searching(list,key,size);
cout<<n;
return 0;
}
int Binary_Searching(int list[],int key,int size) {
int low=0;
int index,mid;
int high=size-1;
int found=0;
do {
mid=(high+low)/2;
if(key==list[mid])
found=1;
else if(list[mid]>key)
high=mid-1;
else if(list[mid]<key)
low=mid+1;
}while(found==0 && low<=high);
if (found==0)
index=-1;
else
index=mid;
return index;
}
👍2
Selection sorting
#include<iostream>
using namespace std;
int main()
{
int array[]= {6,8,2,9,3};
int n=sizeof(array)/sizeof(int);
int smallest,i,j,temp;
for(i=0; i<n; i++) {
smallest=i;
for(j=i+1; j<n; j++) {
if(array[j]<array[smallest]) {
smallest=j;
}
if(smallest!=i) {
temp=array[smallest];
array[smallest]=array[i];
array[i]=temp;
}
}
}
for(i=0; i<n; i++)
cout<<array[i]<<endl;
}
👍4
If you have any question feel free to ask anything .I am here to help
Bot:@Knowledgewis_bot
በTon Coin የሚከፍላቹህ እሰከ 5 Ton ከዛ በላይ ይከፍላል 100% የተሞከረ ነው
አሁኑኑ Start ብለው ይጀምሩ
https://news.1rj.ru/str/preton_drop_bot?start=385f7875-83ed-46c0-ae68-d26abc092e38
Telegram
$PRETON DROP
Preton community: @preton
Preton community: @preton_cis
Chat: @chat_preton
Cooperation: @eleidans
Preton community: @preton_cis
Chat: @chat_preton
Cooperation: @eleidans
👏1
Capturing the beauty of life, one frame at a time. Welcome to Ume Photography Channel, where every click tells a story. Join me on a visual journey through breathtaking landscapes, captivating portraits, and mesmerizing moments frozen in time. Whether you're an aspiring photographer or simply a lover of art, my channel is your gateway to a world of creativity and inspiration. Subscribe now and let's embark on an unforgettable exploration of the world through my lens.
Link:@umephotography
#Ume photography
#Art 💻
#Freshman Tips
👍1
"Refer your friends to the Ton Digging💎 Bot and earn 0.1 Ton coins for each successful referral.
Share your unique referral link with friends and watch your Ton coin balance grow with every new member you bring on board.
https://news.1rj.ru/str/Ton_Coin_Digging_robot?start=r02111307690
Start spreading the word and enjoy the rewards of building your Ton coin network today!"
Share your unique referral link with friends and watch your Ton coin balance grow with every new member you bring on board.
https://news.1rj.ru/str/Ton_Coin_Digging_robot?start=r02111307690
Start spreading the word and enjoy the rewards of building your Ton coin network today!"