Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the following 3 functions and put your code for 3 functions in a single file called homework 2 . cpp . Function 1 :

Implement the following 3 functions and put your code for 3 functions in a single file called homework2.cpp. Function 1: int out_of_order(int a[,int n);
This function returns the number of out order pairs in an array a of size n. Example 1 : input: a=[3,1,2],n=3 return: 2(there are 2 pairs that are out of order: (3,1) and (3,2)) Example 2: input: a=[1,2,3,4,5],n=5 return: 0(all pairs are in order) Example 3 : input: a=[1,5,3,2],n=4 return: 3(there are 3 pairs that are out of order: (5,3),(5,2),(3,2))
Function 2: string binary_to_hex(const string& s);
this function converts a binary string s into a hexadecimal string Example 1: input: s="11010" return: "1a" Example 2: input: s="111000011111" return: "e1f"
Function 3: void shift_, int n); ?*********** This function shifts all 0 to the end of array a while keeping non-0 numbers in the same order. Change the array a in place. Don't create a new array. Example 1: input: a=[1,0,2,0,3],n=5 output: a=[1,2,3,0,0] Example 2: input: a=[0,2,0,0,1,3],n=6 output: a=[2,1,3,0,0,0]
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

T Sql Fundamentals

Authors: Itzik Ben Gan

4th Edition

0138102104, 978-0138102104

More Books

Students also viewed these Databases questions

Question

Define organisational structure

Answered: 1 week ago

Question

Define line and staff authority

Answered: 1 week ago

Question

Define the process of communication

Answered: 1 week ago

Question

Explain the importance of effective communication

Answered: 1 week ago

Question

* What is the importance of soil testing in civil engineering?

Answered: 1 week ago