locked
Need Code for the Below C# query RRS feed

  • Question

  • You are given the following method signature:

    public static int[] MergeAndReorder(int[] a, int[] b) { }

    Arrays a and b are both already sorted in ascending order. 
    How can we return the union of all elements in a and b, sorted in descending order. 
    You may not use any native sorting functionality of C#, such as SortedList or .OrderBy(). 
    Your variables may only be primitives (and obviously an integer array for the result).
     
    Any one good in programming help  me to do this

    C

    Friday, August 17, 2012 7:16 AM

Answers

  • Hi,

    sorry, but that sounds liek you are looking for someone to do your homework. And this is not, what these forums are made for.

    If you attend to a class where you learn c# - please do the homework on your own. It is meant as a check that you understood what was part of the class. If you are unable to do your homework: tell your teacher. He might explain the missing parts to you or to the whole class again.

    But of course: You are welcome in this forum. If you have a problem: feel free to ask for help. But please try to solve it on your own first and then tell us, where you had problems. What did you try that didn't work? We will be glad if we could help you and maybe explain some parts to you.

    But please: Do not just ask for others doing your homework!

    (Sorry, if I got you wrong, but that was, what I saw in your post!)

    With kind regards,

    Konrad

    • Marked as answer by Mike Feng Thursday, September 6, 2012 3:14 AM
    Friday, August 17, 2012 8:28 AM
  • Just do what the function name says "Merge And Reorder"

    Create an output array that is size (a.Length + b.Length)

    Walk through the two arrays, moving the lesser values first to the output array.

    Array.Reverse(outputArray)

    return outputArray


    Dan Randolph - My Code Samples List

    • Marked as answer by Mike Feng Thursday, September 6, 2012 3:14 AM
    Sunday, August 19, 2012 10:39 PM

All replies

  • Hi,

    sorry, but that sounds liek you are looking for someone to do your homework. And this is not, what these forums are made for.

    If you attend to a class where you learn c# - please do the homework on your own. It is meant as a check that you understood what was part of the class. If you are unable to do your homework: tell your teacher. He might explain the missing parts to you or to the whole class again.

    But of course: You are welcome in this forum. If you have a problem: feel free to ask for help. But please try to solve it on your own first and then tell us, where you had problems. What did you try that didn't work? We will be glad if we could help you and maybe explain some parts to you.

    But please: Do not just ask for others doing your homework!

    (Sorry, if I got you wrong, but that was, what I saw in your post!)

    With kind regards,

    Konrad

    • Marked as answer by Mike Feng Thursday, September 6, 2012 3:14 AM
    Friday, August 17, 2012 8:28 AM
  • Just do what the function name says "Merge And Reorder"

    Create an output array that is size (a.Length + b.Length)

    Walk through the two arrays, moving the lesser values first to the output array.

    Array.Reverse(outputArray)

    return outputArray


    Dan Randolph - My Code Samples List

    • Marked as answer by Mike Feng Thursday, September 6, 2012 3:14 AM
    Sunday, August 19, 2012 10:39 PM