This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def radixsort(arr): | |
bins = [] | |
for i in range(0,10): #Creating empty bins | |
bins.append([]) | |
a = 10 #To extract one's digit | |
b = 1 | |
while True: | |
result = [] | |
for elem in arr: | |
digit = (elem % a) // b #Extracting one's digit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class Animal{ | |
static int population = 0; | |
public Animal(){ | |
System.out.println("Animal object created"); | |
population += 1; | |
} | |
} | |
class Person{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class example{ | |
private int data; | |
public example(int d){ | |
data = d; | |
} | |
public int getdata(){ | |
return data; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class singletonExample | |
{ | |
public static singletonExample obj = null; | |
private singletonExample() | |
{ | |
System.out.println("Created object"); | |
} | |
public static singletonExample createObject() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class Employee | |
{ | |
private String name; | |
private int salary; | |
public Employee(String name,int salary){ | |
this.salary = salary; | |
this.name = name; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
public class Main | |
{ | |
static void swapElements(int[] arr,int i,int j) | |
{ | |
int temp = arr[i]; | |
arr[i] = arr[j]; | |
arr[j] = temp; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class Ideone | |
{ | |
static int[] slice(int[] arr, int start, int end) | |
{ | |
int[] result = new int[end-start]; | |
for(int i = 0; i < result.length; i ++) | |
{ | |
result[i] = arr[start+i]; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
class Ideone | |
{ | |
static void printArray(int[] arr) | |
{ | |
for(int i = 0; i < arr.length; i++) | |
{ | |
System.out.print(arr[i]); | |
System.out.print(" "); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def quicksort(arr): | |
if len(arr) <= 1: | |
return arr | |
else: | |
pivot = arr[0] | |
less = [] | |
equal = [] | |
more = [] | |
for elem in arr: | |
if elem < pivot: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* super.super is not allowed in Java. */ | |
import java.io.*; | |
class A | |
{ | |
private int a_data; | |
public A(int a_data) | |
{ | |
System.out.println("Class A constructor is called"); | |
this.a_data = a_data; |