Programming
Programming
#include <iostream>
using namespace std;
//sequential
int main()
{
int size[5]={12, 23, 45, 67, 100};
int target;
int d=1;
cout<<"enter the number your looking for: ";
cin>>target;
for(int i=0; i<5; i++)
{
if(target == size[i])
{
break;
}
d++;
}
if(d >= 1)
{
cout<<"you found: "<<target<<" on index: "<<d<<endl;
}
else
{
cout<<"the number you input is not in the array";
}
return 0;
}
FLOWCHART OF SEQUENTIAL
START
target
true
END break target==size[i]
false
d++
false
cin>>target;
while
(high>=low)
midpoint=(low+high)/2;
TREU
if (target == cout<<"found on
size[midpoint]) number: "<<midpoint;
FALSE
break;
else if(target
high = midpoint-1;
<size[midpoint])
TREU
END
FALSE
TREU
else if (target >
low = midpoint+1;
size[midpoint])
FALSE
#include <iostream>
//SHORTING
arr[j + 1] = temp;
int main() {
int size=5;
cout << "Enter " << size << " elements: ";
bubbleSort(arr, size);
delete[] arr;
return 0;
}
DOBBLE FOWCHART
START
int size=5;
int *arr = new int[size];
endl
cin >> arr[i];
bubbleSort(arr, size);
false
true
END
SELECTION
#include <iostream>
//Selection shorting
int main()
cout<<sorting[i]<<", ";
cout<<endl<<endl;
int small = i;
small = b;
if(small != i)
sorting[i] = sorting[small];
sorting[small] = palit;
cout<<sorting[i]<<", ";
return 0;
}
DOBLE FLOWCHART