Durring this class session we began talking about pointers and memory. Such as the different ways memory can be stored, data types. some of the various data types are integers, characters, float, double, boolean and string etc. Pointers on the other hand are very different. Pointers hold the adress of allocated memory. Basically a sign on a highway telling where a city is.
This is very significant because this is how data is stored in memory on the computer. Each data type has its own purpose and is very important when planning a program. Same with pointer although very different and having a different purpose very important when planning a program.
I am a little shakey on the concept of pointers but after the lecture on the 31st i felt a little more confident and it seemed to make more sense. This might change…
The biggest chalenge i am having with the course is the fact that i feel as if i learned absolutly nothing in my c/c++ class last semester. I got a good grade but do not feel i learned up to my grade and that is frustrating to me.
On this day we started talking about logic. Logic is a very important thig when it comes to computers and software. Logic is the backbone of software or programs without logic there would be no computer programs. We also went over the logic table. We created the table and named six binary and one unary opperation.
Binary: AND, NAND, OR, NOR, XNOR, XOR Unary: NOT
After creating the logic table the class begain name where those opperations where on the logic table. This confused me a little bit i didnt seem to get where and how you knew what opperations were which on the table.
I definitally need to sort this out. I will be asking for help.
Today we began going over the vi editor. This was very usefully because i was constantly dealing with scrutiny and judgment when using the infamous nano editor. Not only was a able to feel more accepted when using it but I was also able to become more efficient when typing code using the many key commands implemented in vi. Just a few of the commands that where taught were i, w , b, ^ and $. These are just a few of the commands but using them efficiently can greatly improve productivity.
i is simple it simply allows you to enter [insert] mode.
w is very usefully and allows you to advance a work or a certain number of words by entering 5w or 9w or 10w.
b is very much the same except for going back a word or a number of words.
$ sends the cursor to the end of the line.
As i said these are only a few of the things described in the class but i thought they were some of the most useful. I found it very useful at least. There was really nothing in this lecture that i had a hard time understanding it will just take practice and use to remember all of the commands. I am having no challenges with respect to the course.
During this lecture we began the concept of linked list and “nodes”. This concept is very useful and inherently confusing. A linked list allow you to allocate a computers memory until it basically runs out. This is very useful when you want to store data but do not know necessarily how much data or how many values you will need to store. Hence the name Linked List, it is a list of data that is linked so it may be navigated. A linked list is similar but at the same time VERY different from an array and array is finite and once defined its space allocated cannot be “re allocated” and the array cannot be re sized. I have been dealing with a lot of understanding issues regarding linked lists but i am getting help and i begin to understand more and more every time i get help and expose myself to them. The only challenges i feel like i am facing for this course is my understanding due to lack of prior knowledge but that is quickly becoming less of a problem because of the high amount of exposure i am having to the material!!!!
Null Pointers
A Null pointer is a pointer that points definitivly nowhere. it does not yield the address of any object or function.
malloc for instance returns a null pointer when it fails.
List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).
passing by reference (function parameter passing) [C++]
To use the address of a variable as a reference to some sort of data contained in the variable to send to some algorithmic function which can use the variable's data to perform some sort of action or solve a problem.
Demonstration of the indicated keyword.
The code block below demonstrates the concept defined above.
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int Sum(int, int); 5 6 int main() 7 { 8 int a; 9 int b; 10 int S; 11 12 printf("please enter two values you would like to add together.\n"); 13 14 scanf("%d", &a); 15 scanf("%d", &b); 16 17 Sum(a, b); 18 19 printf("\nThe sum of a and b is %d.\n", Sum(a, b)); 20 return 0; 21 } 22 23 int Sum(int a, int b) 24 { 25 26 int S; 27 28 S = a + b; 29 return (S); 30 }
Left Complementation
Left Complement is similar to negation p. it is a logic operation that basically negates the p. For example if p was a 1 it would not matter what q was the result would be a 0. Likewise if p was a 0 regardless of q the result would be a 1.
Reference 1: http://en.wikipedia.org/wiki/Negation
Right Complementation
When given a Truth Table, you see two columns of two different values that are related to each other and show opposite relationships, most of the time they are represented by F for false and T for true. Right Complementation is the opposite of the second column, or the right one. When representing each of the results for a 4 by 2 table, there are 16 possible results, one of them being the right complementation, which is actually represented by negation q.
Demonstration of the indicated keyword.
Right Complementation is very similar the Negation P except its Negation Q if you get a combination of P:1 and Q:0 the result will be 1 negating Q and similarly if it is P:0 and Q:1 then the result will be 0. so no mater what P is the answer will always be the negation of Q
The c code block below reflects this.
char NP(char P, char Q) 2 { 3 char x; 4 5 if (Q == 0) 6 x = 1; 7 else 8 x = 0; 9 10 return (x); 11 }
Remote Host
A remote host is a computer typically refereed to as a server in a private or a public network. The computer or server will be located in a distant location. This server or computer can retrieve and store data and users can even access data off of them. A good example would be the servers located here at the business center when we log on and access files from home.
Reference 1: http://www.pcmag.com/encyclopedia_term/0,1237,t=remote+host&i=59583,00.asp
Reference 2: http://wiki.answers.com/Q/What_is_the_meaning_of_remote_host_in_computer
File Listing
File listing in unix is a command “ls” when you type ls into the terminal it will list all the files or directory's in that directory. File listing can also be used with parameters such as -l. when you type “ls -l” it will list all the files again but you will also see more details about the files such as the various permissions the file or directory has. For more information you can visit the “ls” man page.
Demonstration of the indicated keyword.
An example on the Terminal.
lab46:~$ ls Desktop Maildir Public arc.tar archives data lyrics.mp3 src Documents Music Templates archive1.tar.gz closet file.txt.gz public_html the answer.txt Downloads Pictures Videos archive2.zip courses.tar logincnt.sh puzzlebox.sh lab46:~$
lab46:~$ ls -l total 48 drwxr-xr-x 2 eolson1 lab46 6 Aug 28 14:21 Desktop drwxr-xr-x 2 eolson1 lab46 6 Aug 28 14:21 Documents drwxr-xr-x 2 eolson1 lab46 6 Aug 28 14:21 Downloads lrwxrwxrwx 1 eolson1 lab46 17 Aug 25 15:40 Maildir -> /var/mail/eolson1 drwxr-xr-x 2 eolson1 lab46 6 Aug 28 14:21 Music drwxr-xr-x 2 eolson1 lab46 6 Aug 28 14:21 Pictures drwxr-xr-x 2 eolson1 lab46 6 Aug 28 14:21 Public drwxr-xr-x 2 eolson1 lab46 6 Aug 28 14:21 Templates drwxr-xr-x 2 eolson1 lab46 6 Aug 28 14:21 Videos -rw-r--r-- 1 eolson1 lab46 10240 Sep 21 16:01 arc.tar -rw-r--r-- 1 eolson1 lab46 237 Sep 21 15:42 archive1.tar.gz -rw-r--r-- 1 eolson1 lab46 584 Sep 21 15:42 archive2.zip drwxr-x--x 3 eolson1 lab46 80 Sep 21 16:00 archives drwxr-xr-x 2 eolson1 lab46 17 Sep 14 16:37 closet -rw-r----- 1 eolson1 lab46 10240 Sep 22 15:15 courses.tar lrwxrwxrwx 1 eolson1 lab46 27 Aug 29 13:56 data -> /usr/local/etc/data/eolson1 -rw-r--r-- 1 eolson1 lab46 76 Sep 22 15:00 file.txt.gz -rwxr-x--- 1 eolson1 lab46 112 Sep 19 16:40 logincnt.sh -rw-r--r-- 1 eolson1 lab46 658 Sep 21 11:51 lyrics.mp3 drwx-----x 2 eolson1 lab46 6 Aug 26 2009 public_html -rw-r--r-- 1 eolson1 lab46 447 Sep 22 15:35 puzzlebox.sh drwx------ 8 eolson1 lab46 108 Sep 19 14:15 src drwxr-xr-x 2 eolson1 lab46 21 Sep 24 13:25 the answer.txt lab46:~$
what would happen if i modified the guessing game script to try to guess itself would it ever get it right?
From my UNIX class lecture on Septemeber 26th and 28th. AND http://stackoverflow.com/questions/5061227/why-doesnt-my-variable-seem-to-increment-in-my-bash-while-loop
Since i set it up to have one value static and one continuing to be random i think it will be possible
I will write and test a bash script in a controlled environment!
Nope 15864 is not equal to 25740 guess a value: 22205 Nope 22205 is not equal to 25740 guess a value: 4461 Nope 4461 is not equal to 25740 guess a value: 12557 Nope 12557 is not equal to 25740 guess a value: 28518 Nope 28518 is not equal to 25740 guess a value: 17998 Nope 17998 is not equal to 25740 YAY!!!!! IT WORKED! 25740 was equal to 25740 It took 21678 guesses. evan@evan-Extensa-4630Z:~$
This was the final result after letting the script run for about 1 minute.
The code i used :
#!/bin/bash #script 3 # # value=`bc <<< "$RANDOM"` num=5 count=0; while [ $num -ne $value ] ; do echo -n "guess a value: " echo "$num" echo "Nope $num is not equal to $value" count=$((count+1)) num=`bc <<< "$RANDOM"` done echo "YAY!!!!! IT WORKED! $num was equal to $value" echo "It took $count guesses." exit 0
Based on the data collected:
One shortcoming of this would be knowing the exact time it took I feel that would have been nice to have.
I was pretty confident that the experiment would work but i was a little unsure of how long it would take. I implemented the counter to get an idea but it would have been nice ti have a run time timer of some sort. maybe a future revision…