The binary search algorithm allows for faster searching of an ordered array compared to linear search. It works by first examining the middle element of the array and eliminating half of the elements from further search based on whether the target value is less than or greater than the middle element. This process continues, halving the search space on each iteration, allowing binary search to have a time complexity of O(log n).
In most of the algorithms analyzed until now, we have been looking and studying problems solvable in polynomial time. The polynomial time algorithm class P are algorithms that on inputs of size n have a worst case running time of O(n^k) for some constant k. Thus, informally, we can say that the Non-Polynomial (NP) time algorithms are the ones that cannot be solved in O(n^k) for any constant k
.
Short Notes on Automata Theory
Automata theory is the study of abstract machines and automata, as well as the computational problems that can be solved using them. It is a theory in theoretical computer science and discrete mathematics (a subject of study in both mathematics and computer science). The word automata (the plural of automaton) comes from the Greek word αὐτόματα, which means "self-making".
FellowBuddy.com is an innovative platform that brings students together to share notes, exam papers, study guides, project reports and presentation for upcoming exams.
We connect Students who have an understanding of course material with Students who need help.
Benefits:-
# Students can catch up on notes they missed because of an absence.
# Underachievers can find peer developed notes that break down lecture and study material in a way that they can understand
# Students can earn better grades, save time and study effectively
Our Vision & Mission – Simplifying Students Life
Our Belief – “The great breakthrough in your life comes when you realize it, that you can learn anything you need to learn; to accomplish any goal that you have set for yourself. This means there are no limits on what you can be, have or do.”
Like Us - https://www.facebook.com/FellowBuddycom
WHAT IS PATTERN RECOGNISITION ?
Given a text string T[0..n-1] and a pattern P[0..m-1], find all occurrences of the pattern within the text.
Example: T = 000010001010001 and P = 0001, the occurrences are:
first occurrence starts at T[1]
second occurrence starts at T[5]
third occurrence starts at T[11]
APPLICATION :
Image preprocessing
• Computer vision
• Artificial intelligence
• Radar signal classification/analysis
• Speech recognition/understanding
• Fingerprint identification
• Character (letter or number) recognition
• Handwriting analysis
• Electro-cardiographic signal analysis/understanding
• Medical diagnosis
• Data mining/reduction
ALGORITHM DESCRIPTION
The Knuth-Morris-Pratt (KMP) algorithm:
It was published by Donald E. Knuth, James H.Morris and Vaughan R. Pratt, 1977 in: “Fast Pattern Matching in Strings.“
To illustrate the ideas of the algorithm, consider the following example:T = xyxxyxyxyyxyxyxyyxyxyxxy
And P = xyxyyxyxyxx
it considers shifts in order from 1 to n-m, and determines if the pattern matches at that shift. The difference is that the KMP algorithm uses information gleaned from partial matches of the pattern and text to skip over shifts that are guaranteed not to result in a match.
The text and pattern are included in Figure 1, with numbering, to make it easier to follow.
1.Consider the situation when P[1……3] is successfully matched with T[1……..3]. We then find a mismatch: P[4] = T[4]. Based on our knowledge that P[1…… 3] =T[1…… 3], and ignoring symbols of the pattern and text after position 3, what can we deduce about where a potential match might be? In this case, the algorithm slides the pattern 2 positions to the right so that P[1] is lined up with T[3]. The next comparison is between P[2] and T[4].
P: x y x y y x y x y x x
q: 1 2 3 4 5 6 7 8 9 10 11
_(q): 0 0 1 2 0 3
Table 1: Table of values for pattern P.
Time Complexity :
The call to compute prefix is O(m)
using q as the value of the potential function, we argue in the same manner as above to show the loop is O(n)
Therefore the overall complexity is O(m + n)
Boyer-Moore algorithm:
It was developed by Bob Boyer and J Strother Moore in 1977. The algorithm preprocesses the pattern string that is being searched in text string.
String pattern matching - Boyer-Moore:
This algorithm uses fail-functions to shift the pattern efficiently. Boyer-Moore starts however at the end of the pattern, which can result in larger shifts.Two heuristics are used:1: if we encounter a mismatch at character c in Q, we can shift to the first occurrence of c in P from the right:
Q a b c a b c d g a b c e a b c d a c e d
P a b c e b c d
a b c e b c d
(restart here)
Time Complexity:
• performs the comparisons from right to left;
• preprocessing phase in O(m+ ) t
Introduction to complexity theory that solves your assignment problem it contains about complexity class,deterministic class,big- O notation ,proof by mathematical induction, L-Space ,N-Space and characteristics functions of set and so on
In most of the algorithms analyzed until now, we have been looking and studying problems solvable in polynomial time. The polynomial time algorithm class P are algorithms that on inputs of size n have a worst case running time of O(n^k) for some constant k. Thus, informally, we can say that the Non-Polynomial (NP) time algorithms are the ones that cannot be solved in O(n^k) for any constant k
.
Short Notes on Automata Theory
Automata theory is the study of abstract machines and automata, as well as the computational problems that can be solved using them. It is a theory in theoretical computer science and discrete mathematics (a subject of study in both mathematics and computer science). The word automata (the plural of automaton) comes from the Greek word αὐτόματα, which means "self-making".
FellowBuddy.com is an innovative platform that brings students together to share notes, exam papers, study guides, project reports and presentation for upcoming exams.
We connect Students who have an understanding of course material with Students who need help.
Benefits:-
# Students can catch up on notes they missed because of an absence.
# Underachievers can find peer developed notes that break down lecture and study material in a way that they can understand
# Students can earn better grades, save time and study effectively
Our Vision & Mission – Simplifying Students Life
Our Belief – “The great breakthrough in your life comes when you realize it, that you can learn anything you need to learn; to accomplish any goal that you have set for yourself. This means there are no limits on what you can be, have or do.”
Like Us - https://www.facebook.com/FellowBuddycom
WHAT IS PATTERN RECOGNISITION ?
Given a text string T[0..n-1] and a pattern P[0..m-1], find all occurrences of the pattern within the text.
Example: T = 000010001010001 and P = 0001, the occurrences are:
first occurrence starts at T[1]
second occurrence starts at T[5]
third occurrence starts at T[11]
APPLICATION :
Image preprocessing
• Computer vision
• Artificial intelligence
• Radar signal classification/analysis
• Speech recognition/understanding
• Fingerprint identification
• Character (letter or number) recognition
• Handwriting analysis
• Electro-cardiographic signal analysis/understanding
• Medical diagnosis
• Data mining/reduction
ALGORITHM DESCRIPTION
The Knuth-Morris-Pratt (KMP) algorithm:
It was published by Donald E. Knuth, James H.Morris and Vaughan R. Pratt, 1977 in: “Fast Pattern Matching in Strings.“
To illustrate the ideas of the algorithm, consider the following example:T = xyxxyxyxyyxyxyxyyxyxyxxy
And P = xyxyyxyxyxx
it considers shifts in order from 1 to n-m, and determines if the pattern matches at that shift. The difference is that the KMP algorithm uses information gleaned from partial matches of the pattern and text to skip over shifts that are guaranteed not to result in a match.
The text and pattern are included in Figure 1, with numbering, to make it easier to follow.
1.Consider the situation when P[1……3] is successfully matched with T[1……..3]. We then find a mismatch: P[4] = T[4]. Based on our knowledge that P[1…… 3] =T[1…… 3], and ignoring symbols of the pattern and text after position 3, what can we deduce about where a potential match might be? In this case, the algorithm slides the pattern 2 positions to the right so that P[1] is lined up with T[3]. The next comparison is between P[2] and T[4].
P: x y x y y x y x y x x
q: 1 2 3 4 5 6 7 8 9 10 11
_(q): 0 0 1 2 0 3
Table 1: Table of values for pattern P.
Time Complexity :
The call to compute prefix is O(m)
using q as the value of the potential function, we argue in the same manner as above to show the loop is O(n)
Therefore the overall complexity is O(m + n)
Boyer-Moore algorithm:
It was developed by Bob Boyer and J Strother Moore in 1977. The algorithm preprocesses the pattern string that is being searched in text string.
String pattern matching - Boyer-Moore:
This algorithm uses fail-functions to shift the pattern efficiently. Boyer-Moore starts however at the end of the pattern, which can result in larger shifts.Two heuristics are used:1: if we encounter a mismatch at character c in Q, we can shift to the first occurrence of c in P from the right:
Q a b c a b c d g a b c e a b c d a c e d
P a b c e b c d
a b c e b c d
(restart here)
Time Complexity:
• performs the comparisons from right to left;
• preprocessing phase in O(m+ ) t
Introduction to complexity theory that solves your assignment problem it contains about complexity class,deterministic class,big- O notation ,proof by mathematical induction, L-Space ,N-Space and characteristics functions of set and so on
NP completeness. Classes P and NP are two frequently studied classes of problems in computer science. Class P is the set of all problems that can be solved by a deterministic Turing machine in polynomial time.
Bliss: A New Read Overlap Detection AlgorithmCSCJournals
Many assemblers carry out heuristic based overlap detection to avoid string comparisons. But heuristics skips many true overlaps. Also, the order of the number of read pairs compared for overlaps is higher than the order of n. In the raw approach it would be n 2 where every read is compared to every other read. Some assemblers have used a hybrid approach to bring the order down from n 2. Here is an algorithm which works with 100% accuracy. As there is no heuristics involved, it is able to report all the overlaps in a given set of reads without actual string comparisons. It achieves this purely by querying the k-mer position data. Moreover, the number of read pairs compared is proportional to the number of reads present i.e. of the order of n.
The Metaverse and AI: how can decision-makers harness the Metaverse for their...Jen Stirrup
The Metaverse is popularized in science fiction, and now it is becoming closer to being a part of our daily lives through the use of social media and shopping companies. How can businesses survive in a world where Artificial Intelligence is becoming the present as well as the future of technology, and how does the Metaverse fit into business strategy when futurist ideas are developing into reality at accelerated rates? How do we do this when our data isn't up to scratch? How can we move towards success with our data so we are set up for the Metaverse when it arrives?
How can you help your company evolve, adapt, and succeed using Artificial Intelligence and the Metaverse to stay ahead of the competition? What are the potential issues, complications, and benefits that these technologies could bring to us and our organizations? In this session, Jen Stirrup will explain how to start thinking about these technologies as an organisation.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfPeter Spielvogel
Building better applications for business users with SAP Fiori.
• What is SAP Fiori and why it matters to you
• How a better user experience drives measurable business benefits
• How to get started with SAP Fiori today
• How SAP Fiori elements accelerates application development
• How SAP Build Code includes SAP Fiori tools and other generative artificial intelligence capabilities
• How SAP Fiori paves the way for using AI in SAP apps
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
A tale of scale & speed: How the US Navy is enabling software delivery from l...sonjaschweigert1
Rapid and secure feature delivery is a goal across every application team and every branch of the DoD. The Navy’s DevSecOps platform, Party Barge, has achieved:
- Reduction in onboarding time from 5 weeks to 1 day
- Improved developer experience and productivity through actionable findings and reduction of false positives
- Maintenance of superior security standards and inherent policy enforcement with Authorization to Operate (ATO)
Development teams can ship efficiently and ensure applications are cyber ready for Navy Authorizing Officials (AOs). In this webinar, Sigma Defense and Anchore will give attendees a look behind the scenes and demo secure pipeline automation and security artifacts that speed up application ATO and time to production.
We will cover:
- How to remove silos in DevSecOps
- How to build efficient development pipeline roles and component templates
- How to deliver security artifacts that matter for ATO’s (SBOMs, vulnerability reports, and policy evidence)
- How to streamline operations with automated policy checks on container images
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™UiPathCommunity
In questo evento online gratuito, organizzato dalla Community Italiana di UiPath, potrai esplorare le nuove funzionalità di Autopilot, il tool che integra l'Intelligenza Artificiale nei processi di sviluppo e utilizzo delle Automazioni.
📕 Vedremo insieme alcuni esempi dell'utilizzo di Autopilot in diversi tool della Suite UiPath:
Autopilot per Studio Web
Autopilot per Studio
Autopilot per Apps
Clipboard AI
GenAI applicata alla Document Understanding
👨🏫👨💻 Speakers:
Stefano Negro, UiPath MVPx3, RPA Tech Lead @ BSP Consultant
Flavio Martinelli, UiPath MVP 2023, Technical Account Manager @UiPath
Andrei Tasca, RPA Solutions Team Lead @NTT Data
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...
Mcs 031
1. Explanation of binary search algorithm
Suppose we are given a number of integers stored in an array A, and we want to locate a specific target integer K
in this array. If we do not have any information on how the integers are organized in the array, we have to
sequentially examine each element of the array. This is known as linear search and would have a time complexity
of O(n ) in the worst case. However, if the elements of the array are ordered, let us say in ascending order, and we
wish to find out the position of an integer target K in the array, we need not make a sequential search over the
complete array. We can make a faster search using the Binary search method. The basic idea is to start with an
examination of the middle element of the array. This
will lead to 3 possible situations:
If this matches the target K then search can terminate successfully by printing out the index of the element in the
array. On the other hand, if K<A[middle], then search can be limited to elements to the left of A[middle]. All
elements to the right of middle can be ignored. If it turns out that K >A[middle], then further search is limited to
elements to the right of A[middle]. If all elements are exhausted and the target is not found in the array, then the
method returns a special value such as –1. Here is one version of the Binary Search function:
int BinarySearch (int A[ ], int n, int K)
{
int L=0, Mid, R= n-1;
while (L<=R)
{
Mid = (L +R)/2;
if ( K= =A[Mid] )
return Mid;
else if ( K > A[Mid] )
L = Mid + 1;
else
R = Mid – 1 ;
}
return –1 ;
}
Let us now carry out an Analysis of this method to determine its time complexity. Since there are no “for” loops,
we can not use summations to express the total number of operations. Let us examine the operations for a specific
case, where the number of elements in the array n is 64. When n= 64 Binary Search is called to reduce size to n=32.
When n= 32 Binary Search is called to reduce size to n=16
When n= 16 Binary Search is called to reduce size to n=8
When n= 8 Binary Search is called to reduce size to n=4
When n= 4 Binary Search is called to reduce size to n=2
When n= 2 Binary Search is called to reduce size to n=1
Thus we see that Binary Search function is called 6 times ( 6 elements of the array were examined) for n =64. Note
6
that 64 = 2 . Also we see that the Binary Search function is called 5 times ( 5 elements of the array were examined)
5 k
for n = 32. Note that 32 = 2 . Let us consider a more general case where n is still a power of 2. Let us say n = 2 .
Following the above argument for 64 elements, it is easily seen that after k searches, the while loop is executed k
times and n reduces to size 1. Let us assume that each run of the while loop involves at most 5 operations. Thus
k
total number of operations: 5k. The value of k can be determined from the expression 2 = n. Taking log of both
sides k = log n. Thus total number of operations = 5 log n. We conclude from there that the time complexity of the
Binary search method is O(log n), which is much more efficient than the Linear Search method.
Show that clique problem is an NP complete problem
Clique Problem:-In computer science, the clique problem refers to any of the problems related to
finding particular complete sub graphs in a graph, i.e., sets of elements where each pair of elements is
connected. For example, the maximum clique problem arises in the following real-world setting.
Consider a social network, where the graph’s vertices represent people, and the graph’s edges represent
mutual acquaintance. To find a largest subset of people who all know each other, one can systematically
inspect all subsets, a process that is too time-consuming to be practical for social networks comprising
2. more than a few dozen people. Although this brute-force search can be improved by more
efficient algorithms, all of these algorithms take exponential time to solve the problem. Therefore, much
of the theory about the clique problem is devoted to identifying special types of graph that admit more
efficient algorithms, or to establishing the computational difficulty of the general problem in various
models of computation.
Clique problem is an NP complete The clique decision problem is NP-complete. This problem was also
mentioned in Stephen Cook's paper introducing the theory of NP-complete problems. Thus, the problem
of finding a maximum clique is NP-hard: if one could solve it, one could also solve the decision problem,
by comparing the size of the maximum clique to the size parameter given as input in the decision
problem. Karp's NP-completeness proof is a many-one reduction from the Boolean satisfiability
problem for formulas in conjunctive normal form, which was proved NP-complete in the Cook–Levin
theorem. From a given CNF formula, Karp forms a graph that has a vertex for every pair (v,c), where v is
a variable or its negation and c is a clause in the formula that contains v. Vertices are connected by an
edge if they represent compatible variable assignments for different clauses: that is, there is an edge
from (v,c) to (u,d) whenever c ≠ d and u and v are not each others' negations. Ifk denotes the number of
clauses in the CNF formula, then the k-vertex cliques in this graph represent ways of assigning truth
values to some of its variables in order to satisfy the formula; therefore, the formula is satisfiable if and
only if a k-vertex clique exists.
Some NP-complete problems (such as the travelling salesman problem in planar graphs) may be solved
in time that is exponential in a sublinear function of the input size parameter n. However,
as Impagliazzo, Paturi & Zane (2001)describe, it is unlikely that such bounds exist for the clique problem
in arbitrary graphs, as they would imply similarly subexponential bounds for many other standard NP-
complete problems.
A monotone circuit to detect a k-clique in an n-vertex graph for k = 3 and n = 4.
Each of the 6 inputs encodes the presence or absence of a particular (red) edge in the input graph. The circuit uses one
internal or-gate to detect each potential k-clique.
According to the CHOMSKY’s what are the different types in which grammars are classified? Explain with an
example
Within the field of computer science, specifically in the area of formal languages, the Chomsky hierarchy is
a containment hierarchy of classes of formal grammars.
Type-0 grammars (unrestricted grammars) include all formal grammars. They generate exactly all languages
that can be recognized by a Turing machine. These languages are also known as the recursively enumerable
languages. Note that this is different from the recursive languages which can be decided by an always-halting
Turing machine.
Type-1 grammars (context-sensitive grammars) generate the context-sensitive languages. These grammars
have rules of the form with A a nonterminal and α, β and γ strings of terminals and
nonterminals. The strings α and β may be empty, but γ must be nonempty. The rule is allowed
if S does not appear on the right side of any rule. The languages described by these grammars are exactly all
languages that can be recognized by a linear bounded automaton (a nondeterministic Turing machine whose
tape is bounded by a constant times the length of the input.)
3. Type-2 grammars (context-free grammars) generate the context-free languages. These are defined by rules of
the form with A a nonterminal and γ a string of terminals and nonterminals. These languages are
exactly all languages that can be recognized by a non-deterministic pushdown automaton. Context-free
languages are the theoretical basis for the syntax of most programming languages.
Type-3 grammars (regular grammars) generate the regular languages. Such a grammar restricts its rules to a
single nonterminal on the left-hand side and a right-hand side consisting of a single terminal, possibly followed
(or preceded, but not both in the same grammar) by a single nonterminal. The rule is also allowed
here if S does not appear on the right side of any rule. These languages are exactly all languages that can be
decided by a finite state automaton. Additionally, this family of formal languages can be obtained by regular
expressions. Regular languages are commonly used to define search patterns and the lexical structure of
programming languages.
Production rules
Grammar Languages Automaton
(constraints)
Recursively
Type-0 Turing machine (no restrictions)
enumerable
Linear-bounded non-deterministic Turing
Type-1 Context-sensitive αAβ ⟶ αγβ
machine
Type-2 Context-free Non-deterministic pushdown automaton
Type-3 Regular Finite state automaton and
Greedy algorithm gives a optimal solution & when it will be failed
A greedy algorithm is any algorithm that follows the problem solving heuristic of making the locally
optimal choice at each stage with the hope of finding the global optimum. For example, applying the
greedy strategy to the traveling salesman problem yields the following algorithm: "At each stage visit
the unvisited city nearest to the current city". In general, greedy algorithms are used for optimization
problems. In general, greedy algorithms have five pillars:
1. A candidate set, from which a solution is created
2. A selection function, which chooses the best candidate to be added to the solution
3. A feasibility function, that is used to determine if a candidate can be used to contribute to a
solution
4. An objective function, which assigns a value to a solution, or a partial solution, and
5. A solution function, which will indicate when we have discovered a complete solution
Greedy algorithms produce good solutions on some mathematical problems, but not on others. Most
problems for which they work, will have two properties:
Greedy choice property:-
We can make whatever choice seems best at the moment and then solve the subproblems that
arise later. The choice made by a greedy algorithm may depend on choices made so far but not
on future choices or all the solutions to the subproblem. It iteratively makes one greedy choice
after another, reducing each given problem into a smaller one. In other words, a greedy
algorithm never reconsiders its choices. This is the main difference from dynamic programming,
which is exhaustive and is guaranteed to find the solution. After every stage, dynamic
programming makes decisions based on all the decisions made in the previous stage, and may
reconsider the previous stage's algorithmic path to solution.
Cases of failure:-
For many other problems, greedy algorithms fail to produce the optimal solution, and may even produce
the unique worst possible solution. One example is the traveling salesman problem mentioned above:
4. for each number of cities there is an assignment of distances between the cities for which the nearest
neighbor heuristic produces the unique worst possible tour.
Imagine the coin example with only 25-cent, 10-cent, and 4-cent coins. The greedy algorithm would not
be able to make change for 41 cents, since after committing to use one 25-cent coin and one 10-cent
coin it would be impossible to use 4-cent coins for the balance of 6 cent. Whereas a person or a more
sophisticated algorithm could make change for 41 cents change with one 25-cent coin and four 4-cent
coins.
Give an analysis of Best first search
Best-first search is a search algorithm which explores a graph by expanding the most promising node chosen
according to a specified rule. Judea Pearl described best-first search as estimating the promise of node n by a
"heuristic evaluation function f(n) which, in general, may depend on the description of n, the description of the
goal, the information gathered by the search up to that point, and most important, on any extra knowledge about
the problem domain." Some authors have used "best-first search" to refer specifically to a search with
a heuristic that attempts to predict how close the end of a path is to a solution, so that paths which are judged to
be closer to a solution are extended first. This specific type of search is called greedy best-first search. Efficient
selection of the current best candidate for extension is typically implemented using a priority queue.
The A* search algorithm is an example of best-first search. Best-first algorithms are often used for path finding
in combinatorial search. There are a whole batch of heuristic search algorithm e.g. hill climbing search, best first
search, A*, AO* etc. A* uses a best-first search and finds the least-cost path from a given initial node to one goal
node. It uses a distance-plus-cost heuristic function (usually denoted f(x)) to determine the order in which the
search visits nodes in the tree. The distance-plus-cost heuristic is a sum of two functions:
the path-cost function, which is the cost from the starting node to the current node (usually denoted g(x))
and an admissible "heuristic estimate" of the distance to the goal (usually denoted h(x)).
The h(x) part of the f(x) function must be an admissible heuristic; that is, it must not overestimate the distance to
the goal. Thus, for an application like routing, h(x) might represent the straight-line distance to the goal, since that
is physically the smallest possible distance between any two points or nodes.
If the heuristic h satisfies the additional condition for every edge x, y of the graph
(where d denotes the length of that edge), then h is called monotone, or consistent. In such a case, A* can be
implemented more efficiently—roughly speaking, no node needs to be processed more than once (see closed
set below)—and A* is equivalent to running Dijkstra's algorithm with the reduced cost d'(x,y): = d(x,y) − h(x) + h(y).
We'll describe the best-first algorithm in terms of a specific example involving distances by straight line and by
road from a start point s to a goal point t:
5. Let us define, for any node N, g(N) to be the distance travelled from the start node s to reach N. Note that this is a
known quantity by the time you reach N, but that in general it could vary depending on the route taken through
state space from s to N.
In our example scenario, we don't know the distance by road from N to t, but we do know the straight-line
distance. Let us call this distance h(N). As our heuristic to guide best-first search, we use f(N) = g(N) + h(N). That is,
we will search first from the node that we have found so far that has the lowest f(N).
What is the benefit of preconditioning a problem space? Explain with example
Preconditioning is preparing the problem space before application of the algorithm.
For example: in binary search the searching technique can only be applied on a sorted array. Similarly heap sort
requires data to be organized in the form of heap, before sorting technique can be applied. This is called
preconditioning of the data.
Design a NDF automata or NDFA representing the language over alphabet ={a, b} in which all valid strings have
bb or bab as sub string
a,b a,b
0 b 1 b 3
a b
2
in quick sort average cost is closer to best case than worst case- comment
In quick sort the average case complexity is O(n log n).
The best case is obtained if the pivot point is always the mid position, which gives the complexity O(n log n).
2
The worst case complexity is O(n ) when the array is already sorted.
Hence the average case is closer to the best case
Describe whether or not breadth first search algorithm always finds the shortest path to a selected vertex from
the starting vertex
Algorithm of BFS
procedure BFS(Graph,v):
2 create a queue Q
3 enqueue v onto Q
4 mark v
5 while Q is not empty:
6 t ← Q.dequeue()
7 for all edges e in G.incidentEdges(t) do
8 o ← G.opposite(v,e)
9 if o is not marked:
10 mark o
11 enqueue o onto Q
Limitation of Strassen's Algorithm
From a practical point of view Strassen's Algorithm is often not the method of choice for matrix multiplication for
the following four reasons:
(1) The constant factor hidden in the running time Strassen's Algorithm is lager than the constant factor in
the native (n ) method.
3
6. (2) When the matrices are sparse method tailored for sparse matrices are faster.
(3) Strassen's Algorithm is not quite as numerically stable as the native method.
(4) The sub matrices formed at the level of consume space.
Describe white path property of DFS
In a DFS forest of a (directed or undirected) graph G, vertex v is a descendant of vertex u if and only if at time s[u]
(just before u is colored Gray), there is a path from u to v that consists of only White vertices. Proof there are two
directions to prove.
(=⇒ Suppose that v is a descendant of u. So there is a path in the tree from u to v. (Of course this is also a path in
)
G.) All vertices w on this path are also descendants of u. So by the corollary above, they are colored Gray during
the interval [s[u], f[u]]. In other words, at time s[u] they are all White.
(⇐ Suppose that there is a White path from u to v at time s[u]. Let this path be v0 = u, v1, v2, . . . , vk−1, vk = v
=)
To show that v is a descendant of u, we will indeed show that all vi (for 0 ≤ i ≤ k) are descendants of u. (Note that
this path may not be in the DFS tree.) We prove this claim by induction on i.
Base case: i = 0, vi = u, so the claim is obviously true.
Induction step: Suppose that vi is a descendant of u. We show that vi+1 is also a descendant of u. By the corollary
above, this is equivalent to showing that
s[u] < s[vi+1] < f[vi+1] < f[u] i.e., vi+1 is colored Gray during the interval [s[u], f[u]]. Since vi+1 is White at time s[u],
we have s[u] < s[vi+1]. Now, since vi+1 is a neighbor of vi, vi+1 cannot stay White after vi is colored Black. In other
words, s[vi+1] < f[vi]. Apply the induction hypothesis: vi is a descendant of u so s[u] ≤ s[vi] < f[vi] ≤ f[u], we obtain
s[vi+1] < f[u]. Thus s[u] < s[vi+1] < f[vi+1] < f[u] by the Parenthesis Theorem. QED.
In a quick sort algorithm describe the situation when a given pair of elements will be compared to each other &
when they will not compared to each other
Even if pivots aren't chosen randomly, quicksort still requires only O(n log n) time averaged over all possible
permutations of its input. Because this average is simply the sum of the times over all permutations of the input
divided by n factorial, it's equivalent to choosing a random permutation of the input. When we do this, the pivot
choices are essentially random, leading to an algorithm with the same running time as randomized quicksort.
More precisely, the average number of comparisons over all permutations of the input sequence can be estimated
accurately by solving the recurrence relation:
Here, n − 1 is the number of comparisons the partition uses. Since the pivot is equally likely to fall anywhere in the
sorted list order, the sum is averaging over all possible splits.
This means that, on average, quicksort performs only about 39% worse than in its best case. In this sense it is
closer to the best case than the worst case. Also note that a comparison sort cannot use less
than log 2(n!) comparisons on average to sort n items and in case of large n, Stirling's
approximation yields , so quicksort is not much worse than an ideal
comparison sort. This fast average runtime is another reason for quicksort's practical dominance over other
sorting algorithms.
Among BDS & DFS which technique is used in ignorer traversal a Binary tree & how?
The BFS can be used in order traversal of a Binary tree. BFS is a little like hill climbing, in that it uses an evaluation
function & always chooses the next node to be that with the best score. However it is exhaustive in that it should
eventually try all possible paths. The BFS algorithm was developed to simulate the various client based spiders
developed in earlier studies & were used as benchmark for comparison. The genetic algorithm was adopted to
enhance the global optimal search capability of existing internet spider.
Define pumping lemma for context free grammar
In the theory of formal languages in computability theory, a pumping lemma or pumping argument states that, for
a particular language to be a member of a language class, any sufficiently long string in the language contains a
section, or sections, that can be removed, or repeated any number of times, with the resulting string remaining in
that language. The proofs of these lemmas typically require counting arguments such as the pigeonhole principle.
The two most important examples are the pumping lemma for regular languages and the pumping lemma for
context-free languages. Ogden's lemma is a second, stronger pumping lemma for context-free languages
7. Construct a finite Automata for the language: a*(ab+ba)b*
Construct a non deterministic finite automata represented the language (ab)*(ba)+aa*
Write a Context free grammar for a non null even palindrome
In automata theory a set of all palindromes in a given alphabet is a typical example of a language which is context
free but not regular. The following context free grammar produces all palindromes for alphabet {a, b}:S
a|b|aSa|bSb|(empty)
Discuss how DFS can be search can be used to find cycles in an undirected graph
Given an undirected graph a DFS algorithm construct a directed tree from the root. If there exists a directed path
in the tree from v to w then v is a predecessor of w is a descendant of v. a node adjacency structure is an n*n
matrix such that entry aij=1 if node 1 is adjacent to node j & 0 otherwise. A node edge adjacency structure lists for
each node, the nodes adjacent to it.
Write a recursive procedure to compute the factorial of a given number
int fact(int n)
{
if (n=1)then
{
return 1;
}
else
{
Result=n*fact(n-1);
}
}
Properties of good dynamic programming problem
1. The problem can be divided into stages with a decision required at each stage.
In the capital budgeting problem the stages were the allocations to a single plant. The decision was how
much to spend. In the shortest path problem, they were defined by the structure of the graph. The decision
was to go next.
2. Each stage has a number of states associated with it.
8. The states for the capital budgeting problem corresponded to the amount spent at that point in time. The
states for the shortest path problem were the node reached.
3. The decision at one stage transforms one state into a state in the next stage.
The decision of how much to spend gave a total amount spent for the next stage. The decision of where to
go next defined where you arrived in the next stage.