This file contains 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
//Reference: Exploring BeagleBone - Derek Molloy | |
#include<iostream> | |
#include<fstream> | |
#include<string> | |
#include<sstream> | |
#include<unistd.h> | |
using namespace std; | |
#define LDR_PATH "/sys/bus/iio/devices/iio:device0/in_voltage" |
This file contains 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
# Modified from https://pimylifeup.com/raspberry-pi-distance-sensor | |
import RPi.GPIO as GPIO | |
import time | |
try: | |
GPIO.setmode(GPIO.BOARD) | |
PIN_TRIGGER = 7 | |
PIN_ECHO = 11 |
This file contains 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
# Basic stack implementation | |
class Stack: | |
def __init__(self): | |
self.items = list() | |
def isEmpty(self): | |
return self.items == [] | |
def push(self, data): |
This file contains 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
# Basic queue implementation: using collections | |
from collections import deque | |
class Queue: | |
def __init__(self): | |
self.items = deque() | |
def isEmpty(self): | |
return self.items == deque([]) |
This file contains 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
# Basic implementation of singly linked list | |
class Node: | |
def __init__(self, data): | |
self.data = data | |
self.next = None | |
def getData(self): | |
return self.data | |
def setData(self, newData): |
This file contains 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
# Basic implementation of doubly linked list | |
class Node: | |
def __init__(self, data): | |
self.data = data | |
self.next = None | |
self.prev = None | |
def getData(self): | |
return self.data |
This file contains 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 simple complete binary tree implementation with DFS methods | |
class Node: | |
def __init__(self, newData): | |
self.data = newData | |
self.left = None | |
self.right = None | |
def getData(self): |
This file contains 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 simple Trie implementation | |
class Node: | |
def __init__(self): | |
self.children = dict() | |
self.count = 0 | |
class Trie: |
This file contains 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 Simple implementation of vector(containing objects of a class) data structure | |
#include <iostream> | |
#include <vector> | |
using namespace std; | |
class Salad{ | |
private: | |
int oranges, apples; | |
public: | |
void setOranges(int numOranges){ oranges = numOranges; } |
This file contains 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 simple of implementation of a hash table | |
class Node: | |
def __init__(self, key, newData): | |
self.key = key | |
self.data = newData | |
def getKey(self): | |
return self.key |
OlderNewer