Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask C/C++ Expert


Home >> C/C++

Merge - Arrays

In a merge sort, you create ever smaller arrays of items and then merge them to create a final, fully sorted array. In this challenge, you will have two sorted arrays that must be merged to form a single, sorted array. Each of the arrays will be sorted in non-decreasing order.

As an example, consider the arrays a = [1, 2, 3] and b = [2, 5, 5]. Merge the arrays to create array c as follows:

a[0] < b[0] → c = [a[0]] = [1]
a[1] = b[0] → c = a[0], b[0]] = [1, 2]
a[1] < b[1] → c = [a[0], b[0], a[1] = [1, 2, 2]
a[2] < b[i] → c = [a[0], b[0], a[1], a[2] = [1, 2, 2, 3]
No more elements in a → c = a[0], b[0], a[1], a[2], b[1], b[2] = [1, 2, 2, 3, 5, 5]

Elements were alternately taken from the arrays in the order given, maintaining precedence.

Function Description

Complete the function mergeArrays in the editor below. The function must return an array of all the elements from both input arrays in non-decreasing order.

mergeArrays has the following parameter(s):

a[a[0],...a[n-1]]: a sorted array of integers

b[b[0],...b[n-1]]: a sorted array of integers

Lonely Integer

Consider an array of n integers, arr = [a0, a1, ...an-1, where all but one of the integers occur in pairs. In other words, every element in arr occurs exactly twice except for one unique element.

Complete the lonelyinteger function in the editor below. It has one parameter: an array of integers, arr. The function must find and return an integer denoting the unique element in array arr.

Input Format
Locked stub code in the editor reads the following input from stdin and passes it to the function:

The first Line contains an integer, n, denoting the number of elements in arr.

Each line i of the n subsequent lines (where 0 ≤ i ≤ n) contains an integer describing element 0

Constraints
• 1 ≤ 100
• n is odd.
• 0 ≤ a1 ≤ 100, where 0 ≤ i < n

Output Format

The function must return an integer denoting the unique element in the array. This is printed to stdout by locked stub code in the editor.

Sherlock and The Beast

Sherlock Holmes and his dear friend Dr. Watson are working on an urgent problem. Watson had earlier learned through his ''special relationship'' contacts at MI6 that that the CIA has lately been facing weird problems with their supercomputer, The Beast'. Then, Sherlock received a note from Professor Moriarty, his archenemy, boasting that he has infected 'The Beast' with a virus.

Now, all of Sherlock's past efforts to subdue Moriarty had been in vain, but the note gave him new hope to finally triumph over his nemesis. You see, the note had been written on a piece of paper previously sat on Moriaty's desk under another piece of paper. Unbeknownst to anyone but the intrepid Sherlock Holmes, it had an impression of a number N on it. After following up with more clues from his past experience with Moriarty, Sherlock figured out that the key to remove the virus is the largest 'Decent' Number having N digits.

A 'Decent' Number has -
1. Only 3 and 5 as its digits.
2. The number of times 3 appears is divisible by 5.
3. The number of times 5 appears is divisible by 3.

Meanwhile, the trigger date of the virus to completely wipe the disk and burn out the processors of The Beast' is fast approaching. Can you save The Beast', and find the key for Sherlock?

Input Format
The first line will contain an integer T, the number of test cases. This is followed by T lines, each containing an integer N i.e the number of digits in the number

Attachment:- Testcases.zip

C/C++, Programming

  • Category:- C/C++
  • Reference No.:- M92775232
  • Price:- $35

Priced at Now at $35, Verified Solution

Have any Question?


Related Questions in C/C++

Software development fundamentals assignment 1 -details amp

Software Development Fundamentals Assignment 1 - Details & Problems - In this assignment, you are required to answer the short questions, identify error in the code, give output of the code and develop three C# Console P ...

Assign ment - genetic algorithmin this assignment you will

ASSIGN MENT - GENETIC ALGORITHM In this assignment, you will use your C programming skills to build a simple Genetic Algorithm. DESCRIPTION OF THE PROGRAM - CORE REQUIREMENTS - REQ1: Command-line arguments The user of yo ...

There are several ways to calculate the pulse width of a

There are several ways to calculate the pulse width of a digital input signal. One method is to directly read the input pin and another method (more efficient) is to use a timer and pin change interrupt. Function startTi ...

Why do researcher drop the ewaste and where does it end

Why do researcher drop the ewaste and where does it end up?

1 implement the binary search tree bst in c using the node

1. Implement the Binary Search Tree (BST) in C++, using the Node class template provided below. Please read the provided helper methods in class BST, especially for deleteValue(), make sure you get a fully understanding ...

Assignment word matchingwhats a six-letter word that has an

Assignment: Word Matching What's a six-letter word that has an e as its first, third, and fifth letter? Can you find an anagram of pine grave. Or how about a word that starts and ends with ant (other than ant itself, of ...

What are the legal requirements with which websites must

What are the legal requirements with which websites must comply in order to meet the needs of persons with disabilities? Why is maximizing accessibility important to everyone?

Question 1find the minimum and maximum of a list of numbers

Question: 1. Find the Minimum and Maximum of a List of Numbers: 10 points File: find_min_max.cpp Write a program that reads some number of integers from the user and finds the minimum and maximum numbers in this list. Th ...

Project - space race part a console Project - Space Race Part A: Console Implementation

Project - Space Race Part A: Console Implementation INTRODUCTION This assignment aims to give you a real problem-solving experience, similar to what you might encounter in the workplace. You have been hired to complete a ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As