Skip to content

Instantly share code, notes, and snippets.

View MelulekiDube's full-sized avatar
😊
Focusing

MelulekiDube

😊
Focusing
View GitHub Profile
@MelulekiDube
MelulekiDube / root.c
Last active August 6, 2018 21:08
root file
/* Biction Method for finding
==========================
This program uses the Bisection method for finding roots of a fuction F. The
function needs to be defined in the implementation of the F routine below.
References:
This program is an adaption of the code provided by
https://justcode.me/numerical-computing/bisection-method-algorithm-flowchart-code-c/
More information about the Bisection root finding method can be found at the above link.
@MelulekiDube
MelulekiDube / main.cpp
Last active September 30, 2018 16:23
c++ assignment
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/*
* File: main.cpp
* Author: dube_
*
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author dube_
*/
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project source="2.7.1" version="1.0">
This file is intended to be loaded by Logisim (http://www.cburch.com/logisim/).
<lib desc="#Wiring" name="0"/>
<lib desc="#Gates" name="1"/>
<lib desc="#Plexers" name="2"/>
<lib desc="#Arithmetic" name="3"/>
<lib desc="#Memory" name="4">
<tool name="ROM">
<a name="contents">addr/data: 8 8
public void topView(Node node, int level, int distance, Map<Integer, Pair<Integer, T>> map) {
if (node == null) {
return;
}
//check if the map already has an entry of this level, and if the level of that entry was the minimum
if (!map.containsKey(distance) || (map.containsKey(distance) && level < map.get(distance).getKey()/*this is the level*/)) {
// we need to update the values in that case:
map.put(distance, new Pair<>(level, (T) node.data));// we put the new level distance relation we just came through
}
topView(node.leftChild, distance - 1, level + 1, map);
public static String compressString(String originalString) {
if(originalString.length()<3) return originalString;
int freq = 1; //default value for the frequency is 1 to signal that we have seen atleast this character we tokinig abotu
StringBuilder compressedString = new StringBuilder();// we will build the answer here
int current_index = 1;
for (; current_index < originalString.length(); ++current_index) {
if (originalString.charAt(current_index - 1) == originalString.charAt(current_index)) {
++freq;
} else {//if they are not equal
compressedString.append(originalString.charAt(current_index - 1)).append(freq);
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package interview_prep;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
#!/usr/bin/python3
#imports
import spidev
import time as _time
from array import *
from datetime import datetime, timedelta, time
import RPi.GPIO as GPIO
import atexit
/* we are going to use register r0 and r3 for indexes*/
/* we will then use register r4 and r5 as temporal registers*/
.global main
.func main
main:
MOV R0, #0 @ initialze index variable
mov r3, #0
/* we are going to use register r0 and r3 for indexes*/
/* we will then use register r4 and r5 as temporal registers*/
.global main
.func main
main:
MOV R0, #0 @ initialze index variable
mov r3, #0