In class we discussed the concept of an Algorithm. The definition given was as follows:
A well-ordered collection of unambiguous and effictively computatable operations that, when executed, produces a result and halts in a finite amout of time
Given this definition your assignment is to write an algorithm to convert a number, given in base-10 representation, into a number in Octal (base-8) representation and into a number in Hexidecimal (base-16) representation. This problem can also be described as a "conversion" problem.
i.e. The problem is how to "convert" input given in one representation into output in another representation
Your algorithm must not be written in a computer programming language. Your goal is to develop and write out a solution to this conversion problem in an unambiguous yet understandable way. Focus on the definition of an algorithm given above.
Some things to consider when developing your algorithm
All information in a computer is stored as bits (1s and 0s). You can view the contents of a file on the loki server in Octal or Hex using the following linux utilities:
You might consider creating some files using an editor like emacs or vi and then looking at the files using either of the utilities listed above. For example I have a file in my home directory called "justforfun" that contains the following text:
This is a file containing a bunch of text just so I can view it using an octal or hex utility. When I do this I am reminded that all data no matter what it looks like to me is just a bunch of 1s and 0s to a computer.
00
01
02
03
04
05
06
07
08
09
10
When I use the "od" utility to view this file the output looks like this (often called a dump) :
0000000 064124 071551 064440 020163 020141 064546 062554 061440
0000020 067157 060564 067151 067151 020147 020141 072542 061556
0000040 020150 063157 072040 074145 020164 072552 072163 071440
0000060 020150 063157 072040 074145 020164 072552 072163 071440
0000100 071565 067151 020147 067141 067440 072143 066141 067440
0000120 020162 062550 020170 072165 066151 072151 027171 020040
0000140 064127 067145 044440 062040 020157 064164 071551 044440
0000160 060440 020155 062562 064555 062156 062145 072040 060550
0000200 020164 066141 005154 060544 060564 067040 020157 060555
0000220 072164 071145 073440 060550 020164 072151 066040 067557
0000240 071553 066040 065551 020145 067564 066440 020145 071551
0000260 065040 071565 020164 020141 072542 061556 020150 063157
0000200 030440 020163 067141 020144 071460 072040 020157 020141
0000320 067543 070155 072165 071145 005056 030060 030012 005061
0000340 031060 030012 005063 032060 030012 005065 033060 030012
0000360 005067 034060 030012 005071 030061 005012
0000374
The ouput listed above is sometimes refered to as a file "dump".
Feel free to email me your answers to each of the above questions using this link if you want some feedback....Have fun!!