User Tools

Site Tools


opus:fall2012:jcavalu3:part2

Part 2

Entries

Entry 1: October 10, 2012

  • ON THIS TREMENDOUS DAY, WE LEARNED OF THE BEAUTY OF STACKS (aka STAXX, YO).
  • Stacks are very similar to linked list, the access is the big difference.
  • In a stack, you can only access the values in it working from the top of the stack to the bottom, instead of grabbing any of the values at any time.
  • Stacks help keep things neat, no stabbing at the “pile” and loosing track of things this way!
  • I will be working on stacks and creating my own with the help of the linked list program

Entry 2: October 31, 2012

  • So… postfix notation… MIND BLOWN.
  • As opposed to infix notation ( (1 + 7) * 6 ), postfix notation lists the operations at the end of the numbers involved. For example:
    • 1 7 + 6 *
    • 5 3 - 2 /
  • We were told about this concept with the unveiling of BINARY TREE BOOM!!!!! It is used with stack-based and concatenative programming.
  • It is also known as Reverse Polish Notation (RPN).

Entry 3: October 19, 2012

  • I worked with the grep(1) command, which searches through plain text looking for lines that match a regular expression.
  • This is nice when you have a file, such as an html file, that has a lot of the html commands present, but you just want what the html file is going to be displaying (The example in class where we reduced the html file from the CCC course page to just the courses and such).
  • This command can be used right from the command line or in a program itself (Puzzle Box 2).
  • There is another type of grep(1) function that covers extended regular expressions, which is egrep(1).

Entry 4: October 17, 2012

  • I learned that there exists a tremendously hideous but interesting sorting algorithm called Bogo Sort.
  • The way Bogo Sort works is it takes a set of numbers, basically “throws them up in the air and however they land” is your new set, if the numbers aren't in numerical order, then the set will repeat the process and check again. This is done until the set is in correct numerical order.
  • This sorting algorithm is very inconvenient, can be finished within the first ten tries or never even complete, and can use up a great amount of memory.
  • However, it is very interesting knowing how it works and seeing how long and how many tries it takes to find the correct sort.

Keywords

data Keyword 2

queue overrun condition

Definition

Queue Overrun/Overflow Condition happens when a program attempts to add an element onto an already filled queue.

References

data Keyword 2 Phase 2

stack (LIFO or FIFO?)

Definition

LIFO is an acronym that stands for “Last In, First Out.” When it comes to stacks, functions and procedures that are running become stacked on top of one another in memory (called a “push”). When an item is removed from the stack (or “popped”), it is removed from the top down. This computing action allows for stack integrity, and limits access/insertion.

FIFO means “First In, First Out.” In this regard, data and processing are handled on a first come, first serve basis through usage of a queue (or linear data structure). The first process in line is handled before any others are, and then the next, and so on.

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

Demonstration

  • To put another node on top of the stack, you “push” the node onto the top of the stack and becomes the top of the stack (obviously).
  • To pull nodes from the top of the stack, you “pop” the top node off of the stack.

LIFO STACK (Last In, First Out)

(The number represents the order in which they were put into the list)

( 6 ) TOP (This would be the first one out, being the last one input, because it is on the top of the list)
  ^
  |
( 5 ) 
  ^
  |
( 4 
  ^
  |
( 3 )
  ^
  | 
( 2 )
  ^
  |
( 1 ) BOTTOM (This would be the last one out, although it was the first one input)

FIFO STACK (First In, First Out)

(The number, just like above, represents the order)

( 1 ) TOP (This would be the first one out)
  ^
  |
( 2 ) 
  ^
  |
( 3 )
  ^
  |
( 4 )
  ^
  |
( 5 )
  ^
  |
( 6 ) BOTTOM (This would be the last one out)

discrete Keyword 2

cartesian product

Definition

Cartesian Product is making one set that takes one from a set and pairs it with one value from another set. This is done for each of the values in each set. Example:

  • {1, 2} * {up, down} = {(1, up), (1, down), (2, up), (2, down)}
  • {1, 2, left} * {left, right, up, down} = {(1, left), (1, right), (1, up), (1, down), (2, left), (2, right), (2, up), (2, down), (left, left), (left, right), (left, up), (left, down)}

References

List any sites, books, or sources utilized when researching information on this topic. (Remove any filler text).

  • Reference 1
  • Reference 2
  • Reference 3

discrete Keyword 2 Phase 2

variables (environment/local)

Definition

A local variable is only known in the function that you created it in. It isn't known in any other functions and can't be used in any other function. Each time you use the function is starts at whatever value you assigned it to. Global variables are known and can be used by any function in the program. So if you make a variable outside of main() it is a global variable because it can be used in any function. If you make a variable inside main() it can only be used in main() so it is a local variable.

References

Demonstration

  1 #include <stdio.h>
  2 
  3 int glovar = 20; // Global Variable
  4 
  5 int local( int );
  6 
  7 int main()
  8 {
  9     int localvarmain = 0;
 10 
 11     printf("global variable: %d\n\n", glovar);
 12     printf("Local variable cannot be demonstrated the same way because if the program tries\n");
 13     printf("to access a variable that doesn't exist, the program will not compile correctly\n");
 14     printf("and result in the program not running correctly\n\n");
 15 
 16 // Running local function to add the local variable (to the function) to the global variable
 17 
 18     glovar = local( glovar );
 19 
 20     printf("New global variable: %d\n", glovar);
 21 
 22     return 0;
 23 }
 24 
 25 int local( int glovar )
 26 {
 27     int localvar = 10;
 28 
 29     glovar = glovar + localvar;
 30     return glovar;
 31 }

The printed result:

lab46:~/src/opus/opus2$ ./unixdemo 
global variable: 20

Local variable cannot be demonstrated the same way because if the program tries
to access a variable that doesn't exist, the program will not compile correctly
and result in the program not running correctly

New global variable: 30

unix Keyword 2

shabang

Definition

A shabang is this: #! The shabang is used to read the following test on the first line after it to determine what interpreter the user would like to… use. Some example of interpreters (Taken directly from http://en.wikipedia.org/wiki/Shebang_(Unix):

  • #!/bin/bash – Execute the file using sh, the Bourne shell, or a compatible shell
  • #!/bin/csh – Execute the file using csh, the C shell, or a compatible shell
  • #!/usr/bin/perl -T – Execute using Perl with the option for taint checks
  • #!/usr/bin/php – Execute the file using the PHP command line interpreter
  • #!/usr/bin/python -0 – Execute using Python with optimizations to code
  • #!/usr/bin/ruby – Execute using Ruby

References

unix Keyword 2 Phase 2

PATH environment variable

Definition

The $PATH variable specifies a list of one or more directory names separated by colons.

The /bin, /usr, and /local directories are typically included in most users' $PATH settings. The current directory is sometimes included, allowing programs in the current directory to be executed. Superuser (root) accounts as a rule are not include in $PATH, however, in order to prevent the accidental execution of scripts in the current directory.

When a command name is specified by the user or an exec call is made from a program, the system searches through $PATH, examining each directory from left to right in the list, looking for a filename that matches the command name. Once found, the program is executed as a child process of the command shell or program that issued the command.

References

Demonstration

The following is an example of a $PATH:

lab46:~/src/opus/opus2$  

The $PATH The home directory (~/) is the beginning of this specified $PATH, followed by the src directory, then the opus directory, and lastly the opus2 directory.

Experiment 2

Question

I downloaded VirtualBox and Debian to run on it, but when everything was installed, the possible resolutions were not available to me. I am going to experiment with it and figure out how to fix it.

Resources

I installed it with the help of Evan Olson, but the rest of my help will come from the internet and whatever I can find. Any websites used will be listed below:

Hypothesis

I believe that I will need to install packages for the resolution. I don't think there will be much more to it, maybe some command line arguments to actually use the packages or something along those lines.

Experiment/Data

I will research VirtualBox and Debian and find how to fix the problems. I will document my research and experiment in the data section below with the use of screenshots and such!

Well, the first problem I ran into was that I wasn't a sudo user, so with your help, I made myself one by going to the terminal, going to the root command prompt, accessing the visudo file, and adding myself as a user. From there, I typed in sudo apt-get install virtualbox-ose-guest-x11, which, I think, installed the Guest Addition Driver X11. I ended up getting a larger resolution (1024 x 768) instead of the monitor's natural resolution (1600 x 900). I tried the other website's tactics, which were to update Debian, remove the OSE guest additions using sudo apt-get remove virtualbox-ose-guest* and then mounted the VBOXADDITIONS ISO by using the command sudo sh /media/cdrom/VBoxLinuxAdditions.run.

Analysis

Based on the data collected:

  • Yes, but it isn't working very well. I still haven't been able to use the correct resolution.
  • I couldn't get past the 1024 x 768 resolution, even when I tried the things I was told to try on the websites, and I can't think anymore! I'm too tired!
  • I probably could have tried more, but I am going to do that tomorrow when I come in before class starts.
  • The data showed a change in resolutions, it was a better resolution than the one that I started with, but it isn't the best and I can find the best.

Conclusions

I can conclude that I have an extremely hard time messing around with operating systems and it is a lot harder than I thought it would be.

opus/fall2012/jcavalu3/part2.txt · Last modified: 2012/11/01 00:03 by jcavalu3