



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An assignment for a computer science course, focusing on algorithms and data structures. The assignment includes instructions for writing algorithms for sequential search and binary search in a sorted array and binary search tree, analyzing their time complexities, and implementing merge sort and quicksort algorithms. Additionally, students are asked to extend a binary search tree to include a search function and write a program to detect palindromes using a stack.
Typology: Assignments
1 / 5
This page cannot be seen from the preview
Don't miss anything!




In this programming problem, you are going to implement two general sorting algorithms, Merge sort and Quicksort. The provided skeleton code contains the following files:
Database size: 10 Query size: 10 Time of linear search: 0.016 seconds Time of binary search: 0.0 seconds Correctness of binary search: 10/ In this case the first 5 queries exist in the database ( true ) and the last 5 not ( false ). The correctness is verified in the following way: the driver program first runs all the queries using sequential search (which is assumed to be correctly implemented) and stores the query results as ground-truth. Then it runs all the queries using binary search, and compares the results from both algorithms. It prints on the console Correctness of binary search: X/Y meaning that for X out of Y queries binary search returns the same results as sequential search (and is therefore correct). Of course, if your binary search is correctly implemented, you should get the message with X = Y. As mentioned before, the advantage of binary search becomes more obvious as N (the size of the database) grows. Below is another run using a database file(database100000.txt) of 100000 integers and a query file (queries100000.txt) of 100000 integers: Database size: 100000 Query size: 100000 Time of linear search: 14.735 seconds Time of binary search: 0.125 seconds Correctness of binary search: 100000/ 2.2. Extend the Binary Search Tree you developed in your last assignment and add search feature: add a function in your class called: Search(int value) This function should return true if found else false. You can read the search value from console. Display the result back in console.
Write a program that detects a palindrome using stack. A palindrome is a word, phrase, number or sequence of units that has the property of reading the same in either direction. For example, ABCBA never odd or even Read input from console and display yes if it is a palindrome, else no. Ignore the white spaces while reading the string in your program.