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

  Write a c program that allows the user to make transactions

Write a C program that allows the user to make some banking transactions. The program should first prompt the user to enter the current balance of his/her bank account (in dollars and cents).

  Compute your bmi by dividing your mass in kilograms

Compute your BMI by dividing your mass in kilograms by the square of your height in meters. Use symbolic constants to represent the various conversion factors.

  Function prototype

Math.Round is an example of a built-in function.

  Program to modify double linked list

Modify Double Linked List code to include following index based access operations.

  Create diffferent variables and constants holding data

Create five diffferent variables and 5 constants holding data that you will display - create and display your full name initials

  Write a program that will find the smallest number

How to do the subsequent program WITHOUT USING Arrays - Write a program that will find the smallest, largest, and average values in a collection of N numbers. Get the value N before scanning each value in the collection of N numbers.

  Linked list program

This lab, along with your TA, will help you navigate through designing, implementing, and testing a dynamic linked list.  Linked lists may be used to implement many real world applications. Recall, linked lists are data structures, which represent co..

  Determine how long the match goes on

Determine how long the match goes on (it might be just N bytes long, or it might extend past the first N matching bytes to be many bytes longer).

  How many times is the copy constructor called

In the subsequent code how many times is the copy constructor called in the given code?

  Cashregister class that can be used with the retailitem clas

Write a CashRegister class that can be used with the RetailItem class that you wrote in Part 1. The CashRegister class should simulate the sale of a retail item. It should have a constructor that accepts a RetailItem object as an argument.

  Identify one practice mentioned in the text and research

Good Programming practices are necessary but different in every environment. Identify one practice mentioned in the text and research some others. What makes these good? Can you think of a reason why one would not use the good practice?

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