A1: Define an Algorithm ?
An algorithm is a set of step-by-step instructions to accomplish a task or
solve a problem..
2. List and explain 5 properties of algorithms?
1. Input-Output:- Algorithm takes '0' or more input and produces the required
output.
2. Finiteness:- An algorithm must terminate in a countable number of steps.
3. Definiteness: Each step of an algorithm must be stated clearly.
4. Effectiveness: Each and every step in an algorithm can be converted in to
Programming language statement.
5. Generality: Algorithm is generalized one. It works on all set of inputs and
provides the required output.
3. list the 3 categories of algorithms ?
1.Sequence:-The steps described in an algorithm are performed successively
one by one without skipping any step.
2.Selection:-The sequence type of algorithms are not sufficient to solve the
problems, which involves decision and conditions
3.Iteration:-Iteration type algorithms are used in solving the problems which
involves repetition of statement.
4. Define flowchart?
A flowchart is a diagrammatic representation of the logic for solving a task.
5.. Write an algorithm to find the largest among three different
numbers entered by user?
Step 1: Start
Step 2: Declare variables a,b and c
Step 3: Read variables a,b and c.
Step 4: If a>b
If a>c
Display a is the largest number. Else
Name Abdihakiin Hussien
Display c is the largest number. Else
If bc
Display b is the largest number. Else
Display c is the greatest number.
Step 5: Stop
6. Write an algorithm to find the Simple Interest for given Time and
Rate of Interest?
Step 1: Start
Step 2: Read P,R,S,T.
Step 3: Calculate S=(PTR)/100
Step 4: Print S
Step 5: Stop
7: Write an Algorithm to check if a number is even or odd:?
Steps:
1.Start
2. Declare a variable num.
3. Read the value of num.
4. If num%2 8, then: • Display “Even”.
4. Else
6. Display “Odd”.
7. Stop.
8. Define the following terms?
Time Complexity:-The amount of time required for an algorithm to complete
its execution.
Space Complexity :-The amount of space occupied by an algorithm.
9:- definition the terms primitive data structures and non-primitive
Data structures?
Name Abdihakiin Hussien
Primitive Data structures are directly supported by the language ie; any
operation is directly performed in these data items.
Non-primitive data structures are not defined by the programming language,
but are instead created by the programmer.
10.List and explain 6 Following operations can be performed on the
data structures?
1.Traversing- It is used to access each data item exactly once so that it can
be processed.
2. Searching it is used to find out the location of the data item if it exists in
the given collection of data items.
3.Inserting- It is used to add a new data item in the given collection of data
items. 4. 4.Deleting-It is used to delete an existing data item from the given
collection of data items.
5.Sorting- It is used to arrange the data items in some order i.e. in ascending
or descending order in case of numerical data and in dictionary order in case
of alphanumeric data.
6.Merging-It is used to combine the data items of two sorted files into single
file in the sorted form.
Name Abdihakiin Hussien