Computer Networking: A Top-Down Approach (7th Edition)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN: 9780133594140
Author: James Kurose, Keith Ross
Publisher: PEARSON
Bartleby Related Questions Icon

Related questions

Question

Create a function called mergeAndSeparate which performs the following tasks:

  • Accepts two numpy arrays, aLeft and aRight
  • Creates and returns three numpy arrays, left, right, and both
    • both contains the elements in the arrays which match on value and position
      • If aLeft = [1 2 4 4] and aRight = [1 6 5 4] then both should contain [1 4] (the first and last elements)
    • left contains all of the elements in aLeft not matched in aRight
      • In our previous example, left should contain [2 4], the middle two elements
    • right contains all of the elements in aRight not matched in aLeft
      • In our previous example, right should contain [6 5], the middle two elements
  • Your code should use only numpy operations
    • No loops. No if statements
  • The function should not print anything
  • You may assume that the input arrays are 1-dimensional and that they are the same length, but you do not know in advance how long they will be
  • You may assume numpy has already been imported

Hints:

  • My solution is 5 lines long, not counting the function definition
    • Yours doesn't need to be, but it should be fewer than 10 lines
  • Numpy's equivalent to notis the tilde: ~ (it's on the left of the 1 key on most keyboards)
    • That is, if you want to say "not x" in numpy, you say "~x"
    • solve in python
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Similar questions
    SEE MORE QUESTIONS
    Recommended textbooks for you
    Text book image
    Computer Networking: A Top-Down Approach (7th Edi...
    Computer Engineering
    ISBN:9780133594140
    Author:James Kurose, Keith Ross
    Publisher:PEARSON
    Text book image
    Computer Organization and Design MIPS Edition, Fi...
    Computer Engineering
    ISBN:9780124077263
    Author:David A. Patterson, John L. Hennessy
    Publisher:Elsevier Science
    Text book image
    Network+ Guide to Networks (MindTap Course List)
    Computer Engineering
    ISBN:9781337569330
    Author:Jill West, Tamara Dean, Jean Andrews
    Publisher:Cengage Learning
    Text book image
    Concepts of Database Management
    Computer Engineering
    ISBN:9781337093422
    Author:Joy L. Starks, Philip J. Pratt, Mary Z. Last
    Publisher:Cengage Learning
    Text book image
    Prelude to Programming
    Computer Engineering
    ISBN:9780133750423
    Author:VENIT, Stewart
    Publisher:Pearson Education
    Text book image
    Sc Business Data Communications and Networking, T...
    Computer Engineering
    ISBN:9781119368830
    Author:FITZGERALD
    Publisher:WILEY