{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Section6Problems 3 - that rearranges Write a method split...

Info icon This preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
./. Write a method split that rearranges the elements of a list of int.egers so ,/ t.hat al-l- of the negative val-ues appear before aII of the nonneoar'i rrpq tror example, if you have a variable called list that stores t.he following sequence of values: [8, 1, -4, l.9, 0, 43, -8, -1, 2] then the calL: Iist. split O ; shoul-d rearrange the list to put the negatives first. One possible arrangement would be as follows: l-4, -8, -7, 8, 1, 19, O, 43, 2l It matters onJ-y that the negatives appear bef ore the nonn€gatives. So thj-s ic nnlrr ^ne possible soluti-on. Another legal solution would be to rearrange the values this way: [-'7, -8, -4, 2, 43, 0, 19, 7, 8] You may not make any assumptions about how many vaLues are in the l-ist and you are not allowed to swap data fields or to create any new nodes to solve this problem. You must rearrange the list by rearranging the l-inks of the list. You also may not use auxiliary structures like arrays, Arrayl.lsts, stacks, queues, etc, to solve this problem, although you may use recursion, 9. Write a method
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern