Question

1. True or False: The selection sort cannot be used to sort strings. A. True B....

1. True or False: The selection sort cannot be used to sort strings.

A. True

B. False

2. The __________ search is most efficient for large amounts of data.

A. binary

B. serial

C. selection

D. bubble

3. What will be displayed after the following code is executed?

var chips = new Array("plain", "onion", "tuna", "barbecue", "cheddar");

document.write("There are " + chips.length + 1 + " types of chips.");

document.write("My favorite is " + chips[2] + ".");

A. There are 4 types of chips.

My favorite is barbecue.

B. There are 5 types of chips.

My favorite is onion.

C. There are 51 types of chips.

My favorite is tuna.

D. There are 6 types of chips.

My favorite is tuna.

4. Which of the following code snippets will load an array named fives(), consisting of 10 elements with the starting value of the first element = 0 and will load each subsequent element counting by 5's, ending with the last element = 45. In other words, the elements in the fives() array should be (0, 5, 10, 15, ... 45).  

A. var fives = new Array();
for(j = 1; j < 11; j++)
     fives[j] = j + 5;

B. var fives = new Array();
for(j = 1; j < 11; j++)
     fives[j] = j * 5;

C. var fives = new Array();
fives[0] = 0;
for(j = 1; j < 10; j++)
     fives[j] = fives[j - 1] + 5;


D. var fives = new Array();
for(j = 0; j < 11; j++)
     fives[j] = fives[j ] + 1

5. Which statement will delete the first two items in the food() array given below?

var food = new Array("burger", "chips", "soup", "pizza", "lasagna");

A. food.splice(1-2);

B. food.splice(2);

C. food.splice(2, 0);

D. food.splice(0, 2);

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

Ques 1:

The correct answer is B) False

Explanation:

This is an incorrect statement, as any sorting algorithm can be used to sort any type of data.

Whether it be integer type, floating type, character type, or string type data.

Just the comparison is to be done lexicographically in strings.

Ques 2:

The correct answer is A)

Explantion:

Binary search is the most efficient searching algorithm

This is because it has the worst case complexity of O(log n)

Bubble and selection are sorting techniques, not searching techniques.

So, other options are wrong.

Ques 3:

The answer is C)

Explanation:

chips.length, will return the number of elements in the chips array.

As there are a total of 5 elements, so it will return 5

After that, 1 is written which is treated as a string and it becomes 51.

Now, chips[2] will return "tuna" as indexing starts from 0 and hence index 2 is the third element of array.

Ques 4:

The answer is C)

Explanation:

A , B and D options are wrong because, they are trying to access the index till index 10.

But as the length of the array is only 10, so index of the last element will be 9.

C option is correct as it initialises the first element to 0 and then it keeps increasing every next element by adding 5 to the previous element.

Ques 5:

The correct answer is D)

Explanation:

splice method takes first argument as the index from where the elements are to be deleted.

Then, the next argument tells that how many elements starting from that index should be deleted.

So, splice(0, 2) will delete the first 2 elements of the array.

PLEASE UPVOTE IF YOU FOUND THIS HELPFUL!
PLEASE COMMENT IF YOU NEED ANY HELP!

Add a comment
Know the answer?
Add Answer to:
1. True or False: The selection sort cannot be used to sort strings. A. True B....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. True or False: The selection sort cannot be used to sort strings. A. True B....

    1. True or False: The selection sort cannot be used to sort strings. A. True B. False 2. The __________ search is most efficient for large amounts of data. A. binary B. serial C. selection D. bubble 3. What will be displayed after the following code is executed? var chips = new Array("plain", "onion", "tuna", "barbecue", "cheddar"); document.write("There are " + chips.length + 1 + " types of chips."); document.write("My favorite is " + chips[2] + "."); A. There are...

  • 1. Which of the following code snippets will load an array named fives(), consisting of 10...

    1. Which of the following code snippets will load an array named fives(), consisting of 10 elements with the starting value of the first element = 0 and will load each subsequent element counting by 5's, ending with the last element = 45. In other words, the elements in the fives() array should be (0, 5, 10, 15, ... 45).   A. var fives = new Array(); for(j = 1; j < 11; j++)      fives[j] = j + 5; B. var...

  • 1. True or False: The selection sort cannot be used to sort strings. A. True B....

    1. True or False: The selection sort cannot be used to sort strings. A. True B. False 2. The __________ search is most efficient for large amounts of data. A. binary B. serial C. selection D. bubble

  • Transfer C code of selection sort to MIPS code and print the sorted array/results

    Transfer C code of selection sort to MIPS code and print the sorted array/results data Array: word 43, -5, 11, 12, 64, -7, 14, 71, 70, 13, -27 string: asciz"In" # Trantec the C code of selection sort to MIPS code. Do not modify the existing code and structure! text main la ŞtO, Array li $t1, 0 li $t7,11 mul $17, $17, 4 subi $t8,$t7, 4 # array length n-11 # 4*n #4*(n-1) # lis in $t1 and j is...

  • [5 marks] Using selection sort algorithm to sort the array int array[7]-5, 6, 2, 7, 9,...

    [5 marks] Using selection sort algorithm to sort the array int array[7]-5, 6, 2, 7, 9, 4, 3). Assuming we call the following function using statement selection sort (int array, 7); Please fill the table to show the changes of the array int_array after each iteration. The first column is filled. void selection_sort (int list[], int list_size) for (int i = 0; i < list size - 1; 1++) int current min = list[1]; int current_min_index-i for (int j -...

  • Transfer C code of selection sort to MIPS code and print the sorted array/results data Array:...

    Transfer C code of selection sort to MIPS code and print the sorted array/results data Array: word 43, -5, 11, 12, 64, -7, 14, 71, 70, 13, -27 string: asciz"In" # Trantec the C code of selection sort to MIPS code. Do not modify the existing code and structure! text main la ŞtO, Array li $t1, 0 li $t7,11 mul $17, $17, 4 subi $t8,$t7, 4 # array length n-11 # 4*n #4*(n-1) # lis in $t1 and j is...

  • 1. Given the following array, what is the value of pets[3]? var pets = new Array("giraffe",...

    1. Given the following array, what is the value of pets[3]? var pets = new Array("giraffe", "pig", "beetle", "hamster", "spider", "goldfish", "cow"); A. pig B. beetle C. hamster D. spider 2. Given the following array, which statement will create a variable named product that multiplies 4 * 5, using array elements? var nums = new Array(2, 3, 4, 5, 6, 30, 40, 50, 60); A. var product = nums[1] * nums[2]; B. var product = nums[2] * nums[3]; C. var...

  • Java 1. (5) Assume selection sort is applied to the following array. Show the state of...

    Java 1. (5) Assume selection sort is applied to the following array. Show the state of the array after the first pass of the outer loop. 50 35 15 100 90 20 10 25 2. (5) Assume bubble sort is applied to the following array. Show the state of the array after the first pass of the outer loop 50 35 15 100 90 20 10 25 3. (5) Assume quicksort is applied to the following array. Show the state...

  • 1. Assuming each line of information is stored in a new array, which of the following...

    1. Assuming each line of information is stored in a new array, which of the following pairs are not parallel arrays? A. names of all students at Santa Fe College ID numbers of all students at Santa Fe College B. names of all students at Santa Fe College names of all students taking JavaScript at Santa Fe College C. names of all students at Santa Fe College email addresses of all students at Santa Fe College D. All three sets...

  • 2. Suggest a structured plan (algorithm) for the bubble sort and selection sort, and perform running...

    2. Suggest a structured plan (algorithm) for the bubble sort and selection sort, and perform running time analysis for both best and worst case. 3. Consider the age data of 12 children who are supposed to undergo for vaccination in ascending order of their age. Suggest and apply a sorting technique which can efficiently handle this data. Show all the intermediate steps clearly. Child ID 01 02 03 04 05 06 07 08 09 10 11 12 2. Age 1...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT