1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
lana66690 [7]
3 years ago
10

write a function that takes two integer arrays as input return true if any two of the numbers in the first array input add up to

any of the numbers in the second array tests return false
Computers and Technology
1 answer:
Afina-wow [57]3 years ago
8 0

Answer:

Explanation:

This program is written in Python. It is a function that takes in two arrays. Then it loops through the first array twice, adding each element with the others and comparing the sum to the values in the second array. If a similar value is found in the second array, the program prints out the value and returns True to the user. Otherwise, it returns False. A test case has been created with two array variables that print out False, the output can be seen in the attached image below.

def sumArray(arr1, arr2):

   for i in range(len(arr1)):

       for x in range(len(arr1)):

           sum = 0

           if i != x:

               sum = arr1[i] + arr1[x]

           if sum in arr2:

               print(str(sum) + "Found in Second Array")

               return True

   return False

arr1 = [1, 9, 10, 44]

arr2 = [2, 4, 8, 14]

print(sumArray(arr1, arr2))

You might be interested in
Who is the CEO of Quora?
irina [24]
Adam D'Angelo is the CEO and co-founder of Quora, an online knowledge market. He was also chief technology officer and <span>vice president of engineering for Facebook.</span>
5 0
2 years ago
Programming challenge description: Given a string comprising just of the characters (,),{,},[,] determine if it is well-formed o
nadezda [96]

Answer:

Employing Java language,

Explanation:

//for using stack data structure

import java.util.Stack;

//class definition

public class BracketMatch {

   //function to find the string is well formed or not

   public static boolean isWellFormed(String str) {

       //variable to store the character value

       char ch;

       //check if the first character itself is the end of the brackets

       if (str.charAt(0) == ')'||str.charAt(0) =='}'||str.charAt(0) ==']')

           return false;

       //creating a stack of character type

       Stack<Character> stack = new Stack<Character>();

       //iterating through the characters in string

       for(int i=0; i < str.length(); i++) {

           //storing the current character from the string in the variable

           ch = str.charAt(i);

           if(ch == '('||ch=='{'||ch=='[')

               //if the character is starting of the brackets push it into stack

               stack.push(ch);

           else if(ch == ')')

               //if it is closing bracket and the stack is empty then the string is not well formatted

               if(stack.empty())

                   return false;

               else if(stack.peek() == '(')

                   stack.pop();

               else

                   return false;

           else if(ch == '}')

               if(stack.empty())

                   return false;

               else if(stack.peek() == '{')

                   stack.pop();

               else

                   return false;

       }

       //returning the stack content, if the string will be well formed the stack would be empty

       //after all the operations

       return stack.empty();

   }

   //main method

   public static void main(String[] args) {

       //calling function to find if the string is welll formatted or not

       System.out.println(isWellFormed("{}"));

       //calling function to find if the string is welll formatted or not

       System.out.println(isWellFormed("([)]"));

   }

}

5 0
3 years ago
Two routers, R1 and R2, connect using an Ethernet over MPLS service The service provides point-to-point service between these tw
liberstina [14]

Answer: b) R1 will connect to a physical Ethernet link, with the other end of the cable connected to a device at the WAN service provider point of presence.

.d) R1 will forward data link frames to R2 using an Ethernet header/trailer.

Explanation:

Here we have to understand what is MLPS. MLPS is a protocol which identifies the shortest route for the transfer of messages between routers instead of the longest route.

Here we are given a WAN which is a wide area network. Using layer 2 Ethernet service the frames are transmitted across the routers within the WAN.

Option A is incorrect as as connecting the other end of the cable to the R2 would reduce the functionality of the WAN.  Option C is incorrect as HDLC header trailer has no effect.

Option B and D are correct as Ethernet header/ trailer has the same size every frame and to maintain the functionality of the WAN one end must be connected to point of presence(PoP).  

5 0
3 years ago
Andrew’s Complete Cameras offers its customers an interactive website to help them choose the best camera for their lifestyle. B
julsineya [31]

Answer:

The correct answer is letter "A": Engage.

Explanation:

Social media has gained importance not only as an informative medium but as a means for marketing. The 4E framework states the four basic characteristics social media advertisement should fulfill. Those components are:

  • Excite.<em> Provide customers attractive offers.</em>
  • Educate.<em> Give consumers information about the product and the offering.</em>
  • Experience.<em> Allow direct or indirect interaction with the good.</em>
  • <u>Engage</u>.<em> Involve customers in activities related to the product that transcend the simple buying of the good.</em>
8 0
3 years ago
What is the purpose of saving code snippets?
Brrunno [24]

Answer:

A stores code for later re-use

Explanation:

To find - What is the purpose of saving code snippets?

Solution -

Code Snippet" is used to describe a small portion of re-usable source code, machine code, or text.

They allow a programmer to avoid typing repetitive code during the course of routine programming.

So,

The correct option is - A stores code for later re-use

4 0
3 years ago
Other questions:
  • What type of restrictions may be placed on your license?
    7·1 answer
  • Wireless networks are the most difficult type of network to set up <br> true or false
    15·1 answer
  • . Why should we favor programming to interfaces over implementations?
    6·1 answer
  • When using a file name you have to use only lower case letters<br>true or false
    11·1 answer
  • A form’s height is ______________________.<br><br> A property<br><br> A method<br><br> An event
    10·1 answer
  • Which of the following refers to a collection of colors, fonts, and effects that can be
    6·1 answer
  • __________ are hosted on dedicated computers known as 'web servers'.​
    8·2 answers
  • Research for a project should be based on?
    7·2 answers
  • Which sentence is correctly punctuated? WILL GIVE YU MONEY GIVE ME YOUR CASH APP PLS
    12·2 answers
  • A chemical mixture that is burned to produce thrust. (Jet engine homework)
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!