sample_question.pdf

sample_question.pdf - Q1 Pseudo code to bubble sort a...

  • No School
  • AA 1
  • 4

This preview shows page 1 - 4 out of 4 pages.

Q1. Pseudo code to bubble sort a one-dimensional integer array in ascending order is given below. bubbleSort an array of A numbers do swapped := false for each i in 0 to length( A ) - 2 do: if A[ i ] > A[ i + 1 ] then swap( A[ i ], A[ i + 1 ] ) swapped := true end if end for while swapped end The following code is an AVR implementation of the algorithm above for an array of 20 signed 16-bit integers. The code compiles successfully, but has several errors in it. Identify as many errors as you can and give their line number and a short description of the error. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 .include "m2560def.inc" .equ length = 20 .dseg sortedA: .byte length*2 ; reserve space for sorted array .cseg jmp RUwithme ; 20 numbers in array A: .dw 2121,9121,0,-10,1,2,3,-4,5,6 .dw -7,8,9,10,11,-12,-13,14,15,-32767
Image of page 1

Subscribe to view the full document.

Image of page 2
Image of page 3

Subscribe to view the full document.

Image of page 4

{[ 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