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
| public class BBSort | |
| { | |
| private void bubblesort(int [] arr) | |
| { | |
| int i = 1, temp; | |
| boolean swapped = true; | |
| while(swapped) | |
| { | |
| swapped = false; | |
| for(int j=0; j < arr.length - i ; j++) |
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
| public class QuickSortAlgo{ | |
| private void quicksort(int [] arr, int first, int last) | |
| { | |
| int left = first, pivot = first, right = last, temp; | |
| if (first<last) | |
| { | |
| while(left<right) | |
| { |
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 mergeSort(alist): | |
| print("Splitting ",alist) | |
| if len(alist)>1: | |
| mid = len(alist)//2 | |
| lefthalf = alist[:mid] | |
| righthalf = alist[mid:] | |
| mergeSort(lefthalf) | |
| mergeSort(righthalf) |
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 insertionsort(arr): | |
| for i in range(1,len(arr)): | |
| temp = arr[i] | |
| k = i | |
| while k>0 and temp < arr[k-1] : | |
| arr[k] = arr[k-1] | |
| k-=1 | |
| arr[k] = 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
| pixel = [ [0,1,2,3], | |
| [10,11,12,13], | |
| [20,21,22,23], | |
| [30,31,32,33] ] | |
| def rotateMatrix90(pixel): | |
| pixel_temp = [[0]*4 for _ in range(4)] | |
| print(pixel_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
| a = [ 2,2,3,4] | |
| b = [] | |
| print(a) | |
| temp = 1 | |
| length = len(a) | |
| for k in range(1,length): | |
| valk = k | |
| for i in range(length): | |
| for j in range(i+1,length): | |
| temp = 1 |
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
| a = [ 'a','b','c','d'] | |
| b = [] | |
| length = len(a) | |
| print(a) | |
| print(length) | |
| temp = 1 | |
| for k in range(1,length): | |
| valk = k | |
| for i in range(length): | |
| for j in range(i+1,length): |
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
| /* | |
| * nMalloc.cpp | |
| * | |
| * Created on: Dec 5, 2014 | |
| * Author: prasadnair | |
| */ | |
| #include <stdlib.h> | |
| #include <stdio.h> |
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
| package combinations; | |
| import java.util.*; | |
| import java.math.*; | |
| public class combPowerSet { | |
| //printing the charachters as per the number sent. | |
| void printNumber(int number, char [] items) | |
| { |
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
| #! /usr/env/path python | |
| class Solution: | |
| ##Complete this function | |
| #Function to find the sum of contiguous subarray with maximum sum. | |
| def maxSubArraySum(self,arr,N): | |
| ##Your code here | |
| if (N < 1) or (N > 1000000): | |
| print("error : invalid array size") |