1.
Number System
2. Data Representation
3. Integer Representation
1
2. Data Representation
A common form of data are letters of the
alphabet (A to Z), numerals (0 to 9), some
symbols (@, &, *) and certain control
character (Ctrl,Shift).
This types of data is convenient for human
being but all of the data in digital computer
represented in binary form.
Some coding systems are used to represent
these data into the binary form. (Characters
are represented by a sequence of bits.)
2
Data Representation (cont.)
• The famous coding system been used for data
representation are:
– ASCII (American Standard Code for
Information Interchange)
– EBCDIC (Extended Binary Coded Decimal
Interchange Code )
– BCD (Binary Coded Decimal)
3
ASCII
• Is a standard character set used to represent
characters in a computer
• ASCII is used in almost all present-day personal
computers.
• Each alphabetic, numeric, or special character is
represented with a 7-bit binary number (a string of
seven 0s or 1s).
• .
• Example: char A=65 in decimal,41 in hex,
0100 0001 in binary.
4
EBCDIC
• Extended Binary Coded Decimal
Interchange Code (EBCDIC) is an 8-bit
character encoding (code page) used on
IBM mainframe operating systems
ARRAYS
• An array is defined as a finite ordered set
of homogeneous elements.
• Finite means that there is a specific
number of elements in the array.
• An array is a set of variables of the same
type, such as integer or real.
• The number may be large or small but it is
fixed and it must be at least one.
• Thus an array is a static data structure.
• Ordered implies that there is a first,
second, third etc element of the array.
Defining an array
• Array name
• Array size
• Data type
• Magnitude/dimensions
LINKED LIST
A linked list is a dynamic data structure consisting of a number of nodes.
An external pointer points to the first node, and each node holds data plus a
pointer to the next node in the sequence.
Defining a linked list:-
•External start pointer
•Nodes having Data and address part
•Pointer to the next node
•Null pointer at the end of the last node
There are two types of linked lists
Single linked list with only one pointer to the next node
Double linked list with a pointer to the next node and another pointer to the previous node
Adding a Node
Suppose we wanted to add the node 'Pembroke' to the above linked list.
The algorithm is ....
1. Add the New Node is created and location to be inserted is searched
2. Find Previous Node by following links from Pointer until the last node whose
Town is less than New Node.
3. Change the New Node[Pointer] to Previous Node[pointer] and change
Previous Node[pointer] to the address of the New Node..
Adding A node
Deleting a node
Suppose we now want to delete the node 'Swansea'
The algorithm is as follows...
1. Follow the pointers until the Deleted Node (Swansea) is found, and make a
note of the Previous Node (Reading).
2. Change the Previous Node's (Reading's) pointer to the Deleted Node's
(Swansea's) pointer(5).
3. Change the Deleted Node's (Swansea's) pointer (5) to the NFP (7) and the
NFP[pointer] (7) to the Deleted Node's address(2).