Skip to content

Instantly share code, notes, and snippets.

View bragboy's full-sized avatar
🧘
Inner peace

Bragadeesh bragboy

🧘
Inner peace
View GitHub Profile
@bragboy
bragboy / ransack.rb
Created August 8, 2015 20:10
config/initializers/ransack.rb
Ransack::Adapters::ActiveRecord::Base.class_eval('remove_method :search')
@bragboy
bragboy / QueueStack.java
Created August 8, 2015 20:12
Queue using stack
package dsa.stack;
import java.util.Stack;
/**
* An implementation of Queue using two Stacks
* @author Braga
*/
public class QueueStack<T>{
package dsa.stack;
public class TestQueue {
public static void main(String[] args) {
QueueStack<Integer> queueUsingStack = new QueueStack<Integer>();
queueUsingStack.enQueue(1).enQueue(2).enQueue(3).enQueue(4).enQueue(5).enQueue(6);
System.out.println("Queue current size is : "+queueUsingStack.size());
System.out.println(queueUsingStack.deQueue());
System.out.println(queueUsingStack.deQueue());
System.out.println(queueUsingStack.deQueue());
#include <iostream>
#include <queue>
using namespace std;
struct node
{
int data;
struct node* left;
struct node* right;
package dsa.tree;
public class Tree {
Node root;
public static void main(String args[]) {
Tree anyTree = new Tree();
anyTree.root = new Node(3);
anyTree.root.left = new Node(2);
anyTree.root.right = new Node(5);
/*
ASSUMPTIONS:
All characters are case insensitive
ENHANCEMENTS:
Auto correction of word
Display all words in postorder
SAMPLE DATA: - ALGO, ALL, ALSO, ASSOC, TREE, TRIE
+--> [G] ---+--> [O]
int main()
{
trie mytrie;
char *s[] = {"tree","trie","algo","assoc","all","also","ass"};
for(int i=0;i<sizeof(s)/sizeof(*s);i++)
{
mytrie.insert_word(s[i]);
}
mytrie.display();
double angle(int h, int m)
{
double hangle = 0.5D * (h*60 + m);
double mangle = 6*m;
angle = abs(hangle – mangle);
angle = min(angle, 360-angle);
return angle;
}
p->data = p->next->data;
t = p->next;
p->next = p->next->next;
delete t;
void * memcpy ( void * destination, const void * source, size_t num );
void * memmove ( void * destination, const void * source, size_t num );