Q2: Data Structures
1. In our computers, we use and talk about files all the time. But what is a file? Write a technical definition of a computer file.
Most data storage types are used for temporary storage in primary memory so, when the computer is turned off or the program is closed, the data is consequently lost. A computer file is therefore needed to store data permanently on disk, even after the program has ended. A computer file is a collection of information or instructions encoded in such a way, that it allows it to be processed and properly interpreted by a computer. Almost all information stored in a computer must be in a file. Files are basically used when data needs to be stored for later use, or when there is not enough primary memory (RAM) to hold all the data needed for the program. Computer files may be stored on a variety of media, such as CD-ROMs, floppy disks, computer disk/c, microdisks, or magnetic tapes.
Files on a computer can be created (with a given “filename”), moved, read, modified/updated, grown, shrunk and deleted. For instance, in Microsoft Word, the user is allowed to move, rename, or delete their files directly by using a file manager program such as Windows Explorer.
The information stored in a “file” may be in the form of data files (numeric files, representational files and text files), or computer software files (programs, games, fonts), or a combination of both.
Types of Computer Files
Some examples of “Computer Files” include:
· Numeric Data~ Files that are mostly numbers or represented by numbers (e.g., student test scores, football team statistics, etc.).
· Computer program~ A series of instructions directing the computer to perform operations (in order to complete a task), whilst at the same time, identifying the information and mechanisms required.
· Representational~ Files that have pictorial or graphic data, can be manipulated in conjunction with other types of files that can be used to interpret and give meaning to the information e.g. a graph relating to or illustrating a point made in an article written in a document.
· Document~ Files that are mainly alphabetic information (words or sentences) converted into a code that can be processed, sorted and manipulated by machine.
· Interactive multimedia~ supports navigation, through the stored data, and manipulation of many kinds of media (audio, video, etc.)
2. What is an array? Find out how to access data that is stored in an array.
An “array” is known as one of the simplest forms of a data structure (complex data storage types that can hold more than one item of data at a time). It is used to hold a number of related data items of the same data type: for example, the names of students in a class, whereas a record (another type of data structure), for example, can be used to hold related data of more than one type e.g. details about a person, such as name, address and phone number (can only hold one set of details, that is, only one person’s details). In order to hold a number of people’s details, an array of records needs to be created, or alternatively, the data can be stored in a file.
Each array can hold only one specific data type. Individual data items or values contained in the array are called elements. Data stored in arrays, can be accessed by the array name and a storage location in the array is called an index/index value/key, which are unique identifying numbers, numbered in a row 0, 1, 2, 3, etc.
Language Levels
Language Levels. I have no idea what it is about soooo… I’ll just go with the flow!
1. Give definitions of machine specific language and assembly language.
Definitions, ey? Would dictionary.com help again? =\ No but Wiki will! ^O^ ‘kay. Let’s get this show on the road. A machine language is a system of instructions and data directly executed by a computer’s central processing unit. Machine code is the lowest level of abstraction for representing a computer program.

Huh?
Okay let me explain some of that. Basically when you say, want to read this post, you’d have to see the post, right? So the computer automatically does its hocus pocus when you click “I want to view Vivian’s fantastic post!”… if there is such a link. MOVING ON…
Assembly languages. They implement a symbolic representation of the numeric machine codes and other constants needed to program a particular CPU architecture. I’m not even gonna bother trying to decipher that, sorry. >___>” It’s wayy too technical for me. You too, Pikachu?

Pikaaaaaaaaaa!
Okay.
2. Machine specific and assembly languages are called lower level languages, whilst languages like Visual Basic and C are called higher level languages. What does this mean? What is the difference?
A lower level language is a language that provides little or no “abstraction” from a computer’s microprocessor (CPU). Basically, it’s more simple than higher level programming languages. This doesn’t mean it’s crapper or anything! Think of… Pikachu & Raichu… when Ash was trying to face Gym Leader Lt. Surge! Pikachu was able to defeat Raichu even though it was a less “evolved” (ergo simpler) version of Raichu! Incredible, ey? Of course, my Mewtwo can smash Pikachu’s buttocks off in one hit, but that’s a different story.

Find out what a compiler is. Have you ever used a compiler before? Where?
Compiler. A compiler is “A program that translates another program written in a high-level language into machine language so that it can be executed.” – Courtesy of www.dictionary.com. Uhh, would it be like using an Internet browser to view webpages that are encoded with code…? Sure! ^O^
That concludes my lecture on “Language Levels”. Bye! * wipes sweat *
Data Types
1. Give a definition and an example of each of the following data types: characters, integers, floating point numbers, strings and Booleans. Characters- Integers- Floating point numbers- Strings- Booleans- 2. Find out as many different computer data types (note: not file types!) as you can, and give descriptions and examples of these too. Long-
Information that relates to symbols. This also includes letters and numbers.
Any whole number is considered an integer. The integer can be a negative or positive number (-2 and 5). Fractions and decimal numbers (1/2 and 0.5) are not integers.
A string of digits that represents a real number. It is equivilant to the scientific notation but on the computer. The floating point numbers are measured in megaflops and gigaflops. Examples of floating point numbers are 0.0000895236 and 343248.0343. No matter how big or small the number is it is still considered a floating point number if it has alot of digits in the number.
A series of symbols, characters and words that came from predetermined set. If Σ = 73 then 737373737373 is a string over Σ.
A datatype that has true and falso as the only two values. Ada is an example of this:
…
if p then
…
end if;
A computer data type that can store more than 32768 bits.
Linguistic Diversity
- List as many different programming languages that you can find out about. Give descriptions of 3 of them and how they are unique.
Ada, C++, C, C-script, C-, Euclid, Euler, Fortran, Foxpro, FOIL, Forumla language, HAL/S, J, J++, J#, Java, Javascript, Pascal, Ppc++, Python, R++, Visual Basic and Z++
Python- Python is a high-level programming language first released by Guidio van Rossum in 1991 Python is designed around a philosophy which emphasizes readability and the importance of programmer effort over computer effort.
C++- is a general-purpose programming language with high-level and low-level capabilities. It is a statically typed, free-form, multi-paradigm, usually compiled language supporting procedural programming, data abstraction, object-oriented programming, and generic programming.
Ada- is a structured, statically typed, imperative, and object-oriented high-level computer programming language. It was originally designed by a team led by Jean Ichbiah of CII Honeywell Bull under contract to the United States Department of Defense during 1977–1983 to supersede the hundreds of programming languages then used by the US Department of Defence (DoD)..
Procedural Programming
Procedural programming means imperative programming (specifying the steps the program must take to reach the desired state)
Benefits of using procedural programming are:
- The ability to re-use the same code at different places in the program without copying it.
- An easier way to keep track of program flow than a collection of “GOTO” or “JUMP” statements (which can turn a large, complicated program into spaghetti code)
- The ability to be strongly modular or structured.
Object-Oriented Programming
Object-Oriented Programming can be seen as a bunch of objects cooperating with each other. The objects are like their own little machine, receiving messages , processing data, and sending messages to other objects.
Q1: GUIs
1. What is a GUI? What alternatives are there to GUIs?
The acronym “GUI” stands for “Graphical User Interface”, which is a type of graphics-based user interface, such as Windows or Macintosh, that represent files and operations visually in conjunction with text (in order to fully represent the information and actions available to a user) , rather than just using text alone. GUIs incorporate windows, icons, menus and pointers (WIMP) to allow users to interact with a computer or a computer-controlled device in order to perform various tasks such as opening files or creating applications. This is done by enabling the user to activate a certain command or program, or see lists of files, with the use of either a mouse or a keyboard (used to select from ‘a dashboard’ of options presented on the display screen).
The most common alternative user interface to the GUI is the Command Line Interface (CLI). This type of user interface is considerabley different to a GUI in that, instead of choosing commands from a menu or selecting an icon (as you do using a GUI, which is both visual and textual), the user alternatively types a series of text commands using a keyboard to the computer in order to carry out the desired task (purely textual).
2. What advantages do GUIs bring?
Advantages of GUIs Compared with other purely Text-Based User Interfaces e.g. Command Line Interfaces
v As GUIs use graphical representation, rather than just textual, it is considerably easier to interpret as well as use for the purpose of carrying out tasks on the computer.
v Well-designed GUIs can save users the hassle of trying to learn and memorise complex command languages, which they would have to do in order to effectively operate CLIs.
v Users don’t have to type everything at a command prompt, less tedious and time-consuming. v GUIs are easier, as well as take less time, for users to learn.
v GUIs are easier to navigate, and are therefore more efficient for the user.
v GUIs make it easier to move data from one application to another, for example to copy a graph created by a spreadsheet program into a document created by a word processor.
3. Name and explain some of the objects available to programmers in a GUI environment. (Hint: think back to the VB worksheets you completed earlier this term.)
v Check box~ allows an option to be either selected or unselected (usually indicated by a tick or an “X” mark). In a group of check boxes, more than one option can be chosen at the same time.
v Option (radio) button~ simliar to a check box, except that it only allows a single item from the list to be selected at any given time (usually in the form of a graphic circle).
v Combo box~ lists options available for selection, as well allowing data to be entered.
v List box~ in the form of a drop-down menu, displays the only options that can be chosen.
v Command button~ causes an action to occur when it is clicked such as “OK” or “Cancel”.
v Text box~ enables data to be entered, whether in the form of text or numbers.
v Menu~ provides a list of options or commands for selection.
jennifer wong. x]
Algorithms
Ahhh. Algorithms. One may ask me how I might make Algorithms interesting. Even I’m having trouble making this one seem less boring… nevermind. >__< What do you think Pikachu?

“PIKAAAAAAAAACHUUUUU!”
Uhh, care to interpret, Meowth?

“He doesn’t want to have anything to do with algorithms…!”
Oh mannn! My mascot has abandoned me this time. I’ll cry with you too Meowth. * sob *OKAY enough with that. Let’s get the show on the road!1. Write a simple, one-sentence definition of an algorithm (in the general sense, not the computer or mathematical sense). Give an example from your real life where you use an ‘algorithm’ on a regular basis.
Gosh, okay. * runs to dictionary.com *
“A set of rules for solving a problem in a finite number of steps, like finding the greatest common divisor. “ – Courtesy of www.dictionary.com.
Hmm what does that mean? Basically when you have a problem to face, like tying shoelaces (which I have the misfortune of doing everyday), an algorithm comes to the rescue by telling you hthe best way to do it! Sometimes the algorithm is already implanted into your brain, like tying shoelaces. I always remember to tie a knot, take the left shoelace and make a loop, swing the right lace over the top and…

AAAAAAAHHHHHHH!
Oh, you don’t want to know how I tie shoelaces? Okayy.. =(
Yeah. Algorithms for tying shoelaces.
2. What is pseudocode? Why is it useful to programmers?
Haha dictonary.com again. ![]()
“A program code unrelated to the hardware of a particular computer and requiring conversion to the code used by the computer before the program can be used.” – Courtesy of www.dictionary.com
Personally I didn’t understand a word of that, so neither would you. (I’m not suggesting I’m more intelligent than you or anything. Who are you anyway? >___>” So I’ll do a little more research. * puts up Be Right Back sign *

Okay I’ve got some research now! Sort of. It basically is a code that ‘copies’ other codes, or rewords, for instance. An example… for example… look at this code.
<?php if (is_valid($cc_number)) { execute_transaction($cc_number, $order); } else { show_failure(); } ?>
This is hooly-dooly code. Very weird, you might not even understand it! (I hope I’m not insulting your intelligence, because I certainly am insulting mine. Wait I’m making no sense at all, so scrap that.) Well actually it’s PHP coding, stuff that can be used to make more complicated forms of webpages… like forums and polls etc. BUT WE’RE NOT LEARNING ABOUT PHP! This is what it would look like if it was “pseudocoded”!
if credit card number is valid execute transaction based on number and order else show a generic failure message end if
Simpler much? ^O^ Thought so. Pikachu would understand it… if he was here.
3. Name and briefly describe a pictorial or graphical way of representing an algorithm. (Hint: think back to what we have done in IST lessons over the past few weeks.)
Ahahaha you gave it away Mr. Woo! Wait.. what was it called again? * feels dumb *

Shut up, stupid kitty!
Oh yeah! Flow chart! XD It’s sort of pretty… with it’s cute squares and diamonds and stuff… not actually. And can be used for lots of algorithms… like tying shoelaces. Okay I won’t go there again, sorry Vegeta. Very simplified, nice and easy to understand.
Errors
What is debugging? For each of the following, define the term and give an example.
The process of finding and destroying the bugs in a electronic device to that has been causing the problems.
The program has found an error and does not know how to fix it. An example of syntax error is when brackets are entered into a calculator but the brackets did not end. The calculator does not know what to do first so syntax error appears on the screen to notify the person that the numbers that they entered was wrong.
The program has a bug that causes it to misunderstands the instructions that it was given or the formula was incorrect. Therefore the answer that it gives is incorrect.
An example of a logical error:
#include <stdio.h>
int money, money_in_store;
main()
{
do
{
printf("Enter amount of money (0 to exit): ");
scanf("%d", &money);
if (money_in_store == 0) // Should be 'if (money == 0)'
{
printf("%d money on exit\n", money_in_store);
exit(0);
}
money_in_store += money;
} while(1);
return(0);
}
‘money_in_store’ should have been ‘money’ in the formula above.
While the program is running an error is detected. Causes for a runtime error include computer viruses, running other programs and other computer issues.
Question 4 Documentation
WHAT IS INTRINSIC DOCUMENTATION??
Intrinsic documentation uses names for procedures, functions, variables and other structures in a program that makes it easier to understand the program. It is also a form of internal documentation existing in normal code making the code readable. It uses logical variable names, indenting and capitalization of reserved words.
IN PROGRAMMING, WHAT ARE COMMENTS? WHAT IS THEIR PURPOSE?
A comment is a programming language used to embed information in the source code. Its purpose is to document the program and remind programmers of what the code does. Comments do not affect the source code of the program.
PROS + CONS FOR DOCUMENTATION
PROS
- It makes it easier to understand and use the program when other programmers modify the code
- With the use of documentation it makes it easier and faster to identify problems
CONS
- Time consuming
- Documentation may inflict problems with code if put in incorrectly
Control Structures
December 7, 2007
Filed under Uncategorized
Tags: Control, control structures, structures
What is the purpose of a control structure?
The purpose of a control structure is to control the order of individual statement, instructions and functions that is executes and/or analyzed in an imperative or functional program.
For each of the following, describe what exactly happens and give an example from real life.
1. Sequencing control structure
A sequencing control structure basically reads the command from top to bottom without jumping, looping or going into other cases and/or breaks.
2. Selection control structure
The selection control structure allows the program to check for several possible constant values for an expression.
switch (expression) {
case constant1:group of statements 1; break;
case constant2: group of statements 2; break;
. . . default: default group of statements }
It works in the following way: switch evaluates expression and checks if it is equivalent to constant1, if it is, it executes group of statements1 until it finds the break statement. When it finds this break statement the program jumps to the end of the switch selective structure.
If expression was not equal to constant1 it will be checked against constant2. If it is equal to this, it will execute group of statements 2 until a break keyword is found, and then will jump to the end of the switch selective structure.
Finally, if the value of expression did not match any of the previously specified constants (you can include as many case labels as values you want to check), the program will execute the statements included after the default: label, if it exists (since it is optional).
This is the Selection control structure (switch) compared against the “If…else” structure.
| switch example | if-else equivalent |
|---|---|
switch (x) { case 1: cout << "x is 1"; break;
case 2: cout << "x is 2"; break; default: cout << "value of x unknown"; } |
if (x == 1) { cout << "x is 1"; }
else if (x == 2) { cout << "x is 2"; }
else { cout << "value of x unknown"; }
|
3. Repetition control structure
In a repetition control structure, the structure will repeat a certain command/function/statement/instruction at a given interval given that the statement/expression of the structure remains true. This causes many problems when used in programming and modeling because the program just copies the code from a previous time and executes it. The longer the loop is, the less quality the end product is.
In homology modeling, the modeling of protein structures,
the loop modeling method produces models that are generally much less accurate than the rest of the model, particularly if the loop is long.
Question 3 Data Operators
For each of the following, describe its function, give an example of one and explain how it might be used in a program.
- Relational operators
- Logical operators
- Arithmetic operators
Relational Operators
In programming, relational operators allow two values or variables to be compared using either > or = . Depending on whether the relationship between the two operands holds or not the operators return a true of false. Relational operators are usually written in infix notation.
|
Visual Basic |
Relational Operator |
|
= |
equal to |
| <> |
not equal |
| < |
less than |
|
<= |
less than or equal to |
| > |
greater than |
|
>= |
greater than or equal to |
Example: Visual Basic
Logical Operators
Logical Operators allow two or more Boolean value or variables to be compared using OR, AND or NOT.
OR
This is an expression which indicates either operand is true.
AND
This is an expression which indicates that both operands are true.
NOT
This is an expression which indicates the opposite value of a Boolean variable is returned.
Example: Truth Tables, Venn Diagrams
Arithmetic Operators
|
Operation |
Operator |
|
Multiply |
* |
|
Divide |
/ |
|
Addition |
+ |
|
Subtraction |
- |
|
Increment |
++ |
|
Decrement |
– |
|
Modulus |
% |
Arithmetic operators allow mathematical calculations to be added to a program. Calculations are processed left to right, with multiplication and division done before addition and subtraction.
Example: JavaScript