The Wayback Machine - https://web.archive.org/web/20240831080320/https://www.geeksforgeeks.org/introduction-to-computation-complex-theory/
Open In App

Introduction to Computation Complex Theory

Last Updated : 28 Dec, 2020
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

Broad Overview :
Complexity theory, in a nutshell, a complexity word is a quite fancy word, literally, it sounds complex, but it is not an intimidating topic. What it really means is analyzing the program or we can say analyzing the efficiency of the program, figuring out whether the program is correct, figuring out whether one program is better than the other program and how exactly do we go about doing it in a very quantified way. There are lots of variants of this bit that we are generally looking at when we are doing any computer programming or in general or in most practical purposes are just two main complexities, one is Time Complexity, and the other is Space (memory) Complexity.

Time complexity is simple as how fast your code runs, how much time it will take, depends on the number of steps. Time complexity is hardware-independent, so let suppose I write one program, and I might have a supercomputer or I might have a simple laptop, so the time will be different based on where you run the program so it is not a very deterministic metric and we want something very robust and pretty deterministic so next we have a very simple step, which does not measure the actual time but we know that the time is basically very proportional to the number of steps that are taken by the program.

Example of Complexity in Time (execution) and Space (memory) factors :

Example-1 : More Complex

i = 1;                        1s
while( i <= 10 )              11s
{
    a = 5;                       10s
    result = i * a;              10s
    printf(“\n” /d”, result);    10s
    i++;                         10s
}

Here, we assume each variable is equal to 2 Bytes. In the above example we use three variables (i, a, result) which is 6 Bytes.

Execution Time : 52s
Memory (Space) : 6 Bytes


Example-2 : Less Complex

a = 5;                       1s
i = 1;                           1s
while( i<=10)                  11s
{  
    result = i * a;              10s
    printf(“\n” /d”, result);    10s
    i++;                         10s 
}

Execution Time : 43s
Memory (Space) : 6 Bytes


Problems in Computation Complexity :

  • Solvable Problems :
    A problem is said to be solvable first either if you find a solution means what there exists a potential solution, you have an algorithm and procedure to find its solution but also the problem is solvable if you proved mathematically there exists no solution which means the problem does not require any further discussion because we know the problem can never be solvable n matter how many times, we try to solve the problem.

  • Unsolvable Problem :
    Unsolvable problems in computer science is a temporary status of the problem because a problem is unsolvable, we say that instant of time neither we are able to solve the problem nor in a position to say that the problem can not be solved which means in unsolvable problems we are still confused, and the discussion is still open. And if the problem lies in this domain so it is known as an unsolvable problem.

  • Decidable Vs Undecidable :
    Basically, the solvable problems are divided into two categories – Decidable and Undecidable. Before going into the depth of the decidability domain, we should have a good knowledge of algorithms and machine models of the Theory of Computation, especially the Turing Machines.

  • Decidable Problem :
    When we talk about the decidable problems the two important terms are used algorithms and procedures. The procedure is a step-by-step instruction to solve a problem. A procedure becomes an algorithm when we say what is the approximate time to solve a problem. When we are concern with decidable problems means it includes both algorithms as well as procedures.

  • Undecidable Problem :
    When we talk about undecidable problems then we can not predict the time of the problem in which a problem can be solved. Undecidable problems are also solvable and there exists a procedure to solve the problem, but the problem is complex as we cannot predict the approximate time.



Similar Reads

Introduction of Theory of Computation
Automata theory (also known as Theory Of Computation) is a theoretical branch of Computer Science and Mathematics, which mainly deals with the logic of computation with respect to simple machines, referred to as automata. Automata* enables scientists to understand how machines compute the functions and solve problems. The main motivation behind dev
3 min read
Introduction To Grammar in Theory of Computation
Prerequisite - Theory of ComputationGrammar :It is a finite set of formal rules for generating syntactically correct sentences or meaningful correct sentences.Constitute Of Grammar :Grammar is basically composed of two basic elements - Terminal Symbols -Terminal symbols are those which are the components of the sentences generated using a grammar a
3 min read
Relationship between grammar and language in Theory of Computation
A grammar is a set of production rules which are used to generate strings of a language. In this article, we have discussed how to find the language generated by a grammar and vice versa as well. Language generated by a grammar - Given a grammar G, its corresponding language L(G) represents the set of all strings generated from G. Consider the foll
4 min read
Theory of Computation | Regular languages and finite automata | Question 2
What is the complement of the language accepted by the NFA shown below? (A) A (B) B (C) C (D) D Answer: (B) Explanation: Quiz of this QuestionPlease comment below if you find anything wrong in the above post
1 min read
Arden's Theorem in Theory of Computation
Arden's theorem state that: "If P and Q are two regular expressions over "∑", and if P does not contain "∈" , then the following equation in R given by R = Q + RP has a unique solution i.e., R = QP*." That means, whenever we get any equation in the form of R = Q + RP, then we can directly replace it with R = QP*. So, here we will first prove that R
4 min read
Halting Problem in Theory of Computation
To understand better the halting problem, we must know Decidability, Undecidability and Turing machine, decision problems and also a theory named as Computability theory and Computational complexity theory. Some important terms: Computability theory - The branch of theory of computation that studies which problems are computationally solvable using
4 min read
Decidability Table in Theory of Computation
Prerequisite - Undecidability, Decidable and undecidable problems Identifying languages (or problems*) as decidable, undecidable or partially decidable is a very common question in GATE. With correct knowledge and ample experience, this question becomes very easy to solve. A language is undecidable if it is not decidable. An undecidable language ma
2 min read
Chomsky Hierarchy in Theory of Computation
According to Chomsky hierarchy, grammar is divided into 4 types as follows: Type 0 is known as unrestricted grammar.Type 1 is known as context-sensitive grammar.Type 2 is known as a context-free grammar.Type 3 Regular Grammar.Type 0: Unrestricted Grammar: Type-0 grammars include all formal grammar. Type 0 grammar languages are recognized by turing
2 min read
Pumping Lemma in Theory of Computation
There are two Pumping Lemmas, which are defined for 1. Regular Languages, and 2. Context - Free Languages Pumping Lemma for Regular Languages For any regular language L, there exists an integer n, such that for all x ? L with |x| ? n, there exists u, v, w ? ?*, such that x = uvw, and (1) |uv| ? n (2) |v| ? 1 (3) for all i ? 0: uviw ? L In simple te
4 min read
Decidable and Undecidable problems in Theory of Computation
Prerequisite - Turing Machine A problem is said to be Decidable if we can always construct a corresponding algorithm that can answer the problem correctly. We can intuitively understand Decidable problems by considering a simple example. Suppose we are asked to compute all the prime numbers in the range of 1000 to 2000. To find the solution of this
4 min read
Automata Theory | Set 7
These questions for practice purpose for GATE CS Exam. Ques-1: Consider L= {(TM) | TM is the Turing machine that halts on all input and L(TM)= L' for some undecidable language L'}. Here, (TM) is the encoding of a Turing machine as a string over alphabet {0, 1} then L is: (A) decidable and recursively enumerable (B) decidable and recursive (C) decid
3 min read
Automata Theory | Set 8
These questions for practice purpose for GATE CS Exam. Ques-1: Which one of the following language is Regular? (A) {wxwR | w,x ∈ (a+b)+} (B) {wxwR | w ∈ (a+b)*, x ∈ {a,b}} (C) {wwRx | w,x ∈ (a+b)+} (D) {wwR | w ∈ (a+b)*} Explanation: (A) It is correct, since this language can form regular expression which is {{ a(a + b)+a } + {b(a + b)+b}}, i.e., s
2 min read
Automata Theory | Set 9
These questions for practice purpose for GATE CS Exam. Ques-1: Consider the following two statements with respect to Countability: Statement-1: If X union of 'Y' is uncountable, then both set 'X' and set 'Y' must be uncountable. Statement-2: The Cartesian product of two countable sets 'X' and 'Y' is countable. Which of the following option is true
3 min read
Automata Theory | Set 10
These questions for practice purpose of GATE CS Exam. Ques-1: Consider the following statements: X: For any language either a language L or its complement L' must be finite.Y: DFA for language which contains epsilon must have initial state as final state.Z: Non-deterministic finite automata is more powerful than deterministic finite automata. Which
3 min read
Introduction of Pushdown Automata
We have already discussed finite automata. But finite automata can be used to accept only regular languages. Pushdown Automata is a finite automata with extra memory called stack which helps Pushdown automata to recognize Context Free Languages. A Pushdown Automata (PDA) can be defined as : Q is the set of states∑is the set of input symbolsΓ is the
4 min read
Introduction to Queue Automata
We already know about Finite Automata which can be used to accept regular languages and Pushdown Automata that can be used to recognize Context Free Languages. Queue Automata(QDA) is a non-deterministic automata that is similar to Pushdown Automata but has a queue instead of a stack which helps Queue automata to recognize languages beyond Context F
2 min read
Introduction to Linear Bounded Automata (LBA)
History :In 1960, associate degree automaton model was introduced by Myhill and these days this automation model is understood as deterministic linear bounded automaton. After this, another scientist named Landweber worked on this and proposed that the languages accepted by a deterministic LBA are continually context-sensitive languages. In 1964, K
2 min read
Introduction to UNIX System
Unix is an Operating System that is truly the base of all Operating Systems like Ubuntu, Solaris, POSIX, etc. It was developed in the 1970s by Ken Thompson, Dennis Ritchie, and others in the AT&amp;T Laboratories. It was originally meant for programmers developing software rather than non-programmers. Unix and the C were found by AT&amp;T and distr
8 min read
Introduction of Finite Automata
Finite Automata(FA) is the simplest machine to recognize patterns.It is used to characterize a Regular Language, for example: /baa+!/.Also it is used to analyze and recognize Natural language Expressions. The finite automata or finite state machine is an abstract machine that has five elements or tuples. It has a set of states and rules for moving
5 min read
What is Context-Free Grammar?
Context Free Grammar is formal grammar, the syntax or structure of a formal language can be described using context-free grammar (CFG), a type of formal grammar. The grammar has four tuples: (V,T,P,S). V - It is the collection of variables or non-terminal symbols.T - It is a set of terminals. P - It is the production rules that consist of both term
3 min read
Difference Between NPDA and DPDA
A Pushdown Automata (PDA) is a way to implement context-free Grammar in a similar way. We design Finite Automata for Regular Grammar. It is more powerful than FSM.FSM has very limited memory but PDA has more memory.PDA= Finite State Machine + StackThis stack has infinite memory and that facilitates the higher power of Pushdown automata. This helps
4 min read
Boyer-Moore Majority Voting Algorithm
The Boyer-Moore voting algorithm is one of the popular optimal algorithms which is used to find the majority element among the given elements that have more than N/ 2 occurrences. This works perfectly fine for finding the majority element which takes 2 traversals over the given elements, which works in O(N) time complexity and O(1) space complexity
7 min read
Difference between DFA and NFA
1. DFA: DFA refers to Deterministic Finite Automaton. A Finite Automata(FA) is said to be deterministic if corresponding to an input symbol, there is a single resultant state i.e. there is only one transition. A deterministic finite automata is set of five tuples represented as, Where, Q: A non-empty finite set of states in the finite control(qo, q
3 min read
Closure properties of Regular languages
Closure properties on regular languages are defined as certain operations on regular language that are guaranteed to produce regular language. Closure refers to some operation on a language, resulting in a new language that is of the same "type" as originally operated on i.e., regular. Regular languages are closed under the following operations: Co
4 min read
Difference Between Mealy Machine and Moore Machine
Mealy Machine is defined as a machine in the theory of computation whose output values are determined by both its current state and current inputs. In this machine at most one transition is possible. It has 6 tuples: (Q, q0, ∑, ▲, δ, λ’)  Q is a finite set of states q0 is the initial state ∑ is the input alphabet ▲ is the output alphabet δ is the t
2 min read
Mealy and Moore Machines in TOC
Moore and Mealy Machines are Transducers that help in producing outputs based on the input of the current state or previous state. In this article we are going to discuss Moore Machines and Mealy Machines, the difference between these two machines as well as Conversion from Moore to Mealy and Conversion from Mealy to Moore Machines. Moore Machines
2 min read
Turing Machine in TOC
Turing Machine was invented by Alan Turing in 1936 and it is used to accept Recursive Enumerable Languages (generated by Type-0 Grammar).  Turing machines are a fundamental concept in the theory of computation and play an important role in the field of computer science. They were first described by the mathematician and computer scientist Alan Turi
6 min read
Minimization of DFA
DFA minimization stands for converting a given DFA to its equivalent DFA with minimum number of states. DFA minimization is also called as Optimization of DFA and uses partitioning algorithm.Minimization of DFA Suppose there is a DFA D &lt; Q, Δ, q0, Δ, F &gt; which recognizes a language L. Then the minimized DFA D &lt; Q’, Δ, q0, Δ, F’ &gt; can be
7 min read
Conversion from NFA to DFA
An NFA can have zero, one or more than one move from a given state on a given input symbol. An NFA can also have NULL moves (moves without input symbol). On the other hand, DFA has one and only one move from a given state on a given input symbol. Steps for converting NFA to DFA:Step 1: Convert the given NFA to its equivalent transition tableTo conv
5 min read
Regular Expressions, Regular Grammar and Regular Languages
As discussed in Chomsky Hierarchy, Regular Languages are the most restricted types of languages and are accepted by finite automata. Regular Expressions Regular Expressions are used to denote regular languages. An expression is regular if: ? is a regular expression for regular language ?.? is a regular expression for regular language {?}.If a ? ? (
6 min read