Today in Data structures we learned about binary trees. I didn't really see the point of it, until Matt showed how we can use it for sorting. It seems pretty awesome.
The difficult part will be working out the algorithms - but when it comes time to creating a program for binary trees, I will probably choose the recursive method since that is what I'm least familiar with.
For Discrete we've been working on a set program part 2. Basically we have to be able to build 2 sets, display 3 sets (third one is a 'result' set), union the 2 sets, intersect the 2 sets, and take a difference between sets A and B and between B and A. Also clear the sets.
I used iterative algorithms for this program and it was quite a pain after awhile - the algorithms are getting increasingly complex and long. I'm betting a recursive method would have worked much better - if we have another set program I would probably try that instead.
For comp. org. I set up a directory and have an increment and decrement up and running. I set up a bncreate, and a setnum function as well. The next stage is where it gets a little repetitive (ad where Andrew may or may not come into play) and that is writing the C code that would complement the LD functions. For LD functions I am thinking that since there are only a certain of possibilities it may just be better to 'hardcode' them into if statements and taking command line arguments.
Eventually, and I would probably need Matts help with this, there will be scripts that will actually be responsible for calling the LD functions and responsible for sending the command line argument to them.
The asterisk project has pretty much winded down. We've been unable to get the new machine working properly - it connects but no sound gets transmitted. We did connect it to a coffee maker and a lightbulb though so that was cool.
Now we are going to use a program called minimodem which takes a file input and then outputs it as sound (like the dialup sound). This sound will be transmitted through two cans and a string, and then received into a machine running the program in receiving mode. So we could hopefully transmit a photo using two cans and a string.
The LD instruction
The LD function is how data gets moved within this Z80 processor. That's pretty important.
LD C,2 is a simple LD function that will take the value of 2 and put that value into register C.
LD B,C is a LD function that will take the value in C (the 2) and put that value into register B.
LD E,0AAH is a LD function that will put the HEX value (hence the H) into register F.
LD H,11111111B will put that binary value into register H.
You can also do all of these using double registers, to denote 2 byte entities (like memory locations in RAM!)
These instructions all do the same thing (shamelessly taken from the z80 instructions manual):
LD B,073H
LD B,01110011B
LD B,65
LD B,“s”
We use LD functions to move from RAM.
LD A,0FFH - register A now contains the value of 255.
LD BC, 5364 - puts the value of 5364 into the double register BC.
LD (BC),A - puts the 255 from register A into memory location 5364 (BC).
LD E, (BC) - pulls the 255 from memory location 5364 (BC) into register E.
LD (BC), 200 - puts the contents of C into memory 200, and B into memory 201. (Take note that it is backwards.)
The LD instruction
The LD function is how data gets moved within this Z80 processor. That's pretty important.
LD C,2 is a simple LD function that will take the value of 2 and put that value into register C.
LD B,C is a LD function that will take the value in C (the 2) and put that value into register B.
LD E,0AAH is a LD function that will put the HEX value (hence the H) into register F.
LD H,11111111B will put that binary value into register H.
You can also do all of these using double registers, to denote 2 byte entities (like memory locations in RAM!)
These instructions all do the same thing (shamelessly taken from the z80 instructions manual):
LD B,073H
LD B,01110011B
LD B,65
LD B,“s”
We use LD functions to move from RAM.
LD A,0FFH - register A now contains the value of 255.
LD BC, 5364 - puts the value of 5364 into the double register BC.
LD (BC),A - puts the 255 from register A into memory location 5364 (BC).
LD E, (BC) - pulls the 255 from memory location 5364 (BC) into register E.
LD (BC), 200 - puts the contents of C into memory 200, and B into memory 201. (Take note that it is backwards.)
Demonstration of the indicated keyword.
If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:
/* * Sample code block */ #include <stdio.h> int main() { return(0); }
Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:
lab46:~$ cd src lab46:~/src$ gcc -o hello hello.c lab46:~/src$ ./hello Hello, World! lab46:~/src$
doubly linked list
A doubly linked list a a method of storing data.
The manner in which the data is stored is by a series of structs. There will be a variable that will always point to the first struct, and if you want there can be one to always point to the last struct.
Every struct has a minimum of three variables contained within - the data value, a pointer to the struct after it, and a pointer to the struct before it. These pointers is how one will navigate these structs, it is how they are linked together.
No references for this keyword.
linked list
A linked list is a data structure consisting of a group of nodes which together represent a sequence. Under the simplest form, each node is composed of data and a link to the next node in the sequence; more complex variants add additional links. This structure allows for efficient insertion or removal of elements from any position in the sequence.
Demonstration of the indicated keyword.
Plenty of linked list demos in my repo.
5 void FillList(Node **start) 6 { 7 char input; 8 Node *tmp; 9 tmp=(*start); 10 tmp == NULL; 11 printf("Enter a value (-1 to end): "); 12 scanf("%hhd", &input); 13 14 while(input != -1) 15 { 16 if (tmp == NULL) 17 { 18 tmp=(Node*)malloc(sizeof(Node)); 19 tmp->value=input; 20 tmp->next=NULL; 21 tmp->prev=NULL; 22 *start=tmp; 23 } 24 else 25 { 26 tmp->next=(Node*)malloc(sizeof(Node)); 27 tmp->next->value=input; 28 tmp->next->next=NULL; 29 tmp->next->prev=tmp; 30 tmp=tmp->next; 31 } 32 printf("Enter a value (-1 to end): "); 33 scanf("%hhd", &input); 34 } 35 }
This is a function that creates a linked list.
Freeswitch
Freeswitch is an open source communications piece of software that can be used for the creation of voice/messaging tools. It can be used as a standalone application, or embedded and ran with other programs.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
Identification of chosen keyword.
Definition (in your own words) of the chosen keyword.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
Demonstration of the indicated keyword.
If you wish to aid your definition with a code sample, you can do so by using a wiki code block, an example follows:
/* * Sample code block */ #include <stdio.h> int main() { return(0); }
Alternatively (or additionally), if you want to demonstrate something on the command-line, you can do so as follows:
lab46:~$ cd src lab46:~/src$ gcc -o hello hello.c lab46:~/src$ ./hello Hello, World! lab46:~/src$
mutual exclusion
Mutual Exclusion is the method by which one can ensure that a region of memory cannot be accessed by two processes at the same time.
In logic terms, it can described as possibilities where you cannot have more than one be true at a time.
subset
A subset is a set which every element in the set is contained in a larger or equal size set. In other words a set with in a set.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
The set of {2,4,6} would be a subset of the set {0,2,4,6,8}.
For passing linked lists to functions and keeping track of the changes made without using a return, I had to use double pointers. What I would do is send the single Node pointer to the function by address - and define it as a double pointer in the function while dereferencing it once whenever it was used within the function.
What I was curious was would it be the same thing if I defined a double Node pointer in the main function, and just sent that without any dereferencing to the functions? It should be the same thing — it's still a double pointer after all.
This is basically more pointer playfulness. So all of the knowledge was gained last year from C/C++ Programming and from Matt.
I figured that it would work the same - since I am effectively doing the same thing, just shifting the notation by a little bit.
I tried to use this slightly different method in my stack program.
When I tried this - I kept running into seg faults.
When I talked about this with Matt, he figured it would be a malloc issue. Using the debugger, I figured out that even the pointers WEREN'T BEING GIVEN AN ADDRESS. So the pointer, was completely null. It didn't point to something. The pointer itself was null. Therefore, I couldn't pass it. My workaround was to create some variables and set their addresses equal to the pointers. I also had to implement two layers of mallocing. It was a gigantic pain, and the end result was that it sort of worked.
In the end, I resorted to passing single pointers by address :).
My hypothesis was half true.
It is applicable.
There is more going on than I thought - there were malloc issues that had to kind of manually be resolved, and it was a gigantic pain figuring it all out.
There were no shortcomings - I was able to test my hypothesis nicely.
The data is pretty nice about indicating that one would not want to accomplish this task this way.
Pass the single pointer by address.