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
; | |
; PROBLEM: | |
; | |
; Design a data definition to represent binary search trees. As a reminder, | |
; here is one example BST: | |
; an img of a binary search tree was here, because DrRacket allows images into the IDE, why | |
; . | |
(define-struct entry (key val)) |
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
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#define BLOCK 512 | |
int main(int argc, char *argv[]) | |
{ | |
// assure propper usage | |
if (argc != 2) |
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
#include <stdio.h> | |
int main() | |
{ | |
float x = 3.1; | |
float y = 3.1; | |
printf("%.20f\n", x); // 3.09999990463256835938 | |
printf("%.20f\n", y); // 3.09999990463256835938 |
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
#include <stdio.h> | |
int main() | |
{ | |
double x = 3.1; | |
float y = 3.1; | |
printf("%.20f\n", x); // 3.10000000000000008882 | |
printf("%.20f\n", y); //3.09999990463256835938 |
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
import time | |
import random | |
def f(L): | |
""" | |
L: list | |
return list cu elemente cu frecventa impara | |
""" | |
t0 = time.clock() |
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
def isSubstring(substring, string): | |
""" | |
substring: string | |
string: string | |
returns true if substring is substring of string e.g. 'cat' is substring of 'something cat something' | |
""" | |
si = 0 # substring indexer | |
for i in range(len(string)): | |
if string[i] == substring[si]: | |
si += 1 # notice, advancing the substring indexer each time we find a match |
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
import time | |
import random | |
def f(L): | |
""" | |
L: list | |
return list cu elemente cu frecventa impara | |
""" | |
t0 = time.clock() |
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
l = [1,1,2,3,3,2,1,2,3,3] | |
def f(L): | |
""" | |
L: list | |
return list cu elemente cu frecventa impara | |
""" | |
d = {} | |
for e in L: | |
d[e] = d.get(e, 0) + 1 |
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
l = [2,3,4,5,1,4,5,1,2] | |
def f(L): | |
d = {} | |
for e in L: | |
d[e] = d.get(e, 0) + 1 | |
for key in d: | |
if d[key] % 2 != 0: | |
return key |
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
#define _XOPEN_SOURCE | |
#include <unistd.h> | |
#include <stdio.h> | |
#include <cs50.h> | |
#include <string.h> | |
#include <ctype.h> | |