You have to write your code in C++ (as a cpp file) and prepare a docx file that formally explains the complexity of your implemented algorithm (using recurrence relations). For details, please read the questions carefully.
Question 1:
Use a divide and conquer approach based algorithm that finds the largest item in a given array of size n. Analyze your algorithm and show the complexity by solving its recurrence relation (cpp file for the code and a docx file for the complexity analysis).
C++ CODE (cpp file)
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
// Divide & Conquer solution to find minimum and maximum
number in an array
void find_Max(int arr[], int low, int high, int& max)
{
// if array contains only one element
if (low == high) // common comparison
{
if (max < arr[low]) // comparison 1
max = arr[low];
return;
}
// if array contains only two elements
if (high - low == 1) // common comparison
{
if (arr[low] < arr[high]) // comparison 2
{
if (max < arr[high]) // comparison 3
max = arr[high];
}
else
{
if (max < arr[low]) // comparison 4
max = arr[low];
}
return;
}
// find mid element
int mid = (low + high) / 2;
// recur for left sub-array
find_Max(arr, low, mid, max);
// recur for right sub-array
find_Max(arr, mid + 1, high, max);
}
int main()
{
cout<<"Enter the number of elements\n";
int n;
cin>>n;
cout<<"\nEnter the elements\n";
int arr[n];
for(int i=0;i<n;i++)
cin>>arr[i];
int max = INT_MIN;
find_Max(arr, 0, n - 1, max);
cout<<"\nThe maximum element in the array is " <<
max;
cout<<endl;
return 0;
}
IMAGE OF OUTPUT

COMPLEXITY ANALYSIS (Docx file)

Using master theorem to solve the complexity of the algorithm. We have,
T(n) = 2T(n/2) +1 (recurrence formula for the algorithm used)
Here, a = 2 , b = 2 , k = 0 and c = 1
So, a > bk (condition 3 holds true) - as 2 > 1
Thus,
=> T(n) ~ nlog22
=> T(n) ~ n
Time complexity of the algorithm is O(n).
You have to write your code in C++ (as a cpp file) and prepare a docx...
(13 pts) Given an array AlI,2,. .. ,n] integers, design and analyze an efficient Divide-and-Conquer algorithm to find some i and j, where j > 1, such that A[j]-Ali] is maximized. For example, given A 6, 1,3,8,4,5, 12,6], the maximum value of AL] - Ali] for j > i is 12-1 11 where j -7 and i 2. Give the underlying recurrence relation for your algorithm and analyze its running time. You should carefully state all details of your algorithm:...
Assignment on Java programing 1. Write programs for the following exercises in Java. Each file should have short description of the implemented class and for files with main method the problem it is solving. Make sure your files have appropriate names. Programs should write output to the Console. b) BST: Implement Binary Search Tree ADT with insert(int key), delete(int key), Node find(int key), and in-order traverse() where it prints the value of the key. Your operations should use recursion. The...
Use C++
For this week’s lab you will write a program to read a data file
containing numerical values, one per line. The program should
compute average of the numbers and also find the smallest and the
largest value in the file. You may assume that the data file will
have EXACTLY 100 integer values in it. Process all the values out
of the data file. Show the average, smallest, largest, and the name
of the data file in the...
Programming in C/C++ Submit your source code files (all .h and .cpp files) NO GLOBAL VARIABLES Program: Use operator overloaded functions for a birthday club – Based on Chapter 11 lecture (25 pts) Make a class called Birthday that will have a date of month, day, and year and the name. Need to have overloaded operators to compare values along with regular functions like: Overload operator == that takes a Birthdate, compares against the current date values, and returns a...
guys can you please help me to to write a pseudo code for this
program and write the code of the program in visual studio
in.cpp.
compile the program and run and take screenshot of the output
and upload it. please help is really appreciated.
UTF-8"CPP Instruction SU2019 LA X 119SU-COSC-1436- C Get Homework Help With Che X Facebook -1.amazonaws.com/blackboard.learn.xythos.prod/584b1d8497c84/98796290? response-content-dis 100% School of Engineering and Technology COSC1436-LAB1 Note: in the instruction of the lab change "yourLastName" to your last...
Using C programming For this project, you have been tasked to read a text file with student grades and perform several operations with them. First, you must read the file, loading the student records. Each record (line) contains the student’s identification number and then four of the student’s numerical test grades. Your application should find the average of the four grades and insert them into the same array as the id number and four grades. I suggest using a 5th...
please write the code in C++ Implement the BinarySearchTree ADT in a file BinarySearchTree.h exactly as shown below. // BinarySearchTree.h // after Mark A. Weiss, Chapter 4, Dr. Kerstin Voigt #ifndef BINARY_SEARCH_TREE_H #define BINARY_SEARCH_TREE_H #include <cassert> #include <iostream> using namespace std; template <typename C> class BinarySearchTree { public: BinarySearchTree( ) : root{ nullptr } { } ~BinarySearchTree( ) { makeEmpty(); } const C & findMin( ) const { assert(!isEmpty()); return findMin( root )->element; } const C & findMax( ) const...
Write a program that demonstrates use of programmer - defined
data structures. Please provide code! Thank you.
Here are the temps given:
January 47 36
February 51 37
March 57 39
April 62 43
May 69 48
June 73 52
July 81 56
August 83 57
September 81 52
October 64 46
November 52 41
December 45 35
Janual line Iranin Note: This program is similar to another recently assigned program, except that it uses struct and an array of...
I
need help writing this code in C++
Proj11.cpp is provided as well as the randomdata.txt
thank you in advance!
Objectives: The main objectives of this project is to introduce you to recursion, and test your ability to work with some STL functionalities. A review of your knowledge on working with templates, dynamic data structures, as well as manipulating dynamic memory, classes, pointers and iostream to all extents, is also included. Description: For the entirety of this project, you will...