User Tools

Site Tools


opus:fall2011:kkrauss1:part3

Table of Contents

Part 3

Entries

November 4, 2011

  • New month, new day, new headaches caused by feeling like I am behind in many classes. Data/system/cprog seem to be going well. Binary trees seem very simple and I am moderately confident I can make modifications to my doubly linked list libraries to get tree functionality. Discrete/data comm friggin suck anymore, and hpc I really need to get some direction from Matt. I feel like I have learned all the basics of C and will soon have to spend more time on C++, yay for me.

November 18, 2011

  • Time to do some more keywords, hopefully I an get these out of the way so I can focus on other things. Things are fine with data and sys prog but I have to do some work with hpc and figure out what the hell is going on with discrete and data comm.

November 21, 2011

Despite the fact that the class is watching troll 2 on the video wall I am going to attempt to actually do some work. One more keyword for sys prog then I must tackle data structs.

December 1, 2011

   The third part of opus is done and now it is time for eoce.  As usual I think I overreacted to the amount of work as the teacher seems to be very understanding and doesnt seem to expect everyone to get everything done.  I think he is just looking more for progress and a willingness to learn.  I can safely say that I have definitely made progress and learned a lot this semester.  Sometimes I got frustrated but just about every time I asked about a topic the teacher was able to lead me to learning something new.  I can also safely say I cannot wait for a break!

cprog Topics

Keyword 1: C library, libraries, makefile

  • libraries are predefined code and header files that store common functionality. The C standard library includes your basic i/o operations, string functions etc.
  • Makefiles is basically a script containing commands for the utility make. It allows for code compiling with predetermined arguments.

Keyword 2: Mult-file programs

  • Multi-File programming allows for several .c files to be compiled into one binary file. Only one of the files can have a defined function of a given name. Meaning you cant have main() in two different files. All files have to have same header. To compile all the files into one is no different than compiling a single file, except after typing gcc you type all the files names in the order that you want compiled. You can also write a makefile to automate the process.

Keyword 3: I/O stream

  • I/O stream is c++'s version of STD I/O and in fact is built off of STD I/O. Four key components of the i/o stream are cin, cout, cerr and stream operators.
  • cin Deals with input, reads in user input or possibly information file
  • cout Deals with output, prints requested information
  • cerr Specifically deals with error messages
  • Stream operators
    • Insertion operator(«) is used with cout. cout«1; means the value of one is “inserted” into cout(aka output) printed to screen.
    • extraction operator(») is used with cin. cout»variable; means the value entered by the user will be stored in variable.

Keyword 4: Array of char vs. C++ string data type

  • The C++ string data type has the same functionality as an array of chars in C. You can still access individual elements of the string by using the array index[] and there are built in string functions if needed. Concatenation, comparison etc.

Keyword 5: Namespaces

  • Namespaces allow you to group things together, like variables, classes, objects and functions.

here is a good resource for further understanding

Keyword 6: Templates

  • Templates allow for generic functions in c++ thus allowing for the same function to be used for multiple types without having to write the code again.

Keyword 7: Standard template library

  • The standard template library is a library that includes common templates classes.

Keyword 8: type casting operators

  • Casting is when you change the representation of a variable type. In C it is as simple as (char) int; which can also be done in c++ but c++ also has several additional operators as listed here

Keyword 9: constant/volatile

  • Const defines a variable as constant meaning it cannot be modified.
  • Volatile defines a variable as volatile meaning that it can be modified in some way not known by the compiler

Keyword 10: classes and objects

  • Classes are similar to structs in c but can have functions as well. Classes are specifically just a definition.
  • Objects are a declaration of a class.

Keyword 11: Access control

There are three levels of access control within a class:

  • Public members of a class are accessible by any function.
  • protected members are accessible to members of classes that inherit from the class in addition to the class itself and any friends.
    • friends are classes that are given permission to access protected data of another class
  • private are only accessible by functions of the class.

Keyword 12

Identification and definition of the chosen keyword. Substitute “keyword” with the actual keyword.

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$ 

data Topics

Keyword 1: LIFO and FIFO

Keyword 2: Computational complexity

  • Computational complexity is the concept of classifying the difficulty of a computing program.

resource

Keyword 3:Big-O, theta, bounds

In computer science, Big-O and Big theta is used to describe how an algorithm responds to different input sizes. This can be used to describe an algorithm's efficiency by determining processing time and working space requirements. Depending on the bounds you wish to describe will determine which notation would be used as big-o is more for just having an upper bound where big theta is upper and lower.

Keyword 4: Sorting algorithms

  • Sorting algorithms are programs that sort elements of a list into a specified order.

Keyword 5: Selection sort

  • Selection sorting is a simple algorithm that finds the smallest value in a list and puts it in the first element, then moves to the next element and repeats until list is ordered.

resource

Keyword 6:Bubble sort

  • Bubble sorting algorithm is a sorting algorithm that starts at the first element of the list and compares it to the next element. If the first is greater than the second it swaps them, then moves to comparing the second and third elements, repeating and moving through the list. it repeats the process through the list until no swaps happen.

resource

Keyword 7: Insertion sort

  • Insertion sorting algorithms creates a new list of the same number of elements as the list to be sorted, and then sorts the list by copying the elements in specified order into the new list.

resource

Keyword 8: Quick sort

  • Quick sorting algorithms is an algorithm that picks a pivot point of a list then divides the list by that pivot point. One list will contain all values greater than the pivot point, and the other will contain all values less than the pivot. One list will also be chosen to store the pivot point. This process is repeated until the list is sorted.

resource

Keyword 9: Merge sort

  • Merge sort algorithms are similar to quick sorts in that they divide the list and merge it back together, it simply lacks a pivot point.

more

  • Binary Search is a simple search where you typical pick the middle of the list and compare if the searched value is less than, equal, or greater than chosen value. If the searched value is less than the picked value it will remove every element greater from the search and vice versa.

Keyword 11: Trees, Binary Trees(nodes, parents, children)

  • Trees are a type of data structure where each node can have children nodes. In a binary tree each node can have two child nodes. Typically the right node will be a value greater than the value in the parent node, and the left node will be a value less than the parent node.

Keyword 12: Searching a binary tree

  • Binary searching compares each parent branch as to whether is is greater than less than or equal to the searched value, if the element is not the value it effectively cuts half of the list out of the search. The process is run until the lowest level of the tree is searched of the value is found.

resource

hpc1 Topics

Keyword 1

Identification and definition of the chosen 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);
}

Keyword 2

Identification and definition of the chosen keyword.

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$ 

Keyword 3

Identification and definition of the chosen keyword. Substitute “keyword” with the actual 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);
}

Keyword 4

Identification and definition of the chosen keyword. Substitute “keyword” with the actual keyword.

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$ 

Keyword 5

Identification and definition of the chosen keyword. Substitute “keyword” with the actual 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);
}

Keyword 6

Identification and definition of the chosen keyword. Substitute “keyword” with the actual keyword.

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$ 

Keyword 7

Identification and definition of the chosen keyword. Substitute “keyword” with the actual 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);
}

Keyword 8

Identification and definition of the chosen keyword. Substitute “keyword” with the actual keyword.

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$ 

Keyword 9

Identification and definition of the chosen keyword. Substitute “keyword” with the actual 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);
}

Keyword 10

Identification and definition of the chosen keyword. Substitute “keyword” with the actual keyword.

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$ 

Keyword 11

Identification and definition of the chosen keyword. Substitute “keyword” with the actual 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);
}

Keyword 12

Identification and definition of the chosen keyword. Substitute “keyword” with the actual keyword.

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$ 

sysprog Topics

Keyword 1: i/o redirection

.

  • Redirection is a common to command line interpreters in unix that allow for for standard i/o to be redirected to specified locations.

Keyword 2: Pipes

  • Pipes are used with redirection, basically altering the command entered so it does something different than default

Keyword 3 Server/socket

  • A server accepts and processes requests from clients
  • A server requires a socket to access the network. A socket is an endpoint of communication allowing a network application to plug into the network. You typically only have one physical interface but many software sockets can use a single interface simultaneously.

Keyword: Client server model

  • In the client/server model the server accepts process requests placed by the client. The server sets up server sockets that have an address and able to receive connections. Clients create client sockets which do not care about their address. A server can either directly handle the request itself or fork to create a new process to handle the process.

Keyword 5: Coroutines

  • Coroutines are connected processes that work together to complete a function. The processes continue to run and control is passed from one to another as each completes a certain task.

Keyword 6: connections and protocols

  • A connection is when the client and server are linked allowing for data to be to be sent and received.
  • Protocols are the rules of communication between the client and server.

Keyword 7: Server socket

Keyword 8: client sockets

Keyword 9: Zombie

  • A zombie process or a defunct process is a process that has died bstull still has an uncollected exit value.

Keyword 10: Datagrams

  • Datagram communicaton isdoes not make a connection like sockets but instead simply sends a message to an address.

Keyword 11: Tcp vs. udp

  • Tcp aka transmission control protocol is used for non time critical applications
  • Udp aka User Datagram Protocol is used when timing is a little more critical

resource

Keyword 12: Distributed systems

  • A **distributed system* is a series of computers connected through a network but with the added benefit of being able to share all resources of the system.

resource

cprog Objective

Objective

State the course objective; define what that objective entails.

Method

State the method you will use for measuring successful academic/intellectual achievement of this objective.

Measurement

Follow your method and obtain a measurement. Document the results here.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • How did you do?
  • Room for improvement?
  • Could the measurement process be enhanced to be more effective?
  • Do you think this enhancement would be efficient to employ?
  • Could the course objective be altered to be more applicable? How would you alter it?

data Objective

Objective

State the course objective; define what that objective entails.

Method

State the method you will use for measuring successful academic/intellectual achievement of this objective.

Measurement

Follow your method and obtain a measurement. Document the results here.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • How did you do?
  • Room for improvement?
  • Could the measurement process be enhanced to be more effective?
  • Do you think this enhancement would be efficient to employ?
  • Could the course objective be altered to be more applicable? How would you alter it?

hpc1 Objective

Objective

State the course objective; define what that objective entails.

Method

State the method you will use for measuring successful academic/intellectual achievement of this objective.

Measurement

Follow your method and obtain a measurement. Document the results here.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • How did you do?
  • Room for improvement?
  • Could the measurement process be enhanced to be more effective?
  • Do you think this enhancement would be efficient to employ?
  • Could the course objective be altered to be more applicable? How would you alter it?

sysprog Objective

Objective

State the course objective; define what that objective entails.

Method

State the method you will use for measuring successful academic/intellectual achievement of this objective.

Measurement

Follow your method and obtain a measurement. Document the results here.

Analysis

Reflect upon your results of the measurement to ascertain your achievement of the particular course objective.

  • How did you do?
  • Room for improvement?
  • Could the measurement process be enhanced to be more effective?
  • Do you think this enhancement would be efficient to employ?
  • Could the course objective be altered to be more applicable? How would you alter it?

Experiments

Experiment 1: NoTouchy!

Question

Can a child touch its parents private parts?

  • The code below will have a child class inherit private parts:
#include <iostream>
 
using namespace std;
 
class parent
{
	private:
		int number;
};
 
 
class child : private parent
{
 
	public:
		char character;
		void print();
};
 
int main()
{
	child notouchy;
	notouchy.number = 10;
	notouchy.print();
 
	return 0;
}
 
 
void child::print()
{
	cout<<number;
}
  • Here is what happens when you compile:
lairstation3:~/Desktop$ g++ privateparts.cc -Wall
privateparts.cc: In function ‘int main()’:
privateparts.cc:8: error: ‘int parent::number’ is private
privateparts.cc:23: error: within this context
privateparts.cc: In member function ‘void child::print()’:
privateparts.cc:8: error: ‘int parent::number’ is private
privateparts.cc:32: error: within this context
  • As you can see on line 8 you get an error that the variable is private.
  • Just to verify I am going to change from private to public and it will now work.
#include <iostream>
 
using namespace std;
 
class parent
{
	public:
		int number;
};
 
 
class child : public parent
{
 
	public:
		char character;
		void print();
};
 
int main()
{
	child notouchy;
	notouchy.number = 10;
	notouchy.print();
 
	return 0;
}
 
 
void child::print()
{
	cout<<number;
}
  • Here is what happens when I compile and run after changing from private to public:
lairstation3:~/Desktop$ g++ privateparts.cc -Wall
lairstation3:~/Desktop$ ./a.out
10
  • as you can see the code now compiled and runs, so a child class cannot touch its parents private parts.

Experiment 2: Private/Public default?

Question

When declaring variables within a class do they default to private or public?

  • I am going to use the same code I used for my notouchy experiment.
  • I am simply going to remove any reference to public or private and see what happens!
#include <iostream>
 
using namespace std;
 
class parent
{
 
		int number;
};
 
 
class child : parent
{
 
 
		char character;
		void print();
};
 
int main()
{
	child notouchy;
	notouchy.number = 10;
	notouchy.print();
 
	return 0;
}
 
 
void child::print()
{
	cout<<number;
}
  • Here is what happens when you compile:
lairstation3:~/Desktop$ g++ privateparts.cc -Wall
privateparts.cc: In function ‘int main()’:
privateparts.cc:8: error: ‘int parent::number’ is private
privateparts.cc:23: error: within this context
privateparts.cc:17: error: ‘void child::print()’ is private
privateparts.cc:24: error: within this context
privateparts.cc: In member function ‘void child::print()’:
privateparts.cc:8: error: ‘int parent::number’ is private
privateparts.cc:32: error: within this context
lairstation3:~/Desktop$ 
  • As you can see by the error's the default for classes is private!

Experiment 3: Does inheritance from parent to child default to public parts?

  • Typically when declaring a child class you use put “public” in front of the parent class. Being that a child can only inherit the public parts of a parent class, I want to test what will happen if you do not put public in front of parent.
#include <iostream>
 
using namespace std;
 
class parent
{
	Public:
		int number;
};
 
 
class child : parent
{
 
	Public:
		char character;
		void print();
};
 
int main()
{
	child notouchy;
	notouchy.number = 10;
	notouchy.print();
 
	return 0;
}
 
 
void child::print()
{
	cout<<number;
}
  • Weird things happen when compiling:
lairstation3:~/Desktop$ g++ privateparts.cc -Wall
privateparts.cc: In function ‘int main()’:
privateparts.cc:8: error: ‘int parent::number’ is inaccessible
privateparts.cc:23: error: within this context
lairstation3:~/Desktop$ 
  • I was really not expecting this and couldn't figure it out at first, then I tried putting private in front of parent on line 12
#include <iostream>

using namespace std;

class parent
{
	public:
		int number;
};


class child : private parent
{

	public:
		char character;
		void print();
};

int main()
{
	child notouchy;
	notouchy.number = 10;
	notouchy.print();

	return 0;
}


void child::print()
{
	cout<<number;
}
  • Here is the compilation errors again:
privateparts.cc: In function ‘int main()’:
privateparts.cc:8: error: ‘int parent::number’ is inaccessible
privateparts.cc:23: error: within this context
lairstation3:~/Desktop$ 
  • So it turns out that the default is once again private!
opus/fall2011/kkrauss1/part3.txt · Last modified: 2011/12/02 22:16 by kkrauss1