Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 9

What is Programming?

• Process of translating the idea of what a computer system should do


into a program
– Requirements gathering
– Analysis
– Design
– Implementation
– Testing, Debugging
How to tell a computer what to do?
A Computer can not understand natural language.
• The CPU of a computer can only executes commands of 0's and 1's.
• That is not suitable for humans
Programming
• Programs are written in a human readable form
Compilers and Interpreters
• Programming languages can be divided into two classes:
– Compiled languages like C, C++
– Interpreted languages like PHP, Bash, Matlab
• Some mixed forms languages also exist like Java, C#, Python
Compiler
• A special program “compiler” translates source files into architecture
and OS specific executable format

1
• The compiler is different for each architecture Operating System
Interpreter
• A special program “Interpreter” directly processes and executes a
source file
• Interpreters are Architecture and Operating System specific
• Interpreter is slower than Compiler
– Translation from language code to
machine code is done at run-time
– The Compiler is OS specific but Architecture independent
• An Interpreter processes and executes the bytecode
• Java is faster than a pure interpreted language

– But more slower than a pure compiled language


DATA
• The collection of facts and figures is called data (general)
• Data is the raw form of information
DATA TYPES
• To understand data we consider its types
• Data can be character, like grade ‘A’ B’, 'C', etc
• Data can be string, like name ‘HAROON’, 'ALI’
• Data can be real number, like temperature 98, -12.0
• Data can be integer number, like Student ID 13, 14
• Data can be Alphanumeric like House number ’10/A’

2
• Data can be in Boolean form like (TRUE / FALSE)
Whether we go there? NO/FALSE or
YES/TRUE
• Data can be in the form of sound, like the sound you play in computer
• Data can be in form of graphics, like a picture in a computer
• Data can be in the form of animated graphics, like movies in
computer
DATA CLASSES
• Group Data Item
– A Data item that can be further divided into sub items

• Name: if it has first name, last name, etc


• Address: House No. Street No. City name, country name, etc
• Simple Data Item
– A Data item that is not further divided into other sub data items
• Blood Group, A-, B+ • Student Id, 23, 94
STRUCTURE
• Ways of representation of something
• Relation between collection of facts or raw material is called structure
DATA STRUCTURE
• A data structure is a way to store and organize data in order to
facilitate access and modifications

3
• Computerkeeps data in organized form for processing
• This organized form of data is called data structure
TYPES OF DATA STRUCTURE
• Linear data structure
– The organization of data in a single row or in a single column is called
linear data structure
• Non linear data structure
• The organization of data in HIRARICHAL form is called non linear data
structure, for example Trees, Graphs, Hash Tables.
DATA STRUCTURE OPERATIONS
• For example an organization contains a membership file in which
each record contains the following data for a given member:
– Name – Address – Telephone number – Age
– Gender
• Announce meeting through a mailing
– Traverse the file to obtain name and address of each member
• Find the names of all members living in a certain area
– Again traverse to obtain the required data
• Obtain address for a given name
– Search the file for the record containing the name
New person joins the organization
– Insert his/her record in the file
• A member dies
– Delete his/her record from the file

4
• A member has moved to new location
– Search for member’s record and perform update operation
• Members with age >= 22
– Traverse the file
Some Terminologies
• Entity:
– an entity is something, that has certain attributes which may be
assigned values
• Field:
– a single elementary unit of information representing an attribute of
an entity
• Record:
– collection of field values of a given entity
• File:
– collections of records of the entities in a given entity set
Many types of operations on data in a particular data structure can be
performed, but four are basic operations
– Traversing – Searching
– Inserting – Deleting
• Other two are
– Sorting – Merging
Traversing
• Accessing a data item exactly once in a data structure
• Traversal makes data item available for further operations

5
Searching
• Finding the location of a data item in memory
• It is the basic of all operations in data structures
• All other operations on data structure are directly dependent upon
searching operation
Inserting
• Adding a new data item to the data structure
• Insertion operation is successful only if there is a space in data
structure
Deleting
• Removing a data item from data structure
• For deletion, first of all search for the item is performed
Algorithm
• Well definedlist of steps for solving a particular problem
• Algorithm is independent of a particular
computer and the software used for development
Algorithm is general for all sorts of computers and programming
languages
Algorithm is used to describe a problem solving method
Algorithm is written independentof computer programs
The codes used for writing algorithm is called pseudo code or
algorithmic notations
Time Space Tradeoff
• Timeand space are the two major and primary variables measuring
the efficiency of a program
6
• Time is the amount of time used to complete a process
• Spaceis the amount in memory consumed by the process during its
processing
Algorithm Notations
• An algorithm is executed statement by statement, one after the other

• Each statement in algorithm has a step with or without step number


– Read name
• Last statement of the algorithm is EXIT,
STOP, or TERMINATE, etc
• Comments are useful hints for the reader of algorithm
Algorithm Notations...
• Variable
– Variable is a data item that receives its value during processing
– A variable is given an appropriate name
• X=45; • MAX=50;
• Assignment
– A variable or a data item is given a value with the help of assignment
(=). COUNTER=1
• Input
– Input is the process that provides data to the algorithm
– The data is termed as input data
– We can use any of the following statements for input
• READ, INPUT, ACCEPT, etc • INPUT Variable1
7
Output
– The process by which algorithm gives out data.
– The data is termed as output data
– We can use any of the following statement for output
• OUTPUT, WRITE , DISPLAY, PRINT, etc • PRINT Name
Insertion
– Selection logic uses a number of conditions which lead to a selection
of one out of several alternative modules
IF condition, then
[module a]
[end if]
IF condition, then
[module a]
Else
[module b]
• [end if]
Iteration
– Iterative logic makes a statement or group of statements to repeat
until a certain condition or for some specified number of times
Repeat whilecondition
[module]
end loop

8
9

You might also like