Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added CS61C-22Fall-HW/HW1/HW1.1 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW1/HW1.2 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW1/HW1.3 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW1/HW1.4 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW1/HW1.5 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW1/HW1.6 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW1/HW1.7 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW1/HW1.8 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW2/BHW2.1 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW2/BHW2.10 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW2/BHW2.2 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW2/BHW2.3 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW2/BHW2.4 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW2/BHW2.5 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW2/BHW2.6 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW2/BHW2.7 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW2/BHW2.8 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW2/BHW2.9 - CS 61C.pdf
Binary file not shown.
100 changes: 100 additions & 0 deletions CS61C-22Fall-HW/HW2/HW2memory.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>

typedef struct tree {
struct tree* left;
union
{
struct tree* right;
int data;
} rd;
} Inttree;

Inttree* lefttree(Inttree* t)
{
return t->left;
}

Inttree* righttree(Inttree* t)
{
return t->left ? t->rd.right : NULL;
}

bool isleaf(Inttree* t)
{
return !(t->left);
}

void printtree(Inttree* t)
{
if(t == NULL) return;
if(isleaf(t)) printf("%d ", t->rd.data);
else
{
printtree(lefttree(t));
printtree(righttree(t));
}
}

void freetree(Inttree* t)
{
if(t == NULL) return;
if(!isleaf(t))
{
freetree(lefttree(t));
freetree(righttree(t));
}
free(t);
}

Inttree* maketree(Inttree* left, Inttree* right)
{
Inttree* t = malloc(sizeof(Inttree));
t->left = left;
t->rd.right = right;
return t;
}

Inttree* makeleaf(int val)
{
Inttree* t = malloc(sizeof(Inttree));
t->left = NULL;
t->rd.data = val;
return t;
}

void q1()
{
char str[] = {65, 83, 67, 73, 73, 32, 105, 115, 32, 102, 117, 110, 0};
Inttree root;
root.left = maketree(makeleaf(3), maketree(makeleaf(1), makeleaf(4)));
root.rd.right = maketree(maketree(makeleaf(1), makeleaf(5)), maketree(makeleaf(9), makeleaf(3)));
printf("%s\n", &(str[0]));
printtree(&root);
printf("\n");
freetree(root.left);
freetree(root.rd.right);
}
static Inttree* initializetree() {
return NULL;//CODE OMITTED;
}
void q2()
{
int a1 = 0xDEADBEEF;
char str[20];
int a2 = 0xABACABAC;
Inttree* tree = initializetree(); //Code omitted
//Breakpoint 1
printf("%s\n", &(str[0]));
printtree(tree);
printf("\n");
}



int main(int argc, char** argv)
{
q1();
q2();
}
297 changes: 297 additions & 0 deletions CS61C-22Fall-HW/HW2/HW2memoryGDBoutput.txt

Large diffs are not rendered by default.

Binary file added CS61C-22Fall-HW/HW3/B_HW3.1 - CS 61C.pdf
Binary file not shown.
Binary file added CS61C-22Fall-HW/HW3/B_HW3.2 - CS 61C.pdf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading