Saturday, 9 October 2021

UNIT 01: PROBLEM SOLVING AND ALGORTHM DESIGNING - Text Book Exercise And SLOs Question Answers - Computer Science For Class X

GO TO INDEX

Computer Science For Class X
Unit 01: Problem Solving And Algorithm Designing
Text Book Exercise And SLOs Question Answers


B. RESPOND THE FOLLOWING:

1. Describe the steps involved in problem solving. OR. Find feasible solutions of a problem
Ans: PROBLEM SOLVING OR PROBLEM SOLVING PROCESS:
Problem solving is the process of finding solution of difficult or complex issues. It is a process by which any problem is solved.

STEPS INVOLVED IN PROBLEM SOLVING OR PROBLEM SOLVING PROCESS:
Problem solving is a step-by-step process. There are four basic step involved in finding a solution for a problem as given below:
  1. Define the problem.
  2. Generate alternative solutions.
  3. Evaluate and select an alternative solution.
  4. Implement and follow up on the solution.

1. Define the problem:
  • In problem solving process, the first step is defining or identifying the problem. It is the most difficult and the most important of all the steps.
  • It involves diagnosing the situation so that the focus should be on the real problem and not on its symptoms.
  • During this first stage of problem solving, it is important to describe the problem. A well-described problem will also help others to understand the problem.

2. Generate alternative solutions:
  • For any problem, there might have more than one alternative solutions.
  • So, it is best to develop a list of all feasible (possible) solutions that can be assessed and decide which one will be the best for the particular problem and short comes of every opted option.
  • Group thinking and team problem-solving techniques are both useful tools at this stage of problem solving.

3. Evaluate and select an alternative solutions:
  • Many alternative solutions to the problem should be generated before final evaluation.
  • The best solution to a problem is the one that has maximum benefits and lowest possible failure chance or drawbacks.
  • Every alternative therefore requires a thorough analysis and critical evaluation of the situation before passing to an implementation stage.
  • If we just focus on trying to get the results we want, we can miss the chances for learning something new which is required for real improvement in the problem-solving process.

4. Implement and follow up on the solution:
  • The plan for best solution also includes planning on what happens next if something goes wrong with the solution if it does not work out the way it was required.
  • After a strategy has been selected the next important phase is to implement the plan and make sure it will be executed on time without deviation.
  • For this purpose periodic follow up of progress is necessary to access the performance and check for deviation.
  • Sometime due to special circumstances, some modification and adjustments are also implemented in the plan.
  • The problem solver should consider about the possible impacts of that solution. For example, this solution will solve the current problem without creating new ones or this solution is acceptable by everyone involved in this situation or the solution is within the budget and achievable within a given time.


2. What are the advantages of developing algorithms? OR Describe the importance or role of algorithm in problem solving?
Ans: ADVANTAGES OF DEVELOPING ALGORITHMS OR ROLE OF ALGORITHMS IN PROBLEM SOLVING:
  1. The advantage of using an algorithm to solve a problem or make a decision is that it produces the best possible answer every time.
  2. This is useful in solutions where accuracy is required or where similar problem need to be solved more often.
  3. It is a step-wise presentation of a solution to a given problem, which makes it easy to understand.
  4. An algorithm uses a sequential procedure to develop a solution.
  5. In many cases, computer programs can be developed with the help of this process. Then data is entered in that program so that the algorithm can be executed to come up with the required solution.
  6. It is not dependent on any programming language, so it is easy to understand for anyone even without programming knowledge.
  7. Every step in an algorithm has its own logical sequence so it is easy to debug any logical error in program.
  8. By using algorithm, the problem is broken down into smaller pieces or steps hence, it is easier for programmer to convert it into an actual program code.

3. List any three advantages of designing flowcharts. OR Discuss the importance of flowchart designing in problem solving ?
Ans: ADVANTAGES OF DESIGNING FLOWCHART OR
Importance of a Flowchart for Solving a Problem:

Following are some advantages of flowchart for solving problem
  1. Flowcharts help in communicating the logic of a program to all others and make it easy to understand.
  2. It is a useful program document that is needed for various purposes like to know about program quickly or to modify program logic.
  3. The flowcharts act as a guide or blueprint during the coding of program (i.e the system analysis and program development phase).
  4. Main use of a flowchart is to visualize operations and sequence of steps to perform them.
  5. It illustrates the logic to solve a problem, before writing the full computer program.
  6. It shows all steps visually or graphically of a complex problem which is easy to understand in one look and also helps to describe program flow to others.
  7. It also helps programmers when we modify or extend program.
  8. Flowchart explains the concept using simple short diagram and thus save the times.
  9. It is easy to convert the flowchart into any programming language code as it does not use any specific programming language concept
(Note: Write down any three advantages as mention in question)

4. What is the difference between tree and graph data structure?
Ans: DIFFERENCE BETWEEN TREE AND GRAPH DATA STRUCTURE
S.No Tree Data Structure Graph Data Structure
1. Tree data structures are hierarchical, non-linear collections of linked nodes. Graphs are collections of linked nodes in non-linear network models. Like tree data structures, graphs have nodes (that is, the vertices where data is stored) and connections between nodes (that is, edge which carry the relationship between nodes).
2. A good example of hierarchical data is a family tree where each level of depth would represent a hierarchy such as grand parents, parents etc A good example of a network graph is a of roads within a city.
3. The first node of a tree is the root node. Everything else flows hierarchical from this node. Graph data structures do not have root nodes and there are no parent-child relationships.
4. The root node is also called the parent node and all the other nodes connected to it are called child nodes. A graph data structure therefore is a data structure that contains; (i) a finite set of nodes and (ii) a finite set of edges.
5. A tree is thus a collection of linked nodes starting from the or parent where each node is data store with a value and references to it's child nodes. A vertex in a graph can be connected to any number of other vertices using edges. An edge can be bi-directed or un-directed.
6. Leaves are the last nodes without children.  Graphs are more complicated as it can have loops and self-loops.



5. What is the difference between queue and stack data structure?
Ans: DIFFERENCE BETWEEN QUEUE AND STACK DATA STRUCTURE
S.No Queue Data Structure Stack Data Structure
1. A queue is a linear data structure in which elements can be inserted only from one side of the list called rear, and the element can be deleted only from the other side called the front. A stack is a linear data structure in which elements can be inserted and deleted only from one side of list, called the top.
2. The queue data structure follows the FIFO (First In First Out) principle, i.e., the element inserted at first in the list, is the first element to be removed from the list. A stack follows the LIFO (Last In First Out) principle, i.e. the element inserted at the last is the first element to come out.
3. The insertion of an element in a queue is called an Enqueue operation and the deletion of an element is called a Dequeue operation. The insertion of an element into stack is called push operation, and deletion of an element from the stack is called pop operation.
4. In queue we always maintain two pointers, one pointing to the element inserted in the list with the front pointer and the second pointer pointing to the element inserted at the last with the rear pointer. In stack a user can always keep track of the last element press in the list with a pointer called top.



6. What is the need of index in an array?
Ans: Need Of Index In An Array:
An array is the container of elements (values). Elements are stored at memory adjacent locations. Each location of an element in an array has a numerical value called index, which is used to identify the element. Set of indexes in an array are consecutive numbers. Elements in arrays can be accessed by indexing. Thus indexing is an operation that pulls out a selected set of values from an array.


7. With the help of a sketch define: Push, Pop, Overflow and Enqueue, Dequeue.
Ans: DEFINITIONS:
1. PUSH:
The insertion of an element into stack is called push operation. Stack uses LIFO order hence any value can be added but only from top and top from middle or front.

2. POP:
To delete an element from the stack we use pop operation.We can only delete value from top since stack uses LIFO order.

3.OVERFLOW:
When the stack is completely full we can not add any more data values called this stack overflow state.

4. UNDERFLOW:
When the stack is not completely full and we can still add more data values then this is called stack underflow. We can not remove an item in underflow state.

5. ENQUEUE:
The insertion of an element in a queue is called an enqueue operation. Enqueue is always done from rear problem because queue data structure follows FIFO order.

6. DEQUEUE:
When an element is deleted from a queue is called a dequeue operation. Dequeue is always done from front pointer because queue data structure follows FIFO order.

Students Learning Outcomes (SLOs) -  Question Answers

Q.1: Define the term problem? OR What is problem?
Ans: DEFINITION OF PROBLEM:
A problem is a situation preventing something from being achieved. A problem can be a task, a situation or any other thing.
In simple language,
A problem is a question which requires an answer or a solution. In any case, a problem is considered to be a matter which is difficult to solve or settle, a doubtful case, or a complex task involving doubt and uncertainty.
OR
Problem sometimes referred as an issue, is any situation that occurs and is unexpected or prevents something from occurring. In programming a problem is considered as a matter which is difficult to solve, it is a complex task or routine.

Q.2: Evaluate a problem in order to find out its best solution. OR What do you mean by problem solving. Explain it briefly?
Ans: DEFINITION OF PROBLEM SOLVING:
Problem solving is the process of finding solutions of difficult or complex issues. It is the process by which any kind of problem is solved.

EXPLANATION:
Solving problems is the core feature of computers. A computer is not intelligent. It cannot analyze a problem and come up with a solution.
Responsibility Of A Programmer:
A human (the programmer) must analyze the problem, develop the instructions for solving the problem, and then make the computer carry out the instructions. The major responsibility of a programmer is to provide solution of the problems by using computers.
Evaluate A Problem:
It will be easier if computer science students first understand how a human solves a problem, then understand how to translate this solution into something a computer can understand, and finally how to "write" the specific steps to get the job done.
In some cases a machine will solve a problem in a completely different way than a human.

Evaluate A Problem

Q.3: Design a strategy for the solution of problem?
Ans: STRATEGY FOR THE SOLUTION OF PROBLEM:
Plan the solution of Problem:
Problems can be solved with the help of computers but for this programmer has to plan and strategize tasks that lead to the solution of the problem.
Problem Solving Strategies:
A very important aspect of problem-solving is developing good strategies. There are many strategies for solving a problem.
Definition Of Strategy:
A strategy is an approach (or a series of approaches) created to solve a computational problem. Strategies are designed according to the nature of the problem. Strategies are flexible and show various steps to reach the solution. A strategy in itself might produce incorrect results, but an algorithm based on such strategy will always produce correct results.

Thus for solving any problem, it is important to know what the problem really is and how it should actually be if there was no such problem. The question about end result helps to find the gap and create a strategy for solution.

Q.4: Define term algorithm? Give examples also.
Ans: ALGORITHM
Definition:
An algorithm is a set of instructions/steps/rules that are followed to solve a problem. It is a tool for solving a well-specified computational problem. In our daily lives as well, we follow various algorithms without knowing.

Types Or Methods Of Algorithms:
There are two common methods to express algorithm designs;
  • Pseudocode and
  • Flowcharts.

For example:
Example 1: Routine Life Work
We follow a daily routine after waking up in the morning.
We follow a set of instructions while driving a car.
We follow recipes in cooking food or making tea.
These step-by-step instructions that we follow everyday are algorithms to solve certain problems.

Example 2: Information Technology (IT)
Algorithms are widely used throughout all areas of Information Technology (IT).
A search engine algorithm, for example, takes search strings of keywords and operators as input, searches its associated database for relevant web pages, and returns results.

Example 3: Online Advertisement:
Another common example is online advertisements where the algorithm takes age, gender, region and interests as input and then displays ads to only those people who match the criteria.

Q.5: How is algorithms designed? What are the qualities of good algorithms?
Ans: Designing An Algorithm:
A computer programmer has to design various algorithms to create a program. These algorithms can vary from retrieving input from a user to computing complex formulas to reach a conclusion. This data is then rearranged into a meaningful way to present to the user. The user then makes decisions based on the presented data.

Qualities of Good Algorithms:
  • Input and output should be defined precisely.
  • Each step in the algorithm should be clear and unambiguous.
  • Algorithms are supposed to be most effective among many different ways to solve a problem.
  • An algorithm should not include computer code. Instead, the algorithm should be written in such a way that it can be used in different programming languages.

Q.6: Design algorithm to find sum, average, volume, percentage and others.
Ans: Algorithm Examples:
Following are few examples of simple algorithm.

Algorithm 1: Making a cup of tea
  • Step 1: Start
  • Step 2: Place the fresh water in a pot or a kettle.
  • Step 3: Boil the water.
  • Step 4: Put the black tea leaves in that pot.
  • Step 5: After that add some milk into that pot.
  • Step 6: Add some sugar.
  • Step 7: Boil for some time.
  • Step 8: Stop

Algorithm 2: Sum of two numbers
  • Step 1: Start
  • Step 2: Declare variables num1, num2 and sum.
  • Step 3: Read values num1 and num2.
  • Step 4: Add num1 and num2 and assign the result to sum.
    sum = num1 + num2
  • Step 5: Display sum
  • Step 6: Stop

Algorithm 3: Average of three numbers
  • Step 1: Start
  • Step 2: Declare variables num1, num2, num3 and avg.
  • Step 3: Read values num1, num2 and num3.
  • Step 4: Apply formula {Average = Sum / No. of values}
    avg = (num1 + num2 + num3) / 3
  • Step 5: Display avg
  • Step 6: Stop

Algorithm 4: Volume of a box
  • Step 1: Start
  • Step 2: Declare variables length, width, height and volume.
  • Step 3: Read values length, width and height.
  • Step 4: Apply formula {Volume = length x width x height}
    volume = length x width x height
  • Step 5: Display volume
  • Step 6: Stop

Algorithm 5: Percent Calculate
  • Step 1: Start
  • Step 2: Declare variables part, total and percentage.
  • Step 3: Read values part and total.
  • Step 4: Apply formula {Percentage = (part / total) x 100}
    percentage = (part / total) x 100
  • Step 5: Display percentage
  • Step 6: Stop

Q.7: Define the flowchart? Identify the different symbols used in flowchart designing?
Ans: FLOWCHART:
Definition:
The flowchart is the physical representation of problem solving process. It is used to show the sequence of steps and logic of solution for a problem, before writing the full computer program. It also helps in communicating the steps of the solution to others by using different symbols.
OR
It is a general-purpose tool used to define the sequence of different types of processes or operations in information system or program. It shows processes and their flow visually using diagram. It describes graphically different steps of programs or any operation and their sequence or flow using different symbols.

PURPOSE OF DIFFERENT TYPES FLOWCHART:
Information system flowcharts show flow of data from source documents to final distribution to users.
Program flowcharts show the sequence of steps or instructions in a single program or subroutine. It is diagrammatic or graphical representation of algorithm and converts word of algorithm into symbols.

PROCESS Of FLOWCHART PRESENTATION:
The flowchart shows different steps with the help of different shapes and their sequence. The processes are connected with directed lines or arrows which show the path from one procedure step to the next.

Flowchart Symbols:
Flowchart is made up of different symbols to represent or show program and its flow. Some of them are as follows:


Q.8: Design flowchart for any problem by using various flowchart symbols?
Ans:

Q.9: Differentiate between algorithm and flowchart?
Ans: Difference between Algorithm and Flowchart
S.NO. Algorithm Flowchart
1. Algorithm is step by step solution of a problem Flowchart is a diagram of different shapes which shows flow of data through processing system.
2. In algorithm text is used.  In flowchart, symbols or shapes are used.
3. Algorithm is easy to debug. Flowchart is difficult to debug.
4. Algorithm is difficult to write and understand. Flowchart is easy to construct and understand.
5. Algorithm does not follow any rules. Flowchart follows rules for its construction.
6. Algorithm is the pseudo code of the program. Flowchart is just graphical o visual representation of program logic.


Q.10: Define Data Structure? What are its different types? Describe each type with examples?
Ans: DATA STRUCTURE:
A data structure is a particular way of organizing data in a computer to use it effectively.
For example:
Array data structure is used to store a list of items having the same data-type.

TYPES OF DATA STRUCTURE:
Data structure may be;
  1. Linear or
  2. Non-linear.

Linear Data structures:
  • In Linear Data Structure data elements are arranged in sequential order and each of the elements is connected to its previous and next element.
  • This structure helps to convert a linear data structure in a single level and in single run.
  • They are easy to implement as computer memory is also in a sequential form.
  • Linear data structures are not efficient in memory utilization.
  • Examples:
    The types of linear data structures are;
    (i) Stack
    (ii) Queue
    (iii) Array etc.

Non-Linear Data Structures:
  • The elements of a non-linear data structure are not connected in a sequence.
  • Each element can have multiple paths to connect to other elements. They support multi-level storage and often cannot be traversed in single run.
  • Such data structures are difficult to implement but are more efficient in utilizing computer memory.
  • Examples:
  • The types of non-linear data structures are;
    (i) Tree
    (ii) Graphs etc.

Q.11: Define Linear data types? OR Describe types of linear data structure?
Ans: TYPES OF LINEAR DATA
The types of linear data structures are:
  1. Stack
  2. Queue
  3. Array

(a) STACK:
  • Stack is a linear data structure which follows a particular order to perform different operations.
  • Items may be added or removed only at the top of stack.
  • The order may be LIFO (Last In First Out) or FILO (First In Last Out).
  • The data which is placed first is removed in last and which is placed last is removed first.
  • We cannot remove data from the bottom or middle.
  • Examples of a stack are:
    Plates that are stacked or put over one another in the canteen. The plate which is at the top most is the first one to be removed and the plate which is placed at the bottom most position remains in the stack until last plate is removed.

Terms Use In Stack:
(i) Push:
The term push is used to insert a new element into the stack.

(ii) Pop:
pop is used to remove an element from the stack.

(iii) Top:
Insertion and removal can be done at one end called top.

(iv) Overflow:
Stack is in overflow state when it is completely full.
In overflow state we cannot add an item.

(v) Underflow:
It is in underflow state if it is completely empty.
In underflow state we cannot remove an item from it.

(b) QUEUE:
  • A Queue is a linear data which follows a particular order in which operations are performed in FIFO (First In First Out) method. It means that element inserted first will be removed first.
  • Once a new element is inserted into the Queue, it cannot be removed until all the elements inserted before it in the queue are removed.
  • Example of a queue is:
    Any queue of students in school or
    People in cinema where one who comes first gets the ticket first.

Terms Use In Queue:
(i) Front Or Head:
Deletions take place at one end called front or head.

(ii) Rear Or Tail:
Insertions take place only at the other end called rear or tail.

(iii) Enqueue:
The process to add an element into queue is called Enqueue.

(iv) Dequeue:
The process to remove an element from queue is called Dequeue.

(c) ARRAY:
  • Array is a linear data structure, which holds a list of finite data elements of same data type.
  • Each element of array is referenced by a set of index of consecutive numbers.
  • The elements of array are stored in successive memory locations.
  • Most of the data structures make use of arrays to implement their algorithms.
  • Example:
    Operations like Traversal, Search, Insertion, Deletion and Sorting can be performed on arrays.

Terms Use In Array:
Two terms are necessary to understand array.
(i) Element:
Each item stored in an array is called an element.

(ii) Index:
Each location of an element in an array has a numerical value called index, which is used to identify the element.
Set of indexes in an array are consecutive numbers.


Q.12: Define Non-Linear data types? OR Describe types of non-linear data structure?
Ans: TYPES OF NON-LINEAR DATA:
There are two types of non-linear data
  • Tree
  • Graph

a) TREE:
  • This non-linear data structure is used to represent data containing a hierarchical relationship between elements.
  • Element Of Tree - Nodes
    - Tree represents its elements as the nodes connected to each other by edges.
    - In each tree collection, we have one root node, which is the very first node in our tree.
    - If a node is connected to another node element, it is called a parent node and the connected node is called its child node.
  • Binary Tree:
    - There is also a binary tree or binary search tree.
    - A binary tree is a special data structure used to store data in which each node can have a maximum of two children.
    - Each node element may or may not have child nodes.


(b) GRAPH:
A graph is a non-linear data structure.

Elements Of Graph:
  • Graph is consisting of data elements (finite set) called nodes/vertices and edges that are lines that connect any two nodes in that graph.
  • Each element or node can contain information like roll number, name of student, marks, etc.
  • In graph each node can have any number of edges, there is no any node called root or child.
  • A cycle can also be formed.


In the above given figure, circles represent nodes or vertices, while lines represent edges.

Uses OF Graph
Graphs are used to solve network problems.
Examples of networks include:
  • Telephone networks
  • Social networks like Facebook, etc.
  • Mobile Network like a single mobile phone is represented as a node (vertex) whereas its connection with other phones can be shown as an edge between nodes
.
Types of graphs:
There are two types of graphs.
1. Undirected Graph:
In an undirected graph, nodes are connected by edges that are all bidirectional.
For example if an edge connects node 1 and 2, we can traverse from node 1 to node 2, and from node 2 to 1.

2. Directed Graph:
In a directed graph, nodes are connected by directed edges - they only go in one direction.
For example, if an edge connects node 1 and 2, but the arrow head points towards 2, we can only traverse from node 1 to node 2 -not in the opposite direction.






7 comments:

  1. Aslam Alaikum. I think you have lot traffic on your website still you are too weak to upload notes. I think you should not distract students from your website but website is null and void to our questions. Please do something.

    ReplyDelete
    Replies
    1. Education is the key to success12 April 2022 at 13:25

      Walaikum Assalam,
      I agree with you and I have same guilt because many teachers send me content to help students, But i am very slow to upload all quickly, two reason:
      1. Trying to avoid mistakes in content
      2. And try to upload solution of content if needed.

      May Allah Give me strength to manage all that in time. I will try my best and never give up....
      Due to load of work not replying any comment but can't stop to reply you.
      Need prayers
      JAZAKALLAH

      Delete
  2. It helps so much.... perfect web for 10 students of computer science

    ReplyDelete
    Replies
    1. Education is the key to success7 May 2024 at 11:55

      JAZAKALLAH

      Delete
  3. Thankyou editor..may god bless you ♡

    ReplyDelete
    Replies
    1. Education Is the key to success7 May 2024 at 11:53

      JAZAKALLAH

      Delete