Notes Chapter 1 QA-1
Notes Chapter 1 QA-1
PROBLEM SOLVING
AND ALGORITHM
DESIGNING
1
Chapter# 1: Problem Solving and Algorithm Designing
3 Each node can have any number of General trees consist of any the
edges modes having and number of child
nodes but in case of binary trees
every node can have
at the most two child nodes.
4 There is no unique node. called root There is a unique node called root
in graph in trees.
2
Chapter# 1: Problem Solving and Algorithm Designing
5 Algorithm does not follow any rules. Flowchart follows. rules for its
construction.
Q6- What is the difference between queue and stack data structure?
Ans.
Stack Queue
Definition
Stack is a linear data structure which Queue is a linear data structure which
follows a particular order to perform follows a particular order to perform
different operations. different operations.
Order
The order that stack follows is LIFO The order that queue follows is FIFO
(Last In First Out) method. (First In First out) method.
Add/Del of Items
Items may be added or removed only at Deletions take place at one end called
the top of the stack. We cannot remove Front of head and instructions take
data from the bottom as middle. place only at the other end called rear
for tail.
3
Chapter# 1: Problem Solving and Algorithm Designing
4
Chapter# 1: Problem Solving and Algorithm Designing
Q11. Explain non-linear data structure and its types with the help of diagram.
Ans.
1. Tree:
This non-linear data structure is used to represent data containing a hierarchical
relationship between elements.
Representation:
Tree represents its elements as the nodes connected to each other by edges.
Root Node:
In each tree collection, we have one root node, which is the very first node
in our tree.
Parent Node:
In each tree collection, we have one root node, which is the very first node
in our tree.
Child Node:
The sub-connected node to the parent node is called child node. Each node
element may or may not have child node.
Binary Search 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.
5
Chapter# 1: Problem Solving and Algorithm Designing
2. Graph:
A graph is a non-linear data structure consisting of data elements called
nodes/vertices and edges that are lines that connect any two nodes in a graph.
In graph each node can have any number of edges, there is no any node
called root or child.
Use:
Graphs are used to solve network problems.
Examples:
Examples of networks include telephone networks, social networks like
Facebook, etc.
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.
2. Directed Graph:
In a directed graph, nodes are connected by directed edges - they only go in
one direction.