Question

The answer of this question has been attached, and the questions that should be answered is also attached.

The question was:


Write pseudocode for a brute force algorithm for each of the following, and determine its time and space complexity.

1. Determine whether a given Boolean expression is satisfiable.

Notes:

  1. A.) A Boolean expression is one written using only the three Python connectives (and, or, not), and variables ranging over True and False, and parentheses.
  2. B.) A Boolean expression is satisfiableif there is a substitution of values for its variables that makes it true.
  3. C.) Operations available:
  1. a.) vars(E) gives a list of the variables occurring in Boolean Expression E
  2. b.)val(E) gives the value of a ground Boolean expression (that is, one written with True,False, and, or, not and parentheses)
  3. c.) sub(V,X,E) returns the result of substituting value V for variable X in expression E
  4. d.) basic list operations are available


Please check the attachment file.

The problem is that I don't know how to calculate the time and space complexty for the algorithm that attached, and I don't know how to determine the size of input and the number of operation of this algorithm to find out the time comlexity?

Also, how can I prove that answers!


Fune isSatsfiable (E) if Len (L)-O else Yetum (iSatsfable (sub (true,V, E))or isSatisfable (sub (false, v, E) D what is He time and Space Corplexity fr this 2) what is the Size of Impuk ? ② what is number of operation ? Aj How to determine the time Covmple h of this agoritles ?
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Time Complexity: Assume there are N elements in the array. Let's call this array A.
Suppose counting starts from 1 and goes till N.
So, A[1] = first element
A[2] = second element and so on....

In brute force, you'll pick one element and compare it with all the other elements and will perform either of 2 options- swap or nothing. No matter what you do, you'll compare 1 element with rest of the elements i.e N-1.

So, for A[1], check for all elements.
for A[2], check for all elements.
and so on....

So it will be N*N = O(N^2).

Add a comment
Know the answer?
Add Answer to:
Question The answer of this question has been attached, and the questions that should be answered...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Program by force brute in (c++ or java language )

    The question of validity is to answer the question of whether for a Boolean expression consisting of n variables . There is a combination of values of variables that make the result of the expression true or not. In this phrase each The variable can be simple or contradictory. Force brute method of all compounds . Creates and evaluates the possible and the first time the result is true (if it is) the answer to the problem Come and stop...

  • true and false propositions with quantifiers. Answer the following questions in the space provided below. 1....

    true and false propositions with quantifiers. Answer the following questions in the space provided below. 1. For each proposition below, first determine its truth value, then negate the proposition and simplify (using De Morgan's laws) to eliminate all – symbols. All variables are from the domain of integers. (a) 3.0, x2 <. (b) Vr, ((x2 = 0) + (0 = 0)). (c) 3. Vy (2 > 0) (y >0 <y)). 2. Consider the predicates defined below. Take the domain to...

  • Answer the following questions in the space provided below. 1. For each proposition below, first determine...

    Answer the following questions in the space provided below. 1. For each proposition below, first determine its truth value, then negate the proposition and simplify (using DeMorgan's laws) to eliminate all – symbols. All variables are from the domain of integers. (a) 3x, 22 <2. (b) Vx, ((:22 = 0) + (x = 0)). (e) 3xWy((x > 0) (y > 0 + x Sy)). 2. Consider the predicates defined below. Take the domain to be the positive integers. P(x): x...

  • Your teacher is going to give a test where each student is to answer one question. None of the neighboring students should have the same question. How many questions are needed? Graph Coloring Algorit...

    Your teacher is going to give a test where each student is to answer one question. None of the neighboring students should have the same question. How many questions are needed? Graph Coloring Algorithm is used to solve this type of problems. It does not guarantee to use the minimum number of questions, but it guarantees an upper bound on the number of questions. The algorithm never uses more than d+1 questions where d is the maximum degree of vertices...

  • Question 1 (10 Marks) This question consists of 10 true false ansers. In cach ease, answer true i...

    Question 1 (10 Marks) This question consists of 10 true false ansers. In cach ease, answer true if the statement is always true and false otherise. If a statement is false, 1. The set rER0 isa group under the binary operation o defined ad-be is a group under matrix addition. 3. Tho sot eRzs not an Abelian group under the binary erplain why. There is no need to show working for true statements. by a ob vab. 2. The set...

  • 1. Warshall's Algorithm To which other algorithm from our course is Wasrhall's Transitive Closure algorithm most...

    1. Warshall's Algorithm To which other algorithm from our course is Wasrhall's Transitive Closure algorithm most structurally similar? A) Dijkstra B) Floyd C) Kadane D) Karatsuba E) Kruskal F) Prim G) Strassen 2. Powers of Adjacency Matrix Which is true of an Adjacency Matrix of a directed graph raised to the k-th power (A^k) A) A^k ​[i]​[j] = 1 if there is an edge of length k from vertex i to vertex j B) A^k ​[i]​[j] = 1 if there...

  • Please use the JAVA code attached as an input to the program that must be created...

    Please use the JAVA code attached as an input to the program that must be created IN JAVA. Instructions of the program: java code: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * */ import java.util.Random; public class Rand_Z3_Exp { /** * @param args the command line arguments */ public static void main(String[] args) {...

  • Please use the JAVA code attached as an input to the program that must be created IN JAVA. Instru...

    Please use the JAVA code attached as an input to the program that must be created IN JAVA. Instructions of the program: java code: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * */ import java.util.Random; public class Rand_Z3_Exp { /** * @param args the command line arguments */ public static void main(String[] args) {...

  • This was the answer I got, teacher said it was wrong Teacher said, couldnt run the...

    This was the answer I got, teacher said it was wrong Teacher said, couldnt run the gate because there wasnt any switches 5. Design and test a simplified logic circuit to identify all numbers in the output range of function: F(x) = 2x+3 for an input domain between 0 and 6. Be sure to include your truth table. Normal 1 No Spac... Heading 1 Head Paragraph Styles t Draw Simulate View Window Help 39 ) ) 11:55 1 esu.desire2learn.com Boolean...

  • any of these questions answered would help 22. A circuit is attached to a, your "A"...

    any of these questions answered would help 22. A circuit is attached to a, your "A" value. V battery and is found to have a current of. your "B" value, amps. What is the electrical resistance of the circuit? 23. What would be the current in a circuit that has an electrical resistance of, your "C" value, 12 connected to a, your "A" value, V battery? 6V 22 < 4V 24. In which diagram above will the current through the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT