Create ever smaller arrays of items

Assignment Help C/C++ Programming
Reference no: EM131936576

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

Verified Expert

This assignment consists of three java programs, which all depends on the usage of arrays in java .These problems were designed to enrich the knowledge of application of arrays in java. The first program is about the sorting (merge sorting) technique with java. Second, one use the concept of traversing through an array. Finally, the third program is about manipulating the array contents.

Reference no: EM131936576

Questions Cloud

Calculate the increase or decrease in bond value : Assume that coupon interest payments are made semiannually and that par value is $1,000 for both bonds. Calculate the values of Bond A and Bond B.
How much money will his daughter have : How much must you invest at 10% interest in order to see your investment grow to $30,000 in 12 years?
Shielded from liability by the firm : Backus sued the firm and Holden personally, but the latter claimed he was shielded from liability by the firm. Is Holden correct?
Write a program that plays with the user the game : Write a program that plays with the user the game commonly known as Twenty Questions. Also the program will learn and improve from playing each game.
Create ever smaller arrays of items : 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
Sought judgment against them personally : Jacobsen and Kelly agreed to form an LLC. They filled out the appropriate paperwork and mailed it with their check to the secretary of state's office.
What impact would this change have on the assets return : If the market increased by 12% and the return increased by exactly the same amount, what would the new beta for this asset be?
Percent annual interest rate : If you are 30 today, how much must you save each year to meet your retirement goal if you plan to retire at 65?
What will one share of common stock be worth : What will one share of this common stock be worth 10 years from now if the applicable discount rate is 8.0 percent?

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd