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

No.

Graph Tree

1 It is a non-linear data structure. It is also a non-linear data structure.

2 A graph is a set of vertices/nodes A tree is a set of nodes and edges.


and edges.

3 In the graph, there is no unique In a tree, there is a unique node which is known as root.
node which is known as root.

4 Each node can have several Usually, a tree can have several child nodes, and in the
edges. case of binary trees, each node consists of two child
nodes.

5 Graphs can form cycles. Trees cannot form a cycle.


Differentiate between Graph and Spanning tree.

Differentiate between Divide and Conquer, and dynamics programming technique for solving
problem

Divide and Conquer Dynamic Programming


Dynamic programming considers a large number of
Subproblems are solved independently, and finally all
decision sequences and all the overlapping
solutions are collected to arrive at the final answers.
substances.
The divide and conquer strategy is slower than the The dynamic programming strategy is slower than the
dynamic programming approach. divide and conquer approach.
Reduce the amount of time spent on execution by
Maximize time for execution.
consuming less time.
Recursive techniques are used in Divide and Non-Recursive techniques are used in Dynamic
Conquer. programming.
In a dynamic programming solution, the bottom-up
A top-down approach is used in Divide and Conquer.
approach is used.
The problems that are part of a Divide and Conquer A dynamic programming subproblem is dependent
strategy are independent of each other. upon other sub-problems.
One of the best examples of this strategy is a binary One of the best examples of this strategy is the
search. longest common subsequence.
No results are stored when completing sub-problems. The solutions to sub-problems are saved in the table.
Repeating tasks. There is no repeating task.
At a specified point, the split input splits big
Every point in the split input is processed.
problems into smaller ones.
A dynamic programming solution can sometimes be
The divide and conquer strategy is simple to solve.
complicated and challenging to solve.
Not more than one decision sequence is generated. More than one decision sequence is generated.
What is Push Down Automata ? How is it different from Finite Automata ?

A Pushdown automata (PDA) is a finite state machine with an added stack storage. Additional stack is used
in making the decision for transitions apart from input symbols and current state. It contains the following 7
tuples:

Pushdown automata finite automata

For Type-2 grammar we can design For Type-3 grammar we can design
1. pushdown automata. finite automata.

Non – Deterministic pushdown automata has Non-Deterministic Finite Automata has


more powerful than Deterministic pushdown same powers as in Deterministic Finite
2. automata. Automata.

Not every Non-Deterministic pushdown Every Non-Deterministic Finite Automata


automata is transformed into its equivalent is transformed into an equivalent
3. Deterministic pushdown Automata . Deterministic Finite Automata

Context free languages can be recognized by Regular languages can be recognized by


4. pushdown automata. finite automata.
Pushdown automata has the additional stack Finite Automata doesn’t has any space
5. for storing long sequence of alphabets. to store input alphabets.

It gives acceptance of input alphabhets by It accepts the input alphabets by going


6. going up to empty stack and final states. up to final states.

Explain Chomsky‟s classification of grammars.

According to Noam Chomosky, there are four types of grammars − Type 0, Type 1, Type 2, and
Type 3. The following table shows how they differ from each other −

Grammar Grammar Language Accepted Automaton


Type Accepted

Type 0 Unrestricted Recursively enumerable Turing Machine


grammar language

Type 1 Context-sensitive Context-sensitive Linear-bounded


grammar language automaton

Type 2 Context-free Context-free language Pushdown


grammar automaton

Type 3 Regular grammar Regular language Finite state


automaton

Differentiate between Big-oh (O) and Theta () Asymptotic notation


S.No
.
Big Oh (O) Big Omega (Ω) Big Theta (Θ)
It is like (<=)  It is like (>=)  It is like (==) 
rate of growth of an rate of growth is greater meaning the rate of
algorithm is less than or than or equal to a specified growth is equal to a
1. equal to a specific value.  value. specified value.
The upper bound of The bounding of function
algorithm is represented by from above and below is
Big O notation. Only the The algorithm’s lower represented by theta
above function is bounded bound is represented by notation. The exact
by Big O. Asymptotic Omega notation. The asymptotic behavior is
upper bound is  given by asymptotic lower bound is done by this theta
2. Big O notation. given by Omega notation. notation.
Big Omega (Ω) – Lower Big Theta (Θ) – Tight
3. Big oh (O) – Upper Bound Bound Bound
It is define as lower bound
It is define as upper bound and lower bound on an
and upper bound on an algorithm is the least It is define as tightest
algorithm is the most amount of time required bound and tightest bound
amount of time required ( the most efficient way is the best of all the
( the worst case possible, in other words worst case times that the
4. performance). best case). algorithm can take.
Mathematically – Big
Mathematically: Big Oh is Mathematically: Big Theta is 0 <= C2g(n) <=
0 <= f(n) <= Cg(n) for all n Omega is 0 <= Cg(n) <= f(n) <= C1g(n) for n >=
5. >= n0 f(n) for all n >= n0 n0

You might also like