Thursday, November 29, 2007

Flowchart diagrams


(a) 4 = u
13= n
3 = i
8 = v
2 = a
10= c

(b) h = 1

Tuesday, November 27, 2007

Trees

1. Explain what is ment by a data structure?
A data structure is an abstract set of data, organised in an efficient way so that the data
contained in it can be manipulated to process or extract information.

2. A linear list may be inplimented by the use of pointers, what is a linear list and how
do pointers help to impliment it?
an ordered set of elements
The pointers tell the computer which piece of data to take mext or to which location
to add the mext piece of data.

3. What is a tree structure? why are tree structures important in computer science?
A tree structure is a hierarchial data structure. They allow searching to be completed faster,
data can be organised aphabetically and will allow the computer to run smother.

4.

5. What is the main difference between a tree and a binary tree?
the main difference is the fact that a tree can have several child nodes whereas a binary tree
can only have 2 child nodes.

6. (a) What is an ordered binary tree?
this is a tree that is put into a specific order in that information can be systematically
recieved or added.
(b) Why are ordered binary trees important?
They are important because infomation can easily be stored and recieved in a specific order
for example

7. Explain how a binary tree may be used to store data in alphabetical order.
A binary tree may be used easily to store data in alphabetical order. This is done by comparison
in that one piece od data is compared to the last. eg. if ur first letter starts with a letters
lower than the root, then it moves to the left of it and if it is grater than the root then it moves
to the right.


8.What is ment by the terms FIFO and LIFO
First In First Out.
Last In First Out.

9 (a) What is an alternative name for an LIFO data structure?
(b) What is an alternative name for an FIFO data structure?
An alternative name for an LIFO data structure is a stack
An alternative name for an FIFO data structure is a Que

10. Pointers play an important role when implementing queues and stacks. Explain the role of these
pointers when implementing each of these data structures.
In FIFO systems, pointers are used to indicate the start, or the head, of the que, and are also used
to indicate the end, or the footer, of the que. Queues are simple to use, but they must also be implemented
to work with data changes, so circular queues must be used. This simply means that the pointer must
move with the changes.
A LIFO works in the same way only that the pointer is chaged to the top of the stack so that the lsat one
in is always the first one out.

Wednesday, November 7, 2007

Self-Test Questions

Most low-level programming is carried out using assembly language. What typical scenario might mean that a program has to be written in the machine code?

When you are writing a program for a specific coomputer or a specific group of computers that are of the same make. An example could be for a super computer where the computer will be programed to do a unique job and therefor will be one of a kind. Also as it is coded in machine code, the program will run alot quicker as it does not need to be decoded.

Why do assembly language instructions written for one type of machine not run in another?

Because the instructions will be written for the specific processor installed which may not be the same in any other computer. The registers will be named differnetly and will therefor not run properly

What is the purpose of the following part of a typical assembly language instruction?:
  • Label - To name the instruction involved

  • Operation code - To carry out the job required

  • Operands - To define the registers used

  • Comments - To let a reader know what is going on.


  • Why are different modes of addressing encountered when programming in assembly language? Explain what is meant by immediate, direct, indirect and indexed addressing.
    So that you can load different registers into the ALU for example and do different things with them.
    Immediate Addressing where the data appears immediatly after the operation code
    Direct Addressing where the address is referring to a specific location
    Indirect Addressing The use on a number inside the register as a memory location.
    Indexed Addressing where the number in one address is used in combination with an other address to get the memory location.


    An assembly language instruction set may be broken down into subsets like logical and arithmetical and control. Show how 2 simple one-byte integer binary numbers may be added together.
    op codeoperands
    addal, bx


    Explain how a mask may be used to prevent alteration of top(most significant) three bits and the bottom (least significant) two bits but set the rest of the bits in the register to 1

    Not sure how to do this question. Ideas are that you must use the AND and OR op codes but i don't know how.

    Tuesday, November 6, 2007

    Assembly Language

    Assembly language is a Second-Generation low level language made up form mnemonics which can be used instead of machine code.
    The formate for this language generally consist in 4 parts:
    1. Label eg Start:
    2. Op Code eg mov
    3. Operands eg bx.8Oh
    4. Comments eg ;load character count.

    Addressing Modes

    Understanding assemlby language is intimitly ties up with addressing modes. These are related to physical attributes like the registers available and the word length, if, for example you have a single byte register in which to store information for a jump instruction, then you can jump a maximum of 2525 memory locations. Double the length of the location and you could jump 65636 locations or from +32767 to -32768 of you are using a 2's compliment system.

    Register Addressing

    When data is transferred from a source register to a destination register

    Immediate Addressing

    This is when the data appears immediately after the op code, as part of the instruction. Immediate addressing is a very convenient way of putting numbers into registers by specifying the number as one of the operands.

    Direct Addressing

    Direct addressing refers directly to a specific memory location.

    labelop codeoperandscomments

    mov

    ax, [myData]

    ;an example of direct addressing

    Here the contents of the memory location, in the case specified by a label named myData, is copied into the ax register.

    Indirect Addressing.

    Indirect addressing uses a number inside the register(usually an index register to point to the memory loaction of interest where the actual data can be found.

    labelop codeoperandscomments

    mov

    ax, [bx]

    ;an example of indirect addressing

    In this example the brackets around the bx register indicate that the memory location pointed to by the bx register, and not the actual number inside the bx register, will be used. In this case the data in the memory location pointed to by the bx register is copied to the bx register.

    Indexed Addressing

    For indexed addressing a number contained in one register is usually uded in combination with the number in another register to point to the actual memory location where the data can be obtained.

    labelop codeoperandscomments

    mov

    ax, [bx + di]

    ;an example of direct addressing

    In this example the number in the bx register is combined with the number in the di register. As with indirect addressing, the square brackets indicate that this points to the memory location from where the actual data to be put into the cx register can be obtained.

    Base Register and Base Indexed Addressing.

    labelop codeoperandscomments

    ld

    &10[ax]

    ;an example of base register addressing

    movcx,[bx+di];an example of based indexed addressing

    In the first entry an address is held in the base register, in this case the ax register, and an offset (the hex number 10) is added to it. The second entry is useful for handling arrays.

    Example

    By means of an example, show a typical use for a base indexed addresing mode



    Solution

    A classic example of indxed addressing is setting up an array un memory. Consider the two - dimentional array, as shown in thne following examaple.


    This could be mapped onto the memory lacations as shown below.
    A linear sequence of memory locations is mapped onto a 2 dimentional array by using 2 index registers, namly the base-index and destination-index registers
    One register is used fr each dimention of the array. The example shows how th efith element of the array, ie. 22, is accessed by putting the base index register
    to a value of 3, and the destination index register of value of 1. In this case the fith element(not to forget we start at 0) and the number 22 is placed in the
    cx register.




    Actual Address MEMORY Indexed Address
    address + 0 10 Address + 0 + 0
    address + 1 11 Address + 0 + 1
    address + 2 12 Address + 0 + 2
    address + 3 21 Address + 3 + 0
    address + 4 22 Address + 3 + 1
    address + 5 23 Address + 3 + 2
    address + 6 31 Address + 6 + 0
    address + 7 32 Address + 6 + 1
    address + 8 33 Address + 6 + 2


    Typical Assembly Language Instructions.

    Instructions are made of:


  • Logical Operations - "And", "Or" and "Not"

  • Rotate Instructions - Shift left and Right

  • Arithmetical Instructions

  • Bit SET and bit RESET instructions

  • Program control instructions - like "jump"



  • Arithmatical Operations

    Typical of the operations are addition, subtraction, multiplication and divsion. The complexity of each operation depends
    on what is being done. For example, when dividing two numbers there will probably be an integer answer(called thequotient)
    and a remainder. When multiplying two numbers the register for holding the the two numbers to be multiplied will be held in smaller
    than the register needed of the answer.


    Logical Operations

    The logical operations include and, or, not and xor etc. These instructions operate in what is called BITWISE MODE,
    where each bit of a register is matched against the equivalent bit in another register. The and operation is particularly useful for
    MASKING.


    Masking

    When using the logical functions we can create a mask which wither lets a pattern of bits through, or blocks them.Masking is used
    extensively in assembly language to set or reset some of the bits without altering the patterns of other bits.

    Thursday, October 18, 2007

    Some Basic Points About PHP

    Today in class we started to look at some PHP scripting language. initially we will look at the basics but we will soon move on to more complicated stuff.
    1. PHP stands Pre Hypertext Processor
    2. It is a server Scripting language
    3. Its an open source software and
    4. It supports many databases.
    A PHP file may contain Text, HTML tags and scripts and the files are returned to the servers as HTML. PHP Extensions are .php , .php3 and .phtml

    PHP Syntax



    A php file must stat with and end with ?>

    echo " hello world"
    will reproduce Hello world in the browser.

    Variables are declared as
    $var_name = "value"

    Sunday, October 14, 2007

    Thinking About the Program

    Today i started properly to think about how the program of pEters Petrol Pumps is going to work. I used the guidelines to think about how the program is going to work including the interfaces and the acutal program.

    Thursday, October 4, 2007

    Task 24

    A 2 byte floating point numbering system uses 10 places for the mantissa and 6 places for the exponent. Convert the number 1010011010000111 into decimal by filling in the following table to guide you:

    The number is negative. I know this because:
    The first digits are 10

    The mantissa (with the decimal place inserted) is:
    1010011010

    The exponent is:
    000111

    The decimal point in the mantissa must now be moved:
    7 places to the right

    The mantissa becomes:
    1011001.10

    Removing unnecessary zeros gives:
    1011001.1

    Converting from a negative fixed point binary number into denary gives the final answer as:
    89.5

    Task 23

    A 2 byte floating point numbering system uses 10 places for the mantissa and 6 places for the exponent. Convert the number 1010110000000011 into decimal by filling in the following table to guide you:

    The number is negative. i know this because:
    The first digits are 10

    The mantissa (with the decimal place inserted) is:
    1.010110000


    The exponent is:
    000001

    The decimal point in the mantissa must now be moved:
    1 place to the right.

    The mantissa becomes:
    1.010100000

    Removing unnecessary zeros gives:
    1.0101

    Converting from a negative fixed point binary number into denary gives the final answer as:
    -1.00625

    Task 22

    A one byte floating point numbering system uses 5 places for the mantissa and 3 for the exponent. Convert the number -4 into a normalised floating point number by filling in the following table:

    +4 in binary is:
    100

    Packing the front of the binary answer in step 1 with zeros to get the mantissa to the correct size( 5 digits) gives:
    00100

    The 2s compliment for of the answer to step 2 is:
    11011

    Moving the decimal point in the answe to step 3 to the correct place for the normalised form gives:
    11.010

    Removing excess 1s from the front of the number and adding extra zeros at the back of the number to get the normalised form gives us:
    1.0100

    To get the decimal place of the normalised form answer in step 5 back to its pre-normalised position, the decimal point needs to be moved:
    3 places to the right.

    The exponent is therefore:
    011

    Putting the mantissa and the exponent together gives the final answer as:
    10100011

    Task 21

    A one byte floating point numbering system uses 5 places for the matissa and 3 for he exponant. Convert the number -1.5 into a normalised floating number by filling in the following table.

    +1.5 in binary is:
    1.1

    Packing the front of the binary in STEP1 with zeros to get the mantissa to the correct size gives:
    0001.1

    The 2s comliment form of the answer in step 2 is:
    1110.1

    Removing excess 1s from the front of the number and adding extra zeros at the back of the number to get the normailsed form gives us:
    1.0100

    To get the decimal place of the normilaised form answer in STEP 5 back to its pro-normilised position, th edecimal point needs to be moved:
    1 place to the right

    The exponant is therefore:
    001

    Putting the mantissa and the exponant together gives the fimal answer of:
    10100001

    Task 20

    aonebyte floating poimt numbering system ses 5 places of the mantissa and 3 places for the exponant. COnvert the number 10011111 into decimal by filling in the following table.

    This number is negitive because:
    The first digits begin with 10

    The mantissa (with the decimal place inserted) is:
    1.0011

    The mantissa converted into a negitive binary number that is not in 2s compliment is:
    0.1101

    The exponant is:
    111 = -3

    The mantissa now becomes:
    0.0001101

    Removing unneccessary zeros gives:
    0.0001101

    Converting from a negitive fixed point binary number into a denary givs the final answer as:
    -0.1015625

    Task 19

    A one byte floating numbering system esus 5 places for the mantissa and 3 for hte exponant. Calculate the number 10111010 into decimal by filling int he following table.

    This number is negitive. I know this because:
    The first digits are 10

    The mantissa (with the decimal place inserted) is:
    1.0111

    The mantissa converted into a negitive binary number that is not in 2s compliment is:
    0.1001

    The decimal point in the mantissa must no be moved:
    2 places to the right

    The mantissa now becomes:
    010.01

    Removing unneccessary zeros gives:
    10.01

    Converting from a negitive fixed point binary number into denary gives the final answer of:
    2.25.

    Task 18

    a 2 byte floating point numbering system uses 10 places for the mantissa and 6 places for the exponant. Convert the number 2.75 into a normalised floating number using the following table to guide.

    Converting 2.75 into a fixed point number gives me:
    10.11

    The mantissa(with the decimal place inserted) is 10 digits long and nums begin with 0.1. The mantissa is:
    0.101100000

    To get the mantissa back to the original fixed point number, the decimal place must be moved:
    2 places to the right.

    The exponant, which is 6 digits long will be :
    000010

    Putting the mantissa and the exponant together, the final answer is:
    0101100000000010

    Task 17

    A 2 byte floating point numbering system uses 10 places for the mantissa and 6 for the exponant. Convert the number 12.5 into a normalised floating point number using the following table to guide you.

    Converting 12.5 into a fixed point number gives me:
    1100.1

    The mantissa(witht he decimal place inserted) is 10 digits long and must bgin with 0.1. the mantissa is:
    0.110010000

    To get the mantissa back to the original fixed place number, the decimal place:
    Move the decimal place 4 places to the right

    Putting the mantissa and the exponent together, the final answer is :
    0110010000000100

    Tank 16

    A 2 byte floating point numbering system uses 10 places for the mantissa and 6 for the exponant. convert the number 0100000000111101 into decimal by filling in the following table.

    This number is positive because:
    the first digit is a 0

    The mantissa(with the decimal place inserted) is:
    0.100000000

    The exponant is 111101 which os negitive because:
    it begins with a 0

    The denary equivalant is:
    -3

    The decimal place should move:
    3 places to the left

    The mantissa now looks like:
    0.0001000000

    removing the redunadant zeros gives:
    0.0001

    The final denary is :
    0.0625

    Task 15

    A 2 byte floating numbering system uses 10 places for the mantissa and 6 places for the exponant. conver the number 0100000000111101 into decimal by filling in the following table.

    This number is positive, i know this because:
    the first digit is a 0

    The mantissa (with the decimal place inserted) is:
    0.110000110

    The exponant is 0000110 is positive because:
    it begins with a 0

    The denary equivaland is
    +6

    The decimal should move :
    6 places to the right

    The final denary is:
    49.75

    Task 14

    A two byte floating point number system uses 10 places for the mantissa and 6 for the exponent. Convert the number 0111101000000101 into decimal by filling in the following table.

    This number is positive. i know that because:
    the first digit is a 0

    The mantissa(with the decimal place inserted):
    0111101000

    The exponant is 000101 which is positive because:
    the most left digit is a 0

    The denary equivalant of 000101 is
    +3

    The mantissa nw looks like this:
    0111100000

    Removing the redundant zeros the mantissa looks like:
    1111.1

    the final denary answer is:
    30.5

    Wednesday, October 3, 2007

    Task 13

    A one byte floating numbering system uses 5 places for the mantissa and 3 for the exponant. conver the number 1.5 into a normalised floating-point number.

    Converting 1.5 into a fixed oint number gives:
    1.1

    The mantissa(with the decimal place inserted) is 5 digits long and must negin with 0.1. the mantissa is:
    0.1100

    To get the mantissa nack tot he original fixed point number, the decimal place must be moved:
    one place to the right

    The exponant, which is 3 digits long is:
    001

    Putting the mantissa and exponant together, the final answer is:
    01100001

    Task 12

    A one byte floating numbering system uses 5 places for the mantissa and 3 for the exponent. Convert the number 2.25 into a normalised floating nnumber using the following table to guide you.

    Converting 2.25 into a fixed point number gives me:
    10.01

    The mantissa (with the decimal place inserted) is 5 digits long and must begin with 0.1, the mantissa is:
    0.1001

    to get the mantissa back to the original fixed point number, the decimal place must move:
    2 places to the right

    The exponant, which is 3 digits long is:
    010

    Putting the mantissa and the exponant together, the final answer is:
    01001010

    Task 11

    Task 11 - A one-byte floating-point numbering system uses 5 places for the mantissa and 3 for the exponent. Convert the number 01110111 into decimal by filling in the following table.

    The number is positive, i know that because:
    It begins with a zero

    The mantissa is:
    01110

    The exponent is 111 which is negative because:
    Begins with a 1

    The denary equivalent of 111 is:
    -1

    The decimal place in the mantissa must be moved LEFT/RIGHT because:
    Left because -x moves left and +x moves right

    The mantissa now looks like this:
    0.0111

    Removing redundant zeros, the mantissa now looks like this:
    0.0111

    The final denary answer is:
    1/28 OR 0.4375

    Task 10

    A one byte flooating point numbering system uses 5 places for the mantissa and 3 for the exponent.Conver the numbner 01100011 into decimal by filling in th following table

    This is positive. i know this because:
    the first digit is a 0

    The mantissa(with decimal place inserted) is:
    01100

    The exponent is 011 which is positive because
    The first digit is 0

    The decimal place in th emantissa muct be moved LEFT/RIGHT because
    Right because it is positive

    The mantissa now looks like:
    0110.0

    Removing redundant zeros,the mantissa now looks like:
    110

    The final denary answer is:
    6

    Has anyone seen Mr Barr?

    Mr Barr has gone missing
    He left nothin apart for work and this comment

    and i will see you on 00001000 00001010

    feared dead to return as ghost.

    Monday, October 1, 2007

    Task 9

    Convert these denery numbers into binary using the fixed point number system.

    a) 4.75
    b) 10.5
    c) 7.25
    d) 1.125




    a) 00100110
    b) 01010100
    c) 00111010
    d) 00001001

    Task 8

    Convert these fixed point numbers into denary

    a) 01111100
    b) 00000100
    c) 1100001




    a) 15.5
    b) 0.5
    c) 24.125

    Task 7

    Convert the following 7 bit 2s compliment into decimal.
    a)1000100
    b)1011000
    c)0110001


    a)-60
    b)-40
    c)+49

    Task 6

    Convert these 2s compliment valsue into their denary values.
    a) 10001
    b) 11001
    c) 00010
    d) 01000
    e) 11110
    f) 01110


    a) -15
    b) -7
    c) 2
    d) 8
    e) -2
    f) 14

    Task 5

    In using a 5 bit 2s compliment, show how to represent
    a) -12
    b) -14
    c) -1


    a) 10100
    b) 10010
    c) 11111

    Task 4

    In using a 5 bit 2s compliment, show how to represent
    a) -4
    b) -11
    c) 2


    a)11100
    b)10101
    c)00010

    Task 3

    In using a 5 bit 2s compliment, show how to represent
    a) 4
    b) 8
    c) 11




    a) 00100
    b) 01000
    c) 01011

    Task 2

    Suppose you had seven bits to represent 2s compliment numbers.
    a)What is the weighing of each bit?
    b)What is the largest number that can be represented?
    c)What is the smallest number?




    a) -64, 32, 16, 8, 4, 2, 1
    b) 63
    c) -64

    Task 1

    Suppose you had 3 bits to respresent 2s compliment numbers.
    a) What is the weighing of each bit?
    b) What is the largest number that can be represented?
    c) What is the smallest?




    a) -4, 2, 1
    b) 3
    c) -4

    Thursday, September 20, 2007

    We Were asked in clas to create a pay roll applictation that will take in hours worked for 2 weeks work. It also had to claculate the amount of over time pay that should be recieved if a person worked more than 40 hours per week. this rate of overtime was calculated at 1.2 times the usual rate of pay, which can be changed at any time.

    We then ahd to do several extension to which i have managed to get the first 3 done.


    1) Add a button which when clicked outputs a wage slip as a simple text file.
    a. Try using Intellisense to insert the code for creating a text file (Edit >
    Intellisense > Insert Snippet)
    b. Something like: Streamwriter.(“wageslip.txt”,true)
    2) Improve on this by creating a .html file instead of plain text (uses the same
    process)
    3) Have the program create a file using the employee name & current date as
    part of the filename.
    4) *Work out how to read in the employee timesheet data from a text / csv file*
    5) **Implement this as a batch system (process a list of employee timesheet
    records from a csv file.

    If anyone has any idea how to do the last 2, please comment.

    Wednesday, September 19, 2007

    Pay Roll Questions

    1. All the different data types in the projet are:
    • Double
    • Decimal
    • String

    2. Double means it is not an integer and does not have to be a whole number

    Decimal means it is not a whole number and can be used in calculations

    String is a line of charcators with no numerical value attached. they nust be converted to be used in calculations

    3. As double is used because it may not be a whole number

    Decimal is used because it more than likely will not be a whole number

    String is used as it can hold any form of data type easily which can be converted in to numberical values if needed.

    4. It is used to conver numerical charactors of string in to numerical values such as integers

    5.Identifys the form that you are coding in.

    6.If Then Else selection

    7.If an result is true, then a set of code is carried out, if it is false, another differnet code is carried out.

    8. This is an unfinished project as there is

    • No Tax taken off
    • Only one person can be added at a time
    • If you leave out a box, an error occurs

    Tuesday, September 18, 2007

    Visual Basic

    Rite finially got Visual Basic up and running so now i can practice this stuff at home...and eventually get good at it..well thats the idea.

    took 5 litterally 5 hours to install..so il post work 2moro

    homework done in my "hardback book"
    ps. im viewing this web page on my own browser haha..pathetic, i no

    MindMap Chapter 37

    Here is a mind map of the key features in Chapter 37 of out text book on High Level Languages.

    Reasons for using this method are :



    1. Easy Resvision

    2. Clearly set out key points

    3. No long donting paragraphs

    Thursday, September 6, 2007

    Hyperlinks

    In this capter i learned how to creat a hyperlink to ether a new wab site or to a place in the current web site.


    link to a new web page.

    This is simply done using the syntax:

    href="url">Text to be displayed with an anchor of <>



    To make the new site open in a new window you use the synatx:

    target="_blank"



    this is the syntax that i have used in my own website so far:

    Tuesday, September 4, 2007

    HTML Basics


    This is the first of a series of basic HTML notes. Heres some keynotes of what i have learned so far.



    1. A HTML file must befig with and end with

    2. The brackets used are called angle brackets. These are then called tags when thay contain text or commands.

    3. An HTML file muct be saved as .html.




    This is an example of some of the work that i have done recently. I have complied a webite of some of the features that i have learned to date. these include headings, background colour, bold writing, subscript and superscript text. I have also used 2 seperate types of paragraphs.









    In my next post i will detail hyperlinks and tables











    Monday, September 3, 2007

    today in class - 3rd sept

    today we were introduced to w3schools.com...a site to help learn programming languages. we were told to revise beginers HTML and advanced HTML for a test on fri. we were also set a homework to write a letter to Mr Barr about how thankful we will be wen we pass A-level computing with an A grade.

    A2 computing

    MY FIRST BLOGG

    over