Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java Questions Please use the table list below for ALL questions. Q1: If the lis

ID: 3717025 • Letter: J

Question

Java Questions

Please use the table list below for ALL questions.

Q1: If the list in the accompanying figure was sorted using selection sort, which two elements would be swapped first?

A. 5 and 16

B. 65 and 16

C. 5 and 45

D. 7 and 30

Q2: In a sequential search, how many key comparisons would have to be made on the list in the accompanying figure to find the number 5?

A. 4

B. 5

C. 7

D. 8

Q3: If the list in the accompanying figure was sorted, what would be the middle element?

A. 7

B. 16

C. 24

D. 45

Q4: On average in a sequential search, how many comparisons would have to be made to find an element in the list in the accompanying figure?

A. 2

B. 5

C. 6

D. 8

Q5: In a sequential search, how many key comparisons would have to be made on the list in the accompanying figure to find the number 24?

A. 1

B. 2

C. 3

D. 4

Q6: Why can’t a binary search be used on the list as it appears in the accompanying figure?

A. Because the list is too big

B. Because the list is not sorted

C. Because it is a list of integers

D. A binary search can be used on the list

0 1 2 3 4 5 6 7 8 9 List: 16 30 24 7 25 62 45 5 65 50

Explanation / Answer

Please give thumbs up, if it is helpful for you. Let me know if you have any doubt.

#1) A. 5 and 16
Explanation:
The Selection sort algorithm is based on the idea of finding the minimum or maximum element in an unsorted array and then putting it in its correct position in a sorted array.
The minimum element in the array i.e. 5 is searched for and then swapped with the element that is currently located at the first position. i.e. 16

#2) D. 8
Explanation: compare each element from starting position one by one till we got the element.

#3) C. 24
Explanation: 5,7,16,24,25,30,45,50,62,65

#4) B. 5
Explanation:
=> (n+2)(n-1)/2n
=> (10+2)(10-1)/2*10

=> 12*9/20

=> 5

#5) C. 3
Explanation: compare each element from starting position one by one
till we got the element.

#6) B. Because the list is not sorted
Explanation: Binary search only be applied to the list if it is in sorted order.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote