Skip to content

Instantly share code, notes, and snippets.

View prasadwrites's full-sized avatar

Prasad prasadwrites

View GitHub Profile
@prasadwrites
prasadwrites / bfsalgo.c
Last active August 29, 2015 14:05
BFS algorithm
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int data;
node *left, *right;
}node;
//prototypes of functions
int height (node *);
@prasadwrites
prasadwrites / bt_dfs.c
Last active August 29, 2015 14:05
BT_traverse
#include <stdio.h>
#include <stdlib.h>
struct node {
struct node *left;
int data ;
struct node *right;
};
struct node *root = NULL;
@prasadwrites
prasadwrites / bt_printLevelOrder.c
Last active August 29, 2015 14:05
Print level order for a Binary Tree.
#include <stdio.h>
#include <stdlib.h>
typedef struct node {
int data;
node *left, *right;
}node;
//prototypes of functions
int height (node *);
//compiled with compileonline.com
//http://www.compileonline.com/compile_objective-c_online.php
//also compiled using GNUSetup on windows.
#import <Foundation/Foundation.h>
@interface Book : NSObject
{
char * title;
#! /usr/env/path python
items = [2,5,6,7,8,5,0,1,2,3,4]
def quick_sort(items):
""" Implementation of quick sort """
if len(items) > 1:
pivot_index = len(items) // 2
smaller_items = []
larger_items = []
@prasadwrites
prasadwrites / quicksort.py
Last active July 6, 2023 18:10
QuickSort InPlace Python
items = [2,5,6,7,8,5,0,1,9,3,4]
#items = [3, 4, 5, 2 ,1]
def quick_sort(items,first,last):
""" Implementation of in-place quicksort """
if(first < last):
pivot, left, right = first, first, last
while(left<right):
@prasadwrites
prasadwrites / Quicksort.c
Created November 17, 2014 05:23
In Place Quicksort in C language
#include<stdio.h>
void quicksort(int [10],int,int);
int main(){
int x[20],size,i;
printf("Enter size of the array: ");
scanf("%d",&size);
@prasadwrites
prasadwrites / bubblesort.py
Last active August 29, 2015 14:09
BubbleSort
#! /usr/env/path python
arr = [6,5,4,7,8,4,3,2,1,45,23,67,34]
def bubble_sort(arr):
swapped, j = True, 1
length = len(arr)
while(swapped):
swapped = False
for i in range(0,length-j):
@prasadwrites
prasadwrites / MergeSortAlgo.java
Last active August 29, 2015 14:09
Merge Sort algorithm in Java
import java.io.*;
import java.util.*;
public class MergeSortAlgo{
static int arr[] = { 11,34,55,67,23,64,78,34,12,84,33,5,5};
private void MergeSort(int [] arr)
{
@prasadwrites
prasadwrites / bubblesort.c
Created November 22, 2014 21:13
Bubblesort Algorithm in C
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
void bubblesort(int *arr, int size)
{
int i = 0, temp;
int j = 1;