Skip to content

Instantly share code, notes, and snippets.

View YassineBajdou's full-sized avatar

Yassine Bajdou YassineBajdou

  • Howdy Code
  • Fes
View GitHub Profile
@YassineBajdou
YassineBajdou / objects2.js
Created April 19, 2019 08:59
objects2.js
let sammy = {
firstName: "Sammy",
lastName: "Shark",
color: "blue",
location: "Ocean"
};
@YassineBajdou
YassineBajdou / objects1.js
Created April 19, 2019 08:58
objects1.js
let sammy = {firstName:"Sammy", lastName:"Shark", color:"blue", location:"ocean"};
@YassineBajdou
YassineBajdou / array1.js
Created April 19, 2019 08:53
array1.js
let fish = ["shark", "cuttlefish", "clownfish", "eel"];
@YassineBajdou
YassineBajdou / hello-world.js
Created April 17, 2019 08:30
hello-world.js
<script>
let hw = "Hello, World!";
function helloFunction() {
alert(hw);
}
</script>
@YassineBajdou
YassineBajdou / hello-world.html
Last active April 17, 2019 08:30
Hello, World! JS
<!DOCTYPE HTML>
<html>
<head>
<script>
function helloFunction() {
alert("Hello, World!");
}
</script>
</head>
<body>
@YassineBajdou
YassineBajdou / Infinity-loop.js
Created April 17, 2019 08:18
Infinity-loop.js
while (num9 != Infinity) {
// Code here will execute through num9 = Infinity
}
int rand_partition ( int A[ ] , int start , int end ) {
//chooses position of pivot randomly by using rand() function .
int random = start + rand( )%(end-start +1 ) ;
swap ( A[random] , A[start]) ; //swap pivot with 1st element.
return partition(A,start ,end) ; //call the above partition function
}
@YassineBajdou
YassineBajdou / Quick-Sort02.cpp
Created January 11, 2019 11:05
The recursive function Quick_sort
void quick_sort ( int A[ ] ,int start , int end ) {
if( start < end ) {
//stores the position of pivot element
int piv_pos = partition (A,start , end ) ;
quick_sort (A,start , piv_pos -1); //sorts the left side of pivot.
quick_sort ( A,piv_pos +1 , end) ; //sorts the right side of pivot.
}
}
int partition ( int A[],int start ,int end) {
int i = start + 1;
int piv = A[start] ; //make the first element as pivot element.
for(int j =start + 1; j <= end ; j++ ) {
/*rearrange the array by putting elements which are less than pivot
on one side and which are greater that on other. */
if ( A[ j ] < piv) {
swap (A[ i ],A [ j ]);
i += 1;
void insertion_sort ( int A[ ] , int n)
{
for( int i = 0 ;i < n ; i++ ) {
/*storing current element whose left side is checked for its
correct position .*/
int temp = A[ i ];
int j = i;
/* check whether the adjacent element in left side is greater or