Table of Contents

Derek's fall 2012 Opus

Mind of the Dataking

Introduction

Welcome to the opus of the dataking! I am called the dataking because of how much data i have used in the class from projects i have been working on. So i have done a few big projects throughout all of classes. And that is a perfect segway into the introduction of me: I am a computer science student in the programming field. This will be my last semester of corning hopefully recieving my Associates in computer science. I plan after this is to transfer to Binghamton university to further my education and I hope it works out. In my spare time i enjoy playing/making music, playing videogames, and doing anything that is fun. I dont know what else to really say so after you have read this, from here on out you will be seeing all my work throughout my classes for the semester and all my thoughts of these classes week by week. Enjoy and… yea. :)

Part 1

Entries

Entry 1: September 7, 2012

This is the second week of school and our classes are finally starting to become in depth with the course. Of course i mean that like we are starting to dive into the meat of the courses and that makes me happy. In data comm we have started to work with a OS called Asterisk, which will allow us to make phone calls within a local area network. We are just kind of messing around with it to see what we can do and hopefully create our E alert system that we want to create. In data structures we have begun working with datatypes to make sure we are well known with our datatypes. We have to understand the difference and size of each type like int or char to fully understand what kind of data will be going in through our program. In hpc i will be creating a drum machine, so for starters i am just researching ways to create music through linux/C programming and hopefully soon start creating noise with this :D.

Entry 2: September 14, 2012

This week we are head way into making our programs and getting our projects together and such. In data comm we are starting to understand the basics of asterisk. We were able to connect some Voip phones to asterisk so we actually have something we can call to test. We have also discovered that we can throw on our own personal audio onto a certain number or phone number. But for now we just need to succesfully connect all our phones together so we can call each other, I will however try to start converting audio that we can use within the phones. In data structures we are starting on singly linked lists. Its a list of nodes that holds pointers that point to data in a list. but with this list we are only able to go forward so we must learn how to manipulate these lists so we can insert, append and delete nodes at any point in the list. In HPC i have actually started working on a program that will be able to record and playback what i have recorded which will be good cause i can make my own drum samples if i must. I will be accessing the dev/dsp sound driver to access the sound capabilities. So i will be working on this program and hopefully it will work.

Entry 3: September 21, 2012

In data structures we started to take a look at doubly linked lists. It is basically the same as a singly linked list but you have the ability to go forward and backwards. So it will be easier to navigate through a list since you can go back now, however new implementation needs to be learned. But until we really get into them, we are just working on singly linked list projects so we can totally understand for future projects. In Data comm i have been able to put a lot of audio onto the phone. I know exactly how to convert mp3 to gsm so it could be played over a phone line. Then we were able to get asterisk to speak to freeswitch now we just need freeswitch to speak to google voice so we can call anyone we want. So its still a work in progress. And in hpc i havent really touched anything in this class this, i have been focused on getting these projects done so i can work on my own independent project.

Entry 4: September 28, 2012

This week in data structures we still continues on with singly linked lists and just working on them. I have deletion completed but i still have to do insertion. I thought insertion was the same as append, which technically it is, but come to find out insertion is where you place a new node behind and not after like append. So i am little late on that program but i shall have it finished very soon. But other then that, we did more on learning doubly linked and we messed with a deugger little bit on friday. Its a really nifty tool but i think i prefer just debugging a program on my own. In data comm we are still trying to get freeswitch to talk to google but other then that, not much has been done. I added a little audio and i am going to figure out how to make my own automated audio for some audio fun. And in hpc i once again didnt really do much with it, i did some research but i really need to do a lot more if i plan on making this drum machine.

Keywords

Structure Pointer

Definition

A structure pointer is a pointer that points to a structure! Like any pointer,it points to an address in memory. And a structure has multiple elements in one block. Now you can pass and return these structures through functions to get the data you want but this is excessive data movement so to reduce this you would pass a pointer to the structure to the function. All we would have to do is reference the pointer to the struct then dereference it to receive the data we want.

#include <stdio.h>
#include <string.h>
 
struct tag{                     /* the structure type */
    char lname[20];             /* last name */
    char fname[20];             /* first name */
    int age;                    /* age */
    float rate;                 /* e.g. 12.75 per hour */
};
 
struct tag my_struct;           /* define the structure */
void show_name(struct tag *p);  /* function prototype */
 
int main(void)
{
    struct tag *st_ptr;         /* a pointer to a structure */
    st_ptr = &my_struct;        /* point the pointer to my_struct */
    strcpy(my_struct.lname,"Jensen");
    strcpy(my_struct.fname,"Ted");
    printf("
%s ",my_struct.fname);
    printf("%s
",my_struct.lname);
    my_struct.age = 63;
    show_name(st_ptr);          /* pass the pointer */
    return 0;
}
 
void show_name(struct tag *p)
{
    printf("
%s ", p->fname);  /* p points to a structure */
    printf("%s ", p->lname);
    printf("%d
", p->age);
}

References

data Keyword 1 Phase 2

Null Pointers

Definition

A Null pointer is a pointer that points definitively nowhere. It is a special pointer that is used to symbolize that the pointer is pointing at nothing or that there is nothing there. The null pointer is commonly used in malloc, when it fails it returns a null pointer because nothing happened so therefore you get nothing in return.

References

None on this one :)

Demonstration

There is no real way to demonstrate this, if this was compiled in a program it will just come up as undefined or 0 or NULL.

Definition

The link layer is the lowest level in the TCP/IP model. It is a level that contains methods and protocols that only work on the hosts link. It is used in the connections of LAN and WAN, like a phone service that is local to a group or organization and maybe they will eventually branch out onto a WAN connection. This layer is to help connection 2 or more clients to be able to connect and communicate effectively.

References

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

  • Reference 1
  • Reference 2
  • Reference 3

datacomm Keyword 1 Phase 2

VoIP. Voice overlay Internet Proticol

Definition

a system and internet proticol that allows to transmite and receive human voice form one place to another much like the preadvent the tele phone which is analog but in order to use it via computer and the interwebs u need to digitize the sound wave length, tone and pitch of a human voice then transmit via the VoIP system which im not intirely sure of all that happens.

References

  • Astrisk pbx
  • Astrisk pbx wikipedia
  • netcat
  • netcat wikipedia
  • VoIp Wikipedia

Demonstration

Basically voip is like any other telephone except it is used threw the computer. You can connect to someone over the internet or someone inside your home. There is no code or executions to demonstrate how this works, download a voip softphone and boom! discover its magic by dialing in a number or 2.

ALSA/OSS/FIREWIRE

Definition

ALSA stands for Advanced Linux Sound Architecture. It provides sound and MIDI functionality to linux. It supports all types of different sound interfaces, has a safe design and it supports OSS (Open Sound System). Its free and open source so programmers all around have the ability to tinker with it and have fun (so to speak). FIREWIRE is kind of like an ethernet cable or a USB cable. However it has different goals it wants to achieve such as: fast data transfer, ability to handle multiple devices, easy use, plug and play, low cost and hot pluggable ability. It was first established by apple and later standardized by many. It is used mainly for the transfer of audio and media.

References

hpc1 Keyword 1 Phase 2

SPARC

Definition

SPARC is a scalable Processor Architecture RISC instruction set. This is a micro processor that is widely used in sun micro systems hardware.

References

Demonstration

Experiment 1

Question

Can i access the dev/dsp sound driver to enable use of my program?

Resources

Hypothesis

I feel this will not work because i do realize this is an outdated sound driver that has been replaced by ALSA. But i am curious if it is still able to be used at all, maybe its there i just have to find a way to access it and use it.

Experiment

I have a program written for HPC that will access this sound driver if it exists. After i have shown if the dev/dsp is there or not, i will try to locate it and see if i can still use it or not.

Data

1. Here is the program i have written that is suppose to record and replay the recording:

 1 /*
  2 *parrot.c
  3 *Program to illustrate /dev/dsp device
  4 *Records several seconds of sound, then echoes it back
  5 *runs until Control-c pressed.
  6 */
  7
  8 #include <unistd.h>
  9 #include <fcntl.h>
 10 #include <sys/types.h>
 11 #include <sys/ioctl.h>
 12 #include <stdlib.h>
 13 #include <stdio.h>
 14 #include <linux/soundcard.h>
 15
 16 #define LENGTH 3  /*how many seconds of speech to store */
 17 #define RATE 8000 /*the sampling rate*/
 18 #define SIZE 8 /*sample size: 8 or 16 bits */
 19 #define CHANNELS 1 /* 1 = mono, 2 = stereo */
 20
 21 /*this buffer holds the digitized audio*/
 22 unsigned char buf[LENGTH*RATE*SIZE*CHANNELS/8];
 23
 24 int main()
 25 {
 26     int fd;
 27     int arg;
 28     int status;
 29
 30     /*open sound device*/
 31     fd = open("/dev/dsp", O_RDWR);
 32
 33     if(fd < 0)
 34         {
 35             perror("open of /dev/dsp failed");
 36             exit(1);
 37         }
 38
 39     /*set sampling parameters */
 40     arg = SIZE;      /*sample size*/
 41
 42     status = ioctl(fd, SOUND_PCM_WRITE_BITS, &arg);
 43
 44     if (status == -1)
 45         perror("SOUND_PCM_WRITE_CHANNELS ioctl failed");
 46     if (arg != SIZE)
 47         perror("unable to set sample size");
 48
 49     arg = CHANNELS; /*mono or stereo*/
 50
 51     status = ioctl(fd, SOUND_PCM_WRITE_CHANNELS, &arg);
 52
 53     if (status == -1)
 54         perror("SOUND_PCM_WRITE_CHANNELS ioctl failed");
 55     if (arg != CHANNELS)
 56         perror("Unable to set number of channels");
 57
 58     arg = RATE;  /*sampling rate*/
 59     status = ioctl(fd, SOUND_PCM_WRITE_RATE, &arg);
 60     if(status == -1)
 61         perror("SOUND_PCM_WRITE_WRITE ioctl failed");
 62     while (1)    /*loop until ctr-c*/
 63         {
 64             printf("say something:\n");
 65             status = read(fd, buf, sizeof(buf)); /*record some sound*/
 66             if(status != sizeof(buf))
 67                 perror("read wrong number of bytes");
 68             printf("you said:\n");
 69             status = write(fd, buf, sizeof(buf)); /*play it back*/
 70             if (status != sizeof(buf))
 71                 perror("Wrote wrong number of bytes");
 72         /*wait for playback to complete before recording again*/
 73             status = ioctl(fd, SOUND_PCM_SYNC, 0);
 74         if (status == -1)
 75             perror("SOUND_PCMSYNC ioctl failed");
 76         }
 77 }
 78

2. I have run the program to get this message:

lab46:~/src/hpc$ ./parrot
open of /dev/dsp failed: No such file or directory
lab46:~/src/hpc$

3.Now i go for a search of the dev/dsp:

lab46:~$ cat /proc/asound/pcm
lab46:~$ cd proc
-bash: cd: proc: No such file or directory
lab46:~$ cd ..
lab46:/home$ cd ..
lab46:/$ cd proc
lab46:/proc$ cd asound
lab46:/proc/asound$ cd pcm
-bash: cd: pcm: Not a directory
lab46:/proc/asound$ ls
cards  devices  modules  oss  pcm  seq  timers  version
lab46:/proc/asound$ cat pcm
lab46:/proc/asound$ cat devices
  2:        : timer
lab46:/proc/asound$ cat cards
--- no soundcards ---
lab46:/proc/asound$ cd ..
lab46:/proc$ ls
1      11118  11232  12735  16787  19     2274   24531  28441  28539  28600  3133   38    3978  4827  6485  asound       interrupts  modules        timer_stats
10     11122  11233  12736  16788  19252  2275   24642  28449  28540  28601  3135   3803  3981  5     6918  buddyinfo    iomem       mounts         tty
1001   11123  11235  128    16791  19253  2278   24849  28497  28549  28622  3136   388   3983  500   7     bus          ioports     net            uptime
1014   11142  11272  12923  16889  19256  22800  2562   28502  28550  28629  3140   389   3984  5129  7504  cgroups      irq         pagetypeinfo   version
1023   11143  11336  13     16890  2      22801  2565   28503  28558  28632  31855  3904  4     5130  8     cmdline      kallsyms    partitions     vmallocinfo
1029   11147  11339  14     16900  20     22824  2566   28507  28559  29     31857  3907  4007  594   8015  cpuinfo      kcore       sched_debug    vmstat
1038   11148  11348  14725  17     20034  22827  2570   28508  28582  29150  32     3959  4012  6     8141  crypto       key-users   self           xen
1045   11152  11351  14727  178    20035  22891  25728  28517  28583  29151  32024  3961  461   629   8142  devices      keys        slabinfo       zoneinfo
1079   11153  11356  14728  17863  20038  23     26269  28518  28592  29156  32130  3962  462   6310  861   diskstats    kmsg        softirqs
1088   11188  11364  14836  17864  20590  23492  26294  28522  28594  29572  32150  3968  475   6311  862   dma          kpagecount  stat
1098   11189  11896  15     18     21     23493  26299  28523  28595  29573  33     3970  476   6315  8643  driver       kpageflags  swaps
11     1121   12     15037  18303  2156   23497  26302  28527  28596  29576  34     3971  477   6365  9     execdomains  loadavg     sys
11112  11228  12337  15985  18976  217    24     27     28528  28597  3      35     3973  4821  6366  951   fb           locks       sysrq-trigger
11113  11229  12338  16     18977  218    24497  28     28534  28598  30     369    3974  4823  6444  960   filesystems  meminfo     sysvipc
11117  11231  12341  16406  18980  22     24498  28440  28535  28599  31     375    3977  4824  6445  974   fs           misc        timer_list
lab46:/proc$ cd asound
lab46:/proc/asound$ ls
cards  devices  modules  oss  pcm  seq  timers  version
lab46:/proc/asound$ cd oss
lab46:/proc/asound/oss$ ls
devices  sndstat
lab46:/proc/asound/oss$ cat sndstat
Sound Driver:3.8.1a-980706 (ALSA v1.0.21 emulation code)
Kernel: Linux lab46 2.6.32-5-xen-amd64 #1 SMP Mon Jan 9 22:09:26 UTC 2012 x86_64
Config options: 0

Installed drivers:
Type 10: ALSA emulation

Card config:
--- no soundcards ---

Audio devices: NOT ENABLED IN CONFIG

Synth devices: NOT ENABLED IN CONFIG

Midi devices: NOT ENABLED IN CONFIG

Timers:
31: system timer

Mixers: NOT ENABLED IN CONFIG
lab46:/proc/asound/oss$

Analysis

Based on the data collected:

  • Was your hypothesis correct? Yes it was
  • Was your hypothesis not applicable? It is applcable because its part of my project
  • Is there more going on than you originally thought? Yes because i have read somewhere the dev/dsp can be found and enabled under ALSA. I feel its somewhere but maybe not under lab46. I will have to do further research on this to find out.
  • What shortcomings might there be in your experiment? Maybe my program was wrong or maybe i did not look hard enough
  • What shortcomings might there be in your data? I could be looking at the wrong data or just not looking in the right place

Conclusions

I now know that i must enable the use of ALSA in my program unless i am able to find a way to enable the use of dev/dsp under ALSA-oss. I believe i can find it and i will continue until i can. If i can not find it, then i will just have to modify and move on.

Part 2

Entries

Entry 1: October 5th, 2012

This week has been a work week on doubly linked lists. Working on a menu driven program that do the same thing as a singly but instead of only moving forward, it can transverse both forward and backwards. I am going to try this project differently by instead of following the nodes, it will follow the content inside. The only obstacle i will have to face is getting over duplication of numbers so we shall see. In my data comm class we are still working on asterisk, finding new implementations everyday! and for HPC, well.. i should do more work with that

Entry 2: October 12th, 2012

This week we have actually learned some new things! We learned stacks, which are like containers that hold data and spit back out. But it acts differently, like it takes in the data but the last piece to go in is what comes out first. So it reverses the data that is entered and this can be used in certain instances. Another thing we learned is recursion, where a function calls itself so it will loop within itself until it hits a stopping point! This is very useful and i actually will be using it in my list because i believe it will come in handy printing out a list backwards, so will a stack but i dont completely understand it yet with the push and pop functions. Data comm and HPC are still the same where they are, working on asterisk and not working on my drum machine.. i need to step it up or else its going to be a bad time. I just cant get arduino to work!

Entry 3: October 19th, 2012

This is week is another work week but our doubly linked menu were due. And mine was pretty boss, i am now called the recursion king! Just to let you all know. But seriously i got recursion to work in my program and it was a very different implementation then the other programs and i was quite proud of it. Now i just need to work on my stack program, which now i do understand more and i will have to start working on it very soon. We havent really learned anything else, just a test and working on programs. Nothing else. Still trying to get arduino to work on linux and i am having no luck, it wont execute files for some reason for to run the program. Like it wont download the software i need, i have to look deeper in i guess. And i kind of miss data comm this week and came back to working on something new with sound files and images. We will see where this goes lol

Entry 4: October 26th, 2012

This week has been an interesting week, with hurricane sandy coming through. So most of our projects were pushed ahead a week so thats good because i procrastinate a lot :D but other then that, we learned about a binary tree sort, which doesnt seem to hard conceptually but implementing it might be difficult. We can either use recursion, iteration or stacks and you better believe im using recursion, i want to get better with them. So after this stacks program is done i will be doing research on the binary tree and start headway onto the project that will be put out in the future. For HPC i am still stuck on making any headway into this project, i just dont understand why i cant access the software or my sound driver, im in a rut. And for data comm i am not totally sure whats going on because i missed class because of the hurricane so i dont know what we are doing yet!

Keywords

stack data structure

Definition

A stack is a very important part in computer science, especially in the programming field. This could be helpful in many functions even like a simple yet probably not widely used function, reversing a string. Its simple but if we didn't use a stack, it would seem mildly difficult. A stack is like a deck of playing cards, you place one card down and continue stacking cards on top. Then when you are ready, you take the top card off and continue on down. Thats how a stack works, push stuff in and pop stuff off, LIFO (Last in, First out).

References

data Keyword 2 Phase 2

queue overrun condition

Definition

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

References

Demonstration

When you have a overflow, you attempting to add more to something you can not simply add more too. Okay lets say you have a queue of size 5. So you throw in five numbers such as: 27, 6, 45, 87, and 92. The numbers dont really matter, you can throw in 1-5 for all i care lol. The point is, this will run just fine but once you try to push on another such as 23, it will produce an error or a seg fault if you have prepared for this error, that error will be a overflow. You have put too much on hat the size of the queue just can not handle.

datacomm Keyword 2

IVR system

Definition

IVR system is the automated voice that you hear when you call some company! This automated voice helps direct the user through a series of steps that the user has to go through to complete a task. They can either use touch tones, dial tones from the keypad or even use their own voice. Basically it eliminates the need for an actual person to do the work when the computer can do it all! It can do simple tasks to very advanced ones, either way its a very useful to be using.

References

datacomm Keyword 2 Phase 2

Freeswitch

Definition

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.

References

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

  • Reference 1
  • Reference 2
  • Reference 3

Demonstration

This link above is showing real world applications of the freeswitch and how well it worked in real life. Freeswitch is like a phone that will use voip, and if you implement it right with say, oh i dont know asterisk, you can eventually get a free phone service going in your LAN. Now people have made it able to be used with WAn, like where they can call other people not in your network or in your config files and that link above will show that. other than that, i dont really know how else to demonstrate but to show where it can be used in real life.

Data Buffer

Definition

Data buffer is a place in physical memory that holds data temporarily while it is being moved from one place to another. So say you have music from one place you want to move to another, well when you make this transfer that sound will be held in a buffer during the process of moving. A buffer will be very useful in the project of creating my drum machine. When i get access to the sound drivers and transfer the sound over that i want, im going to need many buffers to hold all this data while it is being moved from input, to process, to output. here is some example code:

typedef struct {
    void             *buffer;
    int32_t           length;
    int32_t           tail;
    int32_t           head;
    volatile int32_t  fillCount;
} TPCircularBuffer;
 
bool  TPCircularBufferInit(TPCircularBuffer *buffer, int32_t length);
void  TPCircularBufferCleanup(TPCircularBuffer *buffer);
void  TPCircularBufferClear(TPCircularBuffer *buffer);
 
// Reading (consuming)
void* TPCircularBufferTail(TPCircularBuffer *buffer, int32_t* availableBytes);
void  TPCircularBufferConsume(TPCircularBuffer *buffer, int32_t amount);
 
// Writing (producing)
void* TPCircularBufferHead(TPCircularBuffer *buffer, int32_t* availableBytes);
void  TPCircularBufferProduce(TPCircularBuffer *buffer, int32_t amount);
int   TPCircularBufferProduceBytes(TPCircularBuffer *buffer, const void* src, int32_t len);

References

Data Buffer Phase 2

Definition

Data buffer is a place in physical memory that holds data temporarily while it is being moved from one place to another. So say you have music from one place you want to move to another, well when you make this transfer that sound will be held in a buffer during the process of moving. A buffer will be very useful in the project of creating my drum machine. When i get access to the sound drivers and transfer the sound over that i want, im going to need many buffers to hold all this data while it is being moved from input, to process, to output. here is some example code:

typedef struct {
    void             *buffer;
    int32_t           length;
    int32_t           tail;
    int32_t           head;
    volatile int32_t  fillCount;
} TPCircularBuffer;
 
bool  TPCircularBufferInit(TPCircularBuffer *buffer, int32_t length);
void  TPCircularBufferCleanup(TPCircularBuffer *buffer);
void  TPCircularBufferClear(TPCircularBuffer *buffer);
 
// Reading (consuming)
void* TPCircularBufferTail(TPCircularBuffer *buffer, int32_t* availableBytes);
void  TPCircularBufferConsume(TPCircularBuffer *buffer, int32_t amount);
 
// Writing (producing)
void* TPCircularBufferHead(TPCircularBuffer *buffer, int32_t* availableBytes);
void  TPCircularBufferProduce(TPCircularBuffer *buffer, int32_t amount);
int   TPCircularBufferProduceBytes(TPCircularBuffer *buffer, const void* src, int32_t len);

References

Demonstration

here is an example of a simple buffer:

typedef struct BufferBlockHeader_st BufferBlockHeader;
 
struct BufferBlockHeader_st {
   BufferBlockHeader * pNextBlock;
};
 
struct Buffer_st {
   long  int             totalLength;
   BufferBlockHeader *   pFirstBlock;
   short int             startPoint;
   BufferBlockHeader *   pLastBlock;
   short int             endPoint;
};
 
typedef struct Buffer_st Buffer;

Its only the buffer so this is not a full program or anything, its just showing how it would be created and used. Its being thrown in with a linked list while the buffer are holding data that will eventually be placed within the list itself. That is what a buffer will do!

Experiment 2

Question

Is it possible to convert decimal to binary using recursion instead of loops?

Resources

As the recursion king i am using my knowledge to put forth new experiments into my kingdom. Recursion is where a fucntion will call itself and loop till it reaches a sentinel value and will print out your data, recursively! Now i will be doing a decimal to binary conversion, which is simple to do by hand and or even write out an algorithm on a computer. Here is a bash script that was written that converts decimal to binary:

  1 #!/bin/bash
  2 a=0
  3 echo -n "please enter a number: "
  4 read number
  5 until [ $number -eq 0 ];do
  6 n=0
  7 until [ `echo "$number-2^$n"|bc` -lt 0 ];do
  8     let n=$n+1
  9 done
 10 let n=$n-1
 11 let number=$number-`echo "2^$n"|bc`
 12 places=""
 13 for((i=0;i<$n;i++));do
 14     places="${places}0"
 15 done
 16 places="1${places}"
 17 let a=$a+$places
 18 done
 19 echo "the binary is: $a "
 20 exit 0

This is a example of the algorithm that is used in converting these numbers and it will be used in this experiment just taken a different way, without loops! :D

Hypothesis

I believe it can easily be done, with the algorithm i know that can solve this problem, i believe with the implementation that i will be using will make this easy, in fact even easier then loops and if statements!

Experiment

Im going to write the program, compile it, and run it and see if it works!

Data

1> Write the code:

  1 #include <stdlib.h>
  2 #include <stdio.h>
  3 
  4 
  5 int binary(int);
  6 
  7 int main()
  8 {
  9 
 10     int nb; /*This is number binary, its just a variable the name doesnt really matter*/
 11     int nd;     /*this is number decimal and same here lol*/
 12 
 13     printf("Please enter any decimal number: ");
 14     scanf("%d", &nd);
 15 
 16     nb = binary(nd);
 17     printf("Binary value is: %d\n", nb);
 18 
 19     return 0;
 20 }
 21 
 22 int binary(int nd)
 23 {
 24 
 25     static int nb,remainder,factor = 1;
 26 
 27     if(nd != 0)
 28     {
 29         remainder = nd % 2;
 30         nb = nb + remainder * factor;
 31         factor = factor * 10;
 32         binary(nd / 2);
 33     }
 34 return nb;
 35 
 36 }

2. Execute code:

lab46:~/src/datastruc$ ./binaryrecursion 
Please enter any decimal number: 10
Binary value is: 1010
lab46:~/src/datastruc$ 

Side note to you and mainly myself lol: The static was used because when the fucntion calls itself it actually loses the data that was held with the remainder, factor and nb. So i looked up what to do about that and static was one, which keeps the data held there long after the scope of the fucntion is over so when it is called again we can still have that data and it will be good to go! Or also, i could have passed them all through the fucntion and made it a void so i wouldnt run into that issue, but both ways will work just fine.

Analysis

Based on the data collected:

  • My hypothesis was correct!
  • My hypothesis is very applicable because it worked, duh :)
  • Umm no not really, i knew what was going on i was just seeing if this was possible
  • There might be more going on that i really know or understand, but other than that, i understand what is happening.
  • It may not go high enough for certain numbers since it is using int data value, but it still works just like it is suppose to work.

Conclusions

What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.

Part 3

Entries

Entry 1: November 2nd, 2012

In data structures this week we have been working on stacks and what not. We have to create a program that takes in data and spits it back out. It pretty much has been a work on stuff week and not much else has been progressed. I had to restart my program because it was not working the way i planned so i will start fresh! In data comm we actually are sending data through a string and 2 cups. We are going to see how well this goes.. we just need he cups. In hpc, i kind of stopped on the drum machine because i am making no progress what so ever so i have decided to undergo a new project but i dont know what yet!

Entry 2: November 9th, 2012

This week in data structures our stack program was due and it seems to be working out great. So i should be getting a good grade on it and such. We also started learning about makefiles, c standards and libraries. These will be very essential in bigger projects of programs when we are trying to organize all of our files and functions. Its kind of confusing but im sure i will understand eventually. In data comm we got the cups and string and now we have a program that will amplify the sound of data and another computer that will receive its sound through the microphone but instead of putting them close, we will send it through cups and string. It did not work too great, i mean we sent a picture at least. And for hpc i think my next project will be working on this computer i got. I was asked to fix it so i figured it would be a nice side project.

Entry 3: November 16th, 2012

This week for data structures we have been introduced to the binary search tree, its a way to search through a list of numbers or characters and even possibly organize these numbers if thats what you wish for your program to do. It seems like a lot of fun so i guess we will see how this goes! i need to do more research on it and see what i should do from here on out. In data comm we uh kind of failed at the cup thing so i think we are done with that, we have moved back to doing our usual things by working on asterisk and such. Hpc i have this computer and i am still testing the possibilities of why this computer will not turn on, its either the power cord or the motherboard. I need to use a volt meter on the cord next week to test to see if power is flowing so i can rule out simple possibilities and such.

Entry 4: November 23rd, 2012

This week of data structures we are still pretty much working on binary search tree and we had a knowledge assessment as well! I did really good except for some stupid mistake but thats ok i guess, but yea its pretty much just a work day on programs and such and nothing else really. The EOCE is on its way though so i have to get prepared for end projects and such so i need to get a move on with this search tree and that computer. The hpc and data comm eoce is not all that bad except i need to just so off a few projects i have so i need to go and collect all the data that i do have on the projects i have been doing so that shouldn't be too hard but we will see. But other then that its the end of the semester so i just need to finish up all of my projects and what not and im free :D

Keywords

Binary Search Tree

Definition

A binary search tree can also be named as a sorted/ordered search tree. Its a tree that has nodes that stem off into small search trees. It uses a linked list (doubly) that goes left and right. Numbers are placed in the nodes throughout the tree and with the correct algorithm it can traversed through going least to greatest or vice versa. Generally the left tree will have values that are less then the root (starting node) and the right tree will have values greater. The first node is called the root and the final nodes (depending on where it ends) are considered the leaves of the trees since that are the last on the tree.

References

data Keyword 3 Phase 2

tree rebalancing

Definition

In computer science, a self-balancing (or height-balanced) binary search tree is any node-based binary search tree that automatically keeps its height (number of levels below the root) small in the face of arbitrary item insertions and deletions. These structures provide efficient implementations for mutable ordered lists, and can be used for other abstract data structures such as associative arrays, priority queues and sets.

References

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

* Reference 2:wikipedia.com

Demonstration

One example of a self-balancing tree is an AA tree. AA trees require O(log(N)) bits of metadata per node, in the form of an integer “level”. The following is an example of a function that this tree would use, split:

function split is
    input: T, a node representing an AA tree that needs to be rebalanced.
    output: Another node representing the rebalanced AA tree.
 
    if nil(T) then
        return Nil
    else if nil(right(T)) or  nil(right(right(T))) then
        return T
    else if level(T) == level(right(right(T))) then
        We have two horizontal right links.  Take the middle node, elevate it, and return it.
        R = right(T)
        right(T) := left(R)
        left(R) := T
        level(R) := level(R) + 1
        return R
    else
        return T
    end if
end function

Opportunistic encryption

Definition

This word applies to any system thats connecting to another system and attempts to encrypt the communications channel otherwise falling back to unencrypted communications. This process requires no previous configurations of the two systems, so the OE process should run just fine on both systems.

References

datacomm Keyword 3 Phase 2

Virtual Private Network

Definition

A virtual private network extends a private network through a tunnel to other computers. It is highly secure and uses encryption to port network activity under a tunnel

References

Demonstration

Memory Module

Definition

A memory module is a really broad term for Ram or other integrated circuits that deal with some sort of memory. These are circuits that are mounted up on the motherboard or other places and it is mainly used for personal computers and laptop. Some specific types of memory modules are Dual inline package, transflash memory module, SIPP Memory, SIMM and DIMM. And what separates all of these are its volts, bits or storage.

References

Debugging

Definition

This is a process that a programmer or network administrator would do to determine a problem within in a program or network. Debugging happens by knowing the error codes or having a debugger installed that will pick apart programs. It can be a difficult time when there are many many different sub programs happening and what not. You need control flow, integration testing and more!

References

Demonstration

Not really a way to demonstrate except for following the steps to debug and find an error! here is a website that helps break it down:http://en.wikipedia.org/wiki/Memory_module

Experiment 3

Question

Can i assign a integer to a unsigned char in c?

Resources

Hypothesis

I believe this can be done in some possible way, i know you can do it in c++ so why not in c? :)

Experiment

I am going to test out a program that shows the normal way and what i want to do with the character type.

Data

#include <stdio.h>
int main()
{
unsigned char *A,*B;
unsigned char C='X';
int Integr_val=320;
B=&C ;
A=(unsigned char *)&Integr_val;
*B= Integr_val;
return printf("\n %c,%i\n %c,%i",*A *A,*B,*B);
}

output:

lab46:~/src/datastruc$ ./exper3

 @,64
 @,64
lab46:~/src/datastruc$

Analysis

Based on the data collected:

  • Was your hypothesis correct? Yes it was in a way
  • Was your hypothesis not applicable? It is applicable
  • Is there more going on than you originally thought? Umm yes, there are more steps to do something so simple
  • What shortcomings might there be in your experiment? I could be going about this all wrong.
  • What shortcomings might there be in your data? It could seem like its working when its not

Conclusions

What can you ascertain based on the experiment performed and data collected? Document your findings here; make a statement as to any discoveries you've made.