A problem is defined as the “difference between the current state of things and a desired future state in an information processing system”
Example
CURRENT STATE:
A score taker for a football game could be using a paper
based information processing system consisting of
Hardware:
A notebook
Pencil
Data management:
Ruled lines forming a table in the notebook,
Columns for scores, fouls, Events etc
Calculations such as cumulative minutes or
penalties in the game (these are calculated mentally by the score taker and
recorded during the progression of the game.)
Inputs :
Goals scored,
Scorer’s name
Team scoring
Fouls
Attacking
player name , victim name
Minute of foul
Outputs (to officials and score board operator):
Scores
Fouls
Minutes
Desired future state:
Input:
Scores along with player’s Number entered
manually
Fouls with attacker and victim names number
manually via keyboard
In our discussion, we consider well defined precise algorithms (in flowcharts or pseudocode) as compared with narrative algorithms.
Some of the reasons why algorithms are beneficial or important to the problem solving process are:
Algorithms serve as a blueprint for other programmers to follow
When problems are complex, an algorithm’s precise structure allows for an accurate development of a solution in parts. This documentation (the algorithm itself) is useful since it is difficult for the problem solver to remember many sub-processes , procedures and inputs/outputs to the problem.
Because algorithms are intended for a computer system and programming language, it allows us to design for that particular programming language’s structure and for efficiency ,given the limitations of system resources.
For example, an algorithm which processes DNA sequence information for matching DNA strands together (see Longest common sub sequence) can be developed strictly for solving the problem without considering system resources. In this case the algorithm still resembles programming language.
Usually in this type of general solution, array sizes are allowed to be very large or of infinite size. If memory becomes a constraint, we can now modify the algorithm to use say, array sizes at a maximum of 1000 to allow for the intended program to run within the limitation of our system resources.
Algorithms are easily testable when using dry runs and trace tables.
Task: Create an algorithm which accepts a decimal integer and outputs it’s binary equivalent.
This algorithm was designed and implemented in Flowgorithm:
See the video below for an explanation of how the algorithm works:
Decimal to binary algorithm explained
The code in C is shown below:
Copy and paste from here:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>//library needed for string operations
int main()
{
//declare and identify integers
int number, remainder;
//declare, identify and initialize all strings
char result[20]="";
char remainderString[20]="";
//initialize all other variables
number=-1;
remainder=-1;
//get input
printf("Enter a number in decimal\n");
scanf("%d", &number);
printf("\n");
while (number!=0)
{
remainder=number%2;
/* #Implementation_Result
Here we implement the following:
result=remainder + result
*/
//first convert the remainder to a string,
//and store the converted data in "remainderString"
itoa(remainder,remainderString,10);
//add "remainderString" to "result" in that order.
//the result of the concatenation is stored in "remainderString"
strcat(remainderString,result);
//now copy our data so far back to "result"
strcpy(result,remainderString);
/*End #Implementation_Result*/
number=number/2;
}
printf("The binary Result is %s \n",result);
return 0;
}
This post contains a gif
image that is
approximately
9 MB in size.
Introduction…
You’re going to wish that your teachers started excel with a pivot table instead of teaching you formulas and filters, some of which can be complex to understand and difficult to put into practice. I guess teachers know that our absolute addressing labclass would be interruptedwith , “You should’ve just used a pivot table!”
What are they and what do they do?
Pivot tables are new tables that are created from an existing table that contain custom summary features for your original table’s data.
For example, consider the following data:
Employee #
Name
Region
Sales Commission For January
# Items Sold
1
Roly Basima
Americas
1850
1
2
Louna Reba
Africa
2830
7
3
Cole Khayriyya
Caribbean
1050
5
4
Khalida Fuad
Caribbean
2280
7
5
Perlie Shanelle
Asia
1510
3
6
Briscoe Benjamin
Asia
1600
1
7
Misha Street
Americas
4600
8
8
Janice Kemplin
Caribbean
1830
2
9
Aracelis Oyler
Africa
2930
4
10
Alvina Coppola
Africa
1770
7
Figure 1 – Raw data (note that all data was randomly generated.)
You could quickly arrive at a summary view:
Pivot table showing a summary of our data.
This takes about 20 seconds and requires no knowledge of formulas.
The proof is shown in the gif below:
Inserting a Pivot Table in less than 20 seconds.
Creating a pivot table from our data
Copy and paste the data from the table above (Figure 1) into a new excel workbook. The result is shown below:
2. Select all the data that will be used to create your pivot table:
3. Click on the insert tab on the ribbon, and choose Recommended Pivot Tables :
4. Choose a suggested pivot table that you’d like to insert. In this example, we chose the third one. Click “Ok” to insert the table.
5. After Clicking on “Ok” (from step 4), Excel inserts your pivot table on a new sheet. See the result below:
Resulting pivot table
Making sense of your pivot table by manipulating it’s rows, columns and values.
A demonstration of how to manipulate the pivot table in the video below:
Using a pivot table effectively.
Download the finished tutorial from the video here:
A pivot table can help you to make strategic decisions based on your operational data. In our example above, we look at some sale information for the month of January (Operational Data) and create a summary (Strategic Data) to make strategic decisions.
Strategic decisions are made by the leaders of your organization (by you if you’re the leader) and affects how you approach your next set of goals.
From our example, we see that the largest commissions are paid to our sales people in the African continent who also sold the most items in January. Using that information, we may want to communicate with our sales force in Africa to determine the causes and try to apply their methods fro success in other regions.
Our assumption becomes, “Our African Sales force seems to be motivated and practice good methods in selling our products. We must investigate if this is true by comparing their methods to other regions.”
From the assumption above, we can now make our first strategic decision:
Monitor sales in Africa to see if the trend continues
If we find our assumption to be true we can now make the following strategic decisions and plan:
2. Learn the best practices from our African Sales Force
3. Start a training program for our entire company scheduled to run in the month of July .
In class exercise
Describe any other scenario that can result after analyzing the pivot table from our example.
A search engine is website application that allows users to search for information on the world wide web.
Search engines are mainly accessed by their website address. When a user visits a search engine’s website address, they can input their search criteria (also known as a search query) so that the search engine may produce a list of website pages which contain information related to the search criteria.
e.g, a user may visit http://www.google.com and proceed to input the search criteria funny videos :
user enters the search query “funny videos”
Now they can click on the search button –
Click on the search button to perform the search.
And now you can view and visit web pages from various websites which contain related results:
Be sure to read the comments at the start of each function to get an idea of what needs to be implemented. I’ll be happy to answer any questions that you have in class.
In this lesson, we create a variable called score and update it when a collision occurs. The code occurs in our “Play game” broadcast while moving the ship.
We add the following code:
So that the code becomes:
We add a variable called Still playing to keep track of our current game state:
And the score is only reset during initialization when “StillPlaying” is false.
In the case that the ship is missed after movement was completed,, we simply set “StillPlaying” to false and our score is reset during initialization:
That’s it for our main logic!
Here’s the full code for the spaceship:
Here’s the code for the planet:
A full implementation with all the bells and whistles can be found here: