Question

In: Computer Science

a.) What are the tight lowerbound of the comparison based sorting problem and searching problem respectively....

a.) What are the tight lowerbound of the comparison based sorting problem and searching problem respectively.

b.) True or False: A P problem is one that can be solved in polynomial time. while a NP problem is one that cannot be solved in polynomial time.Tell the relationship between P and NP problems

Solutions

Expert Solution

Answer to a:

Comparison based sorting can be viewed abstractly as a decision tree problem. Let us assume is as a full binary tree. Each leaf of the decision tree will correspond each of the n! permutations of the n numbers. Each internal node will be a comparison between ai and aj element of the list. Left subtree dedicates subsequent consequences if ai <= aj. The right subtree will dedicate subsequences for ai > aj.

Let x be the maximum number of comparisons. So x is the height of the tree. So with maximum of leaves.

Now,

n! <=

Taking log2 on both sides

log2(n!) <= x

Since log2(n!) = (nlog2n)

So we can say lower bound is (nlog2n)

The tight lower bound cost of searching algorithm is O(n) when the list is unsorted. Because to search we need to travel the entire list, otherwise we can not make the comparison. Now, if the list is sorted, then the lowest bound is O(log n).

Answer to b:

The statement is FALSE.

P problem can be solved in polynomial time.

NP problem(stands for Non deterministic polynomial) is solvable in polynomial time in non deterministic Turing machine.

Every decision problem that is solved by a deterministic polynomial time algorithm is also solved by a polynomial time non deterministic algorithm.

All P problems are solved in Polynomial time, whereas NP-P are intractable.

It is not known if P=NP. If P NP, then P is a subset of NP.


Related Solutions

(Lower bound for searching algorithms) Prove: any comparison-based searching algorithm on a set of n elements...
(Lower bound for searching algorithms) Prove: any comparison-based searching algorithm on a set of n elements takes time Ω(log n) in the worst case. (Hint: you may want to read Section 8.1 of the textbook for related terminologies and techniques.)
Problem Description Objective This practical will test your knowledge on sorting and searching algorithms. In this...
Problem Description Objective This practical will test your knowledge on sorting and searching algorithms. In this practical, you will be implementing a number of algorithms. Each of these algorithms will be constructed in a different class. You should make sure that you know the complexity of the algorithms you implement. Design Think of how you are going to solve the problem and test your implementation with the test cases you designed based on the stages below. Testing Hint: it’s easier...
Describe what are sorting and searching, and why are they essential in a computer science field....
Describe what are sorting and searching, and why are they essential in a computer science field. Give two examples when sorting and searching are necessary in designing software applications. Describe three different types of existing sorting algorithms and two types of searching algorithms. Justify, compare and contrast your choice of sorting and searching algorithms. Include one example of sorting or searching program. You may use a program you discover on the Internet as an example. Please make sure to give...
IN JAVA Searching and Sorting In An Integer List File IntegerList contains a Java class representing...
IN JAVA Searching and Sorting In An Integer List File IntegerList contains a Java class representing a list of integers. The following public methods are provided: ? IntegerList(int size)—creates a new list of size elements. Elements are initialized to 0. ? void randomize()—fills the list with random integers between 1 and 100, inclusive. ? void print()—prints the array elements and indices ? int search(int target)—looks for value target in the list using a linear (also called sequential) search algorithm. Returns...
Java Searching and Sorting, please I need the Code and the Output. Write a method, remove,...
Java Searching and Sorting, please I need the Code and the Output. Write a method, remove, that takes three parameters: an array of integers, the length of the array, and an integer, say, removeItem. The method should find and delete the first occurrence of removeItem in the array. If the value does not exist or the array is empty, output an appropriate message. (After deleting an element, the number of elements in the array is reduced by 1.) Assume that...
For your initial post, utilizing credible sources, describe the various types of sorting and searching algorithms...
For your initial post, utilizing credible sources, describe the various types of sorting and searching algorithms and give an example of each other than the examples provided in the assigned readings. Apply algorithmic design and data structure techniques in developing structured programs by discussing time and space complexity in relation to whether using a sort algorithm is better than using a search algorithm. Does it really matter with the capabilities of computers today? Provide justification to support your answers.
Purpose This project is meant to give you experience with sorting, binary searching, and Big-Oh complexity....
Purpose This project is meant to give you experience with sorting, binary searching, and Big-Oh complexity. Objective "Write in Java please" Your goal is to take a book, as a large text file, and build a digital “concordance”. A concordance is like an index for a book in that it contains entries for words in the book, but it also includes passages from the book containing that word. For example, a query for the word Dormouse in Alice in Wonderland...
Comparison of absortion costing and activity based costing systems Through an optimization problem.
Comparison of absortion costing and activity based costing systems Through an optimization problem.
Write a C++ program to compare those two searching algorithms and also compare two sorting algorithms....
Write a C++ program to compare those two searching algorithms and also compare two sorting algorithms. You need to modify those codes in the book/slides to have some counters to count the number of comparisons and number of swaps. In the main function, you should have an ordered array of 120integers in order to test searching algorithms, and the other two identical arrays of 120integers not in order to test sorting algorithms. Display all counters in the main functions.Counter for...
Write a program to compare those two searching algorithms and also compare two sorting algorithms. You...
Write a program to compare those two searching algorithms and also compare two sorting algorithms. You need to modify those codes in the book/slides to have some counters to count the number of comparisons and number of swaps. In the main function, you should have an ordered array of 120 integers in order to test searching algorithms, and the other two identical arrays of 120integers not in order to test sorting algorithms. Display all counters in the main functions. Counter...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT