Skip to content

Instantly share code, notes, and snippets.

View syedjafer's full-sized avatar
🎯
Focusing

syedjafer_k syedjafer

🎯
Focusing
View GitHub Profile
def find_max_min(array):
max_val, min_val = None, None
if len(array) == 1:
max_val = min_val = array[0]
elif array:
max_val, min_val = (array[0], array[1]) if array[0] > array[1] else (array[1], array[0])
for itr in array[2:]:
if itr > max_val:
function partition(array, low, high){
var pivot = array[high];
var partition_index = low;
var temp;
for (var itr=low; itr<high; itr++){
if (array[itr]<pivot){
temp = array[itr];
array[itr] = array[partition_index];
array[partition_index] = temp;
partition_index += 1
public class QSort{
static void printArray(int[] arr, int size)
{
for(int i = 0; i < size; i++)
System.out.print(arr[i] + " ");
System.out.println();
}
def partition(array, start, end):
pivot = array[end]
partition_index = start
for itr in range(start, end):
if array[itr] < pivot:
array[partition_index], array[itr] = array[itr], array[partition_index]
partition_index += 1
array[partition_index], array[end] = array[end], array[partition_index]
return partition_index
function partition(array, low, high){
var pivot = array[high];
var partition_index = low;
var temp;
for (var itr=low; itr<high; itr++){
if (array[itr]<pivot){
temp = array[itr];
array[itr] = array[partition_index];
array[partition_index] = temp;
partition_index += 1
public class QSort{
static void printArray(int[] arr, int size)
{
for(int i = 0; i < size; i++)
System.out.print(arr[i] + " ");
System.out.println();
}
def partition(array, start, end):
pivot = array[end]
partition_index = start
print(pivot, partition_index)
for itr in range(start, end):
if array[itr] < pivot:
array[partition_index], array[itr] = array[itr], array[partition_index]
partition_index += 1
print(array)
array[partition_index], array[end] = array[end], array[partition_index]
var arr = [1, 2, 3, 4, 5];
arr.reverse()
console.log(arr)
import java.util.*;
public class Main {
/*function reverses the elements of the array*/
static void reverse(Integer myArray[])
{
Collections.reverse(Arrays.asList(myArray));
System.out.println("Reversed Array:" + Arrays.asList(myArray));
}
arr = [1, 2, 3, 4, 5]
arr.reverse()
print(arr)