Forwarded from تقنية معلومات IT & علوم حاسوب CS ( مراجع ، ملخصات ، مشاريع ، نماذج ، محاضرات فيديو وصوت ومستند)
المختصر المفيد
معمارية عملي
أكرم لقمان
معمارية عملي
أكرم لقمان
تعديل هاااااااام‼️‼️‼️
الإختبار بايكون بكرة الساعة 10 للقسمين.
خلينا الكنترول يتواصل مع الاستاذه ويأخذ منها الإختبار ويختبرونا بكرة حسب الموعد
لان الاختبار لو تأجل للسبت باتتلخبط المذاكرة على الكل وممكن يحدث فورمات.
الإختبار بايكون بكرة الساعة 10 للقسمين.
خلينا الكنترول يتواصل مع الاستاذه ويأخذ منها الإختبار ويختبرونا بكرة حسب الموعد
لان الاختبار لو تأجل للسبت باتتلخبط المذاكرة على الكل وممكن يحدث فورمات.
سلام. امتحان المحملين 12-9 والمستجدين 19-9 لذا يوم 26 سوف يكون في الاسبوع الثاني. يرجى مراجعة الجدول واذا فيه اي تعديلات يتم ارسال الجدول من جديد
Information Technology "IT" - level 4
سلام. امتحان المحملين 12-9 والمستجدين 19-9 لذا يوم 26 سوف يكون في الاسبوع الثاني. يرجى مراجعة الجدول واذا فيه اي تعديلات يتم ارسال الجدول من جديد
بايكون هناك تعديل بسيط في الجدول برسله لكم اليوم
Forwarded from ❥͢ ❈↡< C++ > برمجة (❥ツ)
إ₰...👨🏻💻CODE👩🏻💻...₰❥
#Binary_Tree
خــوارزمــيات الاشـجار الثنــائية:-
1⃣ كــود #اضــافـة العقد والأبناء.
2⃣كــود #طــباعــة العناصر مرتبة.
3⃣كــود #البــحـث عن عنصر بالأشجار الثنائية.
4⃣كــود #ايــجـاد اكبر واصغر عنصر بالشجرة.
5⃣كــود #تــرتيب الشجرة بطرقها الثلاث
preorder , inorder , postorder
6⃣كــود #حــذف عقدة من الشجرة سواء كانت تحمل ...
one child ,no child , two child
#include <iostream>
using namespace std;
struct node
{
int data;
node *left;
node *right;
};
node *NewNode(int data)
{
node *Node = new node;
Node->data = data;
Node->left = NULL;
Node->right = NULL;
return Node;
}
node *insertNode(node *&root, int val)
{
if (root == NULL)
{
node *newNode = NewNode(val);
root = newNode;
}
else if (val <= root->data)
root->left = insertNode(root->left, val);
else
root->right = insertNode(root->right, val);
return root;
}
void print(node *root)
{
if (root != NULL)
{
print(root->left);
cout << root->data << " ";
print(root->right);
}
}
node *search(node *root, int data)
{
if (root == NULL)
{
return NULL;
}
else if (root->data == data)
{
return root;
}
else if (data < root->data)
{
return search(root->left, data);
}
else if (data > root->data)
{
return search(root->right, data);
}
}
void postorder(node *root)
{
if (root)
{
postorder(root->left);
postorder(root->right);
cout << root->data << " ";
}
}
void Inorder(node *root)
{
if (root)
{
Inorder(root->left);
cout << root->data << " ";
Inorder(root->right);
}
}
void preorder(node *root)
{
if (root)
{
cout << root->data << " ";
preorder(root->left);
preorder(root->right);
}
}
node *findMin(node *root)
{
node *temp = root;
while (temp->left != NULL)
temp = temp->left;
return temp;
}
node *findMax(node *root)
{
node *temp = root;
while (temp->right != NULL)
temp = temp->right;
cout << temp->data;
return temp;
}
node *deleteNode(node *root, int data)
{
if (root == NULL)
return root;
else if (data < root->data)
root->left = deleteNode(root->left, data);
else if (data > root->data)
root->right = deleteNode(root->right, data);
else
{
//case 1 ....> No child
if (root->left == NULL && root->right == NULL)
{
delete root;
root = NULL;
}
//case 2 .....> One child
else if (root->left == NULL)
{
node *temp = root;
root = root->right;
delete temp;
}
else if (root->right == NULL)
{
node *temp = root;
root = root->left;
delete temp;
}
//case 3 .......> Two child
else
{
node *temp = findMin(root->right);
root->data = temp->data;
root->right = deleteNode(root->right, temp->data);
}
}
return root;
}
int main()
{
node *root = NULL;
node *item;
insertNode(root, 5);
insertNode(root, 1);
insertNode(root, 8);
insertNode(root, 7);
insertNode(root, 2);
insertNode(root, 9);
insertNode(root, 50);
insertNode(root, 4);
cout << "Binary sorted Tree :-" << endl;
print(root);
cout << endl;
cout << endl
<< "postorder " << endl;
postorder(root);
cout << endl
<< "*-*-*-*-*-*-*-*-*-*-*-*";
cout << endl
<< "Inorder " << endl;
Inorder(root);
cout << endl
<< "*-*-*-*-*-*-*-*-*-*-*-*";
cout << endl
<< "preorder " << endl;
preorder(root);
cout << endl
<< "*-*-*-*-*-*-*-*-*-*-*-*" << endl;
cout << endl
<< "max element : ";
findMax(root);
cout << endl
<< "*-*-*-*-*-*-*-*-*-*-*-*" << endl;
int SearchValue;
cout << "enter the value :";
cin >> SearchValue;
item = search(root, SearchValue);
if (item == NULL)
cout << "Not found ..\n";
else
cout << "found..\n";
cout << "*-*-*-*-*-*-*-*-*-*-*-*" << endl;
cout << "delete element 9:-" << endl;
root = deleteNode(root, 9);
print(root);
cout << endl;
cout << "delete element 2 :-" << endl;
root = deleteNode(root, 2);
print(root);
cout << endl;
cout << "delete element 8 :-" << endl;
root = deleteNode(root, 8);
print(root);
cout << endl;
return 0;
}
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja↷
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
#Binary_Tree
خــوارزمــيات الاشـجار الثنــائية:-
1⃣ كــود #اضــافـة العقد والأبناء.
2⃣كــود #طــباعــة العناصر مرتبة.
3⃣كــود #البــحـث عن عنصر بالأشجار الثنائية.
4⃣كــود #ايــجـاد اكبر واصغر عنصر بالشجرة.
5⃣كــود #تــرتيب الشجرة بطرقها الثلاث
preorder , inorder , postorder
6⃣كــود #حــذف عقدة من الشجرة سواء كانت تحمل ...
one child ,no child , two child
#include <iostream>
using namespace std;
struct node
{
int data;
node *left;
node *right;
};
node *NewNode(int data)
{
node *Node = new node;
Node->data = data;
Node->left = NULL;
Node->right = NULL;
return Node;
}
node *insertNode(node *&root, int val)
{
if (root == NULL)
{
node *newNode = NewNode(val);
root = newNode;
}
else if (val <= root->data)
root->left = insertNode(root->left, val);
else
root->right = insertNode(root->right, val);
return root;
}
void print(node *root)
{
if (root != NULL)
{
print(root->left);
cout << root->data << " ";
print(root->right);
}
}
node *search(node *root, int data)
{
if (root == NULL)
{
return NULL;
}
else if (root->data == data)
{
return root;
}
else if (data < root->data)
{
return search(root->left, data);
}
else if (data > root->data)
{
return search(root->right, data);
}
}
void postorder(node *root)
{
if (root)
{
postorder(root->left);
postorder(root->right);
cout << root->data << " ";
}
}
void Inorder(node *root)
{
if (root)
{
Inorder(root->left);
cout << root->data << " ";
Inorder(root->right);
}
}
void preorder(node *root)
{
if (root)
{
cout << root->data << " ";
preorder(root->left);
preorder(root->right);
}
}
node *findMin(node *root)
{
node *temp = root;
while (temp->left != NULL)
temp = temp->left;
return temp;
}
node *findMax(node *root)
{
node *temp = root;
while (temp->right != NULL)
temp = temp->right;
cout << temp->data;
return temp;
}
node *deleteNode(node *root, int data)
{
if (root == NULL)
return root;
else if (data < root->data)
root->left = deleteNode(root->left, data);
else if (data > root->data)
root->right = deleteNode(root->right, data);
else
{
//case 1 ....> No child
if (root->left == NULL && root->right == NULL)
{
delete root;
root = NULL;
}
//case 2 .....> One child
else if (root->left == NULL)
{
node *temp = root;
root = root->right;
delete temp;
}
else if (root->right == NULL)
{
node *temp = root;
root = root->left;
delete temp;
}
//case 3 .......> Two child
else
{
node *temp = findMin(root->right);
root->data = temp->data;
root->right = deleteNode(root->right, temp->data);
}
}
return root;
}
int main()
{
node *root = NULL;
node *item;
insertNode(root, 5);
insertNode(root, 1);
insertNode(root, 8);
insertNode(root, 7);
insertNode(root, 2);
insertNode(root, 9);
insertNode(root, 50);
insertNode(root, 4);
cout << "Binary sorted Tree :-" << endl;
print(root);
cout << endl;
cout << endl
<< "postorder " << endl;
postorder(root);
cout << endl
<< "*-*-*-*-*-*-*-*-*-*-*-*";
cout << endl
<< "Inorder " << endl;
Inorder(root);
cout << endl
<< "*-*-*-*-*-*-*-*-*-*-*-*";
cout << endl
<< "preorder " << endl;
preorder(root);
cout << endl
<< "*-*-*-*-*-*-*-*-*-*-*-*" << endl;
cout << endl
<< "max element : ";
findMax(root);
cout << endl
<< "*-*-*-*-*-*-*-*-*-*-*-*" << endl;
int SearchValue;
cout << "enter the value :";
cin >> SearchValue;
item = search(root, SearchValue);
if (item == NULL)
cout << "Not found ..\n";
else
cout << "found..\n";
cout << "*-*-*-*-*-*-*-*-*-*-*-*" << endl;
cout << "delete element 9:-" << endl;
root = deleteNode(root, 9);
print(root);
cout << endl;
cout << "delete element 2 :-" << endl;
root = deleteNode(root, 2);
print(root);
cout << endl;
cout << "delete element 8 :-" << endl;
root = deleteNode(root, 8);
print(root);
cout << endl;
return 0;
}
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja↷
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
Forwarded from ❥͢ ❈↡< C++ > برمجة (❥ツ)
إ₰...Output....₰❥
Binary sorted Tree :-
1 2 4 5 7 8 9 50
postorder
4 2 1 7 50 9 8 5
*-*-*-*-*-*-*-*-*-*-*-*
Inorder
1 2 4 5 7 8 9 50
*-*-*-*-*-*-*-*-*-*-*-*
preorder
5 1 2 4 8 7 9 50
*-*-*-*-*-*-*-*-*-*-*-*
max element : 50
*-*-*-*-*-*-*-*-*-*-*-*
enter the value :6
Not found ..
*-*-*-*-*-*-*-*-*-*-*-*
delete element 9:-
1 2 4 5 7 8 50
delete element 2 :-
1 4 5 7 8 50
delete element 8 :-
1 4 5 7 50
[Program finished]
Binary sorted Tree :-
1 2 4 5 7 8 9 50
postorder
4 2 1 7 50 9 8 5
*-*-*-*-*-*-*-*-*-*-*-*
Inorder
1 2 4 5 7 8 9 50
*-*-*-*-*-*-*-*-*-*-*-*
preorder
5 1 2 4 8 7 9 50
*-*-*-*-*-*-*-*-*-*-*-*
max element : 50
*-*-*-*-*-*-*-*-*-*-*-*
enter the value :6
Not found ..
*-*-*-*-*-*-*-*-*-*-*-*
delete element 9:-
1 2 4 5 7 8 50
delete element 2 :-
1 4 5 7 8 50
delete element 8 :-
1 4 5 7 50
[Program finished]
Forwarded from ❥͢ ❈↡< C++ > برمجة (❥ツ)
إ₰...👨🏻💻CODE👩🏻💻...₰❥
#Binary_Search_Algorithm
خـوارزمــية البــحث الـثــنائـي:-
#include <iostream>
using namespace std;
int BinarySearch(int array[], int Size, int SearchValue)
{
int low = 0;
int high = Size - 1;
int mid ;
while (low <= high)
{
mid = (low + high) / 2;
if (SearchValue == array[mid])
{
return mid;
}
else if (SearchValue > array[mid])
{
low = mid + 1;
}
else
{
high = mid - 1;
}
}
return -1;
}
int main()
{
int a[] ={11, 32, 43, 54, 65, 76, 87, 98};
int value;
cout << "enter an integer :" << endl;
cin >> value;
int result = BinarySearch(a, 8, value);
if (result >= 0)
{
cout << "the number " << a[result] << " was found at the element with index " << result << endl;
}
else
{
cout << "the number " << value << " was not found " << endl;
}
}
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja↷
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
إ₰...Output....₰❥
enter an integer :
3
the number 3 was not found [Program finished]
-*-*-*-*-*-*-*-*-*-*-*-*-*
enter an integer :
98
the number 98 was found at the element with index 7
[Program finished]
#Binary_Search_Algorithm
خـوارزمــية البــحث الـثــنائـي:-
#include <iostream>
using namespace std;
int BinarySearch(int array[], int Size, int SearchValue)
{
int low = 0;
int high = Size - 1;
int mid ;
while (low <= high)
{
mid = (low + high) / 2;
if (SearchValue == array[mid])
{
return mid;
}
else if (SearchValue > array[mid])
{
low = mid + 1;
}
else
{
high = mid - 1;
}
}
return -1;
}
int main()
{
int a[] ={11, 32, 43, 54, 65, 76, 87, 98};
int value;
cout << "enter an integer :" << endl;
cin >> value;
int result = BinarySearch(a, 8, value);
if (result >= 0)
{
cout << "the number " << a[result] << " was found at the element with index " << result << endl;
}
else
{
cout << "the number " << value << " was not found " << endl;
}
}
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja↷
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
إ₰...Output....₰❥
enter an integer :
3
the number 3 was not found [Program finished]
-*-*-*-*-*-*-*-*-*-*-*-*-*
enter an integer :
98
the number 98 was found at the element with index 7
[Program finished]
Forwarded from ❥͢ ❈↡< C++ > برمجة (❥ツ)
إ₰...👨🏻💻CODE👩🏻💻...₰❥
#insertion_sort
خوارزمية الترتيب بالإدراج
#include <iostream>
using namespace std;
void insertionSort(int a[], int Size)
{
int key, i, j;
for (i = 1; i < Size; i++)
{
key = a[i];
j = i;
while (j > 0 && a[j - 1] > key)
{
a[j] = a[j - 1];
j -= 1;
}
a[j] = key;
}
}
void printArray(int a[], int Size)
{
for (int i = 0; i < Size; i++)
{
cout << a[i] << " ";
}
cout << endl;
}
int main()
{
int a[11] = {9, 2, 5, 7, 1, 6, 3, 4, 8, 0, 10};
int Size = sizeof(a) / sizeof(a[0]);
cout << "Array befor sorted....\n";
printArray(a, Size);
insertionSort(a, Size);
cout << "Array after sorted....\n";
printArray(a, Size);
return 0;
}
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja↷
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
إ₰...Output....₰❥
Array befor sorted....
9 2 5 7 1 6 3 4 8 0 10
Array after sorted....
0 1 2 3 4 5 6 7 8 9 10
[Program finished]
#insertion_sort
خوارزمية الترتيب بالإدراج
#include <iostream>
using namespace std;
void insertionSort(int a[], int Size)
{
int key, i, j;
for (i = 1; i < Size; i++)
{
key = a[i];
j = i;
while (j > 0 && a[j - 1] > key)
{
a[j] = a[j - 1];
j -= 1;
}
a[j] = key;
}
}
void printArray(int a[], int Size)
{
for (int i = 0; i < Size; i++)
{
cout << a[i] << " ";
}
cout << endl;
}
int main()
{
int a[11] = {9, 2, 5, 7, 1, 6, 3, 4, 8, 0, 10};
int Size = sizeof(a) / sizeof(a[0]);
cout << "Array befor sorted....\n";
printArray(a, Size);
insertionSort(a, Size);
cout << "Array after sorted....\n";
printArray(a, Size);
return 0;
}
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja↷
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
إ₰...Output....₰❥
Array befor sorted....
9 2 5 7 1 6 3 4 8 0 10
Array after sorted....
0 1 2 3 4 5 6 7 8 9 10
[Program finished]
Forwarded from ❥͢ ❈↡< C++ > برمجة (❥ツ)
إ₰...👨🏻💻CODE👩🏻💻...₰❥
#selection_sort
خوارزمية الترتيب بالأختيار
#include <iostream>
using namespace std;
void selectionSort(int arr[], int Size)
{
int min, i, j, temp;
for (i = 0; i < Size; i++)
{
min = i;
for (j = i + 1; j < Size; j++)
{
if (arr[j] < arr[min])
min = j;
}
temp = arr[i];
arr[i] = arr[min];
arr[min] = temp;
}
}
void printArray(int arr[], int Size)
{
for (int i = 0; i < Size; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
int main()
{
int arr[10] = {2, 5, 4, 3, 8, 1, 9, 0, 7, 6};
int Size = sizeof(arr) / 4;
cout << "Array befor sorted....\n";
printArray(arr, Size);
selectionSort(arr, Size);
cout << "Array after sorted....\n";
printArray(arr, Size);
return 0;
}
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja↷
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
إ₰...Output....₰❥
Array befor sorted...
2 5 4 3 8 1 9 0 7 6 Array after sorted....
0 1 2 3 4 5 6 7 8 9 [Program finished]
#selection_sort
خوارزمية الترتيب بالأختيار
#include <iostream>
using namespace std;
void selectionSort(int arr[], int Size)
{
int min, i, j, temp;
for (i = 0; i < Size; i++)
{
min = i;
for (j = i + 1; j < Size; j++)
{
if (arr[j] < arr[min])
min = j;
}
temp = arr[i];
arr[i] = arr[min];
arr[min] = temp;
}
}
void printArray(int arr[], int Size)
{
for (int i = 0; i < Size; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
int main()
{
int arr[10] = {2, 5, 4, 3, 8, 1, 9, 0, 7, 6};
int Size = sizeof(arr) / 4;
cout << "Array befor sorted....\n";
printArray(arr, Size);
selectionSort(arr, Size);
cout << "Array after sorted....\n";
printArray(arr, Size);
return 0;
}
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja↷
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
إ₰...Output....₰❥
Array befor sorted...
2 5 4 3 8 1 9 0 7 6 Array after sorted....
0 1 2 3 4 5 6 7 8 9 [Program finished]
Forwarded from ❥͢ ❈↡< C++ > برمجة (❥ツ)
إ₰...👨🏻💻CODE👩🏻💻...₰❥
#Merge_Sort
خــوارزمية الـفرز بالــدمج :-
#include <iostream>
using namespace std;
void merge(int arr[], int start, int mid, int end)
{
int i, j, k;
int len1 = mid - start + 1;
int len2 = end - mid;
int *L, *R;
L = new int[len1];
R = new int[len2];
for (i = 0; i < len1; i++)
L[i] = arr[start + i];
for (j = 0; j < len2; j++)
R[j] = arr[mid + 1 + j];
i = j = 0;
k = start;
while (i < len1 && j < len2)
{
if (L[i] <= R[j])
{
arr[k] = L[i];
i++;
}
else
{
arr[k] = R[j];
j++;
}
k++;
}
while (i < len1)
{
arr[k] = L[i];
i++;
k++;
}
while (j < len2)
{
arr[k] = R[j];
j++;
k++;
}
} //end merge_function
void mergeSort(int arr[], int start, int end)
{
int mid;
if (start < end)
{
mid = (start + end) / 2;
mergeSort(arr, start, mid);
mergeSort(arr, mid + 1, end);
merge(arr, start, mid, end);
}
return;
} //end mergeSort_function
void print(int arr[], int Size)
{
for (int i = 0; i < Size; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
int main()
{
int arr[10] = {2, 5, 9, 1, 40, 0, 8, 1, 7, 25};
int Size = sizeof(arr) / 4;
cout << "array befor sorted...\n";
print(arr, Size);
mergeSort(arr, 0, Size - 1);
cout << "array after sorted...\n";
print(arr, Size);
return 0;
} //end main
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja↷
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
إ₰...Output....₰❥
array befor sorted...
2 5 9 1 40 0 8 1 7 25
array after sorted...
0 1 1 2 5 7 8 9 25 40 [Program finished]
#Merge_Sort
خــوارزمية الـفرز بالــدمج :-
#include <iostream>
using namespace std;
void merge(int arr[], int start, int mid, int end)
{
int i, j, k;
int len1 = mid - start + 1;
int len2 = end - mid;
int *L, *R;
L = new int[len1];
R = new int[len2];
for (i = 0; i < len1; i++)
L[i] = arr[start + i];
for (j = 0; j < len2; j++)
R[j] = arr[mid + 1 + j];
i = j = 0;
k = start;
while (i < len1 && j < len2)
{
if (L[i] <= R[j])
{
arr[k] = L[i];
i++;
}
else
{
arr[k] = R[j];
j++;
}
k++;
}
while (i < len1)
{
arr[k] = L[i];
i++;
k++;
}
while (j < len2)
{
arr[k] = R[j];
j++;
k++;
}
} //end merge_function
void mergeSort(int arr[], int start, int end)
{
int mid;
if (start < end)
{
mid = (start + end) / 2;
mergeSort(arr, start, mid);
mergeSort(arr, mid + 1, end);
merge(arr, start, mid, end);
}
return;
} //end mergeSort_function
void print(int arr[], int Size)
{
for (int i = 0; i < Size; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
int main()
{
int arr[10] = {2, 5, 9, 1, 40, 0, 8, 1, 7, 25};
int Size = sizeof(arr) / 4;
cout << "array befor sorted...\n";
print(arr, Size);
mergeSort(arr, 0, Size - 1);
cout << "array after sorted...\n";
print(arr, Size);
return 0;
} //end main
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja↷
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
إ₰...Output....₰❥
array befor sorted...
2 5 9 1 40 0 8 1 7 25
array after sorted...
0 1 1 2 5 7 8 9 25 40 [Program finished]
Forwarded from ❥͢ ❈↡< C++ > برمجة (❥ツ)
إ₰...👨🏻💻CODE👩🏻💻...₰❥
#Quick_Sort
خــوارزمــية الفــرز الســريع :-
#include <iostream>
using namespace std;
int partition(int arr[], int low, int high)
{
int temp;
int pivot = arr[low];
int i = low + 1;
for (int j = low + 1; j <= high; j++)
{
if (arr[j] <= pivot)
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++;
}
}
temp = arr[low];
arr[low] = arr[i - 1];
arr[i - 1] = temp;
return (i - 1);
}
void quickSort(int arr[], int low, int high)
{
if (low < high)
{
int pivot = partition(arr, low, high);
quickSort(arr, low, pivot - 1);
quickSort(arr, pivot + 1, high);
}
}
void print(int arr[], int Size)
{
for (int i = 0; i < Size; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
int main()
{
int arr[10] = {2, 5, 9, 85, 40, 0, 8, 1, 7, 25};
int Size = sizeof(arr) / 4;
cout << "Array befor sorted....\n";
print(arr, Size);
quickSort(arr, 0, Size - 1);
cout << "Array after sorted....\n";
print(arr, Size);
return 0;
}
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja↷
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
إ₰...Output....₰❥
Array befor sorted....
2 5 9 85 40 0 8 1 7 25
Array after sorted....
0 1 2 5 7 8 9 25 40 85
[Program finished]
#Quick_Sort
خــوارزمــية الفــرز الســريع :-
#include <iostream>
using namespace std;
int partition(int arr[], int low, int high)
{
int temp;
int pivot = arr[low];
int i = low + 1;
for (int j = low + 1; j <= high; j++)
{
if (arr[j] <= pivot)
{
temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
i++;
}
}
temp = arr[low];
arr[low] = arr[i - 1];
arr[i - 1] = temp;
return (i - 1);
}
void quickSort(int arr[], int low, int high)
{
if (low < high)
{
int pivot = partition(arr, low, high);
quickSort(arr, low, pivot - 1);
quickSort(arr, pivot + 1, high);
}
}
void print(int arr[], int Size)
{
for (int i = 0; i < Size; i++)
{
cout << arr[i] << " ";
}
cout << endl;
}
int main()
{
int arr[10] = {2, 5, 9, 85, 40, 0, 8, 1, 7, 25};
int Size = sizeof(arr) / 4;
cout << "Array befor sorted....\n";
print(arr, Size);
quickSort(arr, 0, Size - 1);
cout << "Array after sorted....\n";
print(arr, Size);
return 0;
}
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
❥➺┊ @barrmaja↷
•┈┈┈•❈••✦✾✦••❈•┈┈┈•
إ₰...Output....₰❥
Array befor sorted....
2 5 9 85 40 0 8 1 7 25
Array after sorted....
0 1 2 5 7 8 9 25 40 85
[Program finished]
تم تأجيل مناقشة فيديوهات برمجة مرئية عملي ليوم الثلاثاء القادم.