Kamis, 13 April 2017

SECTION 2 QUIZ ALTERNATIF 3

Section 2 - Quiz 2 L4-L6
  (Answer all questions in this section)
 
  1.   What are maps that link a Key to a Value?  Mark for Review
(1) Points
 
 
HashSets

 
HashMaps (*)

 
Arrays

 
ArrayLists

 
  Incorrect. Refer to Section 2 Lesson 5.

 
  2.   A LinkedList is a type of Stack  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

 
  3.   Which of the following methods adds a Key-Value map to a HashMap?  Mark for Review
(1) Points
 
 
get(Key, Value)

 
add(Key, Value)

 
put(Key, Value) (*)

 
remove(Key, Value)

 
  Incorrect. Refer to Section 2 Lesson 5.

 
  4.   Stacks are identical to Queues  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  5.   Which scenario best describes a stack?  Mark for Review
(1) Points
 
 
A pile of pancakes with which you add some to the top and remove them one by one from the top to the bottom. (*)

 
A row of books that you can take out of only the middle of the books first and work your way outward toward either edge.

 
A line at the grocery store where the first person in the line is the first person to leave.

 
All of the above describe a stack.

 
  Incorrect. Refer to Section 2 Lesson 5.


 
  6.   These are a list of elements that have a first in last out ordering.  Mark for Review
(1) Points
 
 
Enums

 
Arrays

 
HashMaps

 
Stacks (*)

 
  Incorrect. Refer to Section 2 Lesson 5.

 
  7.   A collection is an interface in the Java API.  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

 
  8.   The following code is valid when working with the Collection Interface.
Collection collection = new Collection();  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  9.   What is a set?  Mark for Review
(1) Points
 
 
Something that enables you to create a generic class without specifying a type between angle brackets <>.

 
A collection of elements that does not contain duplicates. (*)

 
A keyword in Java that initializes an ArrayList.

 
A collection of elements that contains duplicates.

 
  Incorrect. Refer to Section 2 Lesson 4.

 
  10.   Big-O Notation is used in Computer Science to describe the performance of Sorts and Searches on arrays. True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

11.   Of the options below, what is the fastest run-time?  Mark for Review
(1) Points
 
 
n*log(n)

 
n^2

 
n

 
log(n) (*)

 
  Incorrect. Refer to Section 2 Lesson 6.

 
  12.   Which of the following best describes lexicographical order?  Mark for Review
(1) Points
 
 
An order based on the ASCII value of characters. (*)

 
The order of indicies after an array has been sorted.

 
A simple sorting algorithm that is inefficient on large arrays.

 
A complex sorting algorithm that is efficient on large arrays.

 
  Incorrect. Refer to Section 2 Lesson 6.

 
  13.   Which of the following best describes lexicographical order?  Mark for Review
(1) Points
 
 
The order of indicies after an array has been sorted.

 
A simple sorting algorithm that is inefficient on large arrays.

 
An order based on the ASCII value of characters. (*)

 
A complex sorting algorithm that is efficient on large arrays.

 
  Correct

 
  14.   Which of the following sorting algorithms utilizes a "divide and conquer" technique to sort arrays with optimal speed?  Mark for Review
(1) Points
 
 
Sequential Search

 
Merge Sort (*)

 
Selection Sort

 
Binary Search

 
All of the above

 
  Incorrect. Refer to Section 2 Lesson 6.

 
  15.   Selection sort is a sorting algorithm that involves finding the minimum value in the list, swapping it with the value in the first position, and repeating these steps for the remainder of the list. True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

1.   Why might a sequential search be inefficient?  Mark for Review
(1) Points
 
 
It utilizes the "divide and conquer" method, which makes the algorithm more error prone.

 
It requires incrementing through the entire array in the worst case, which is inefficient on large data sets. (*)

 
It involves looping through the array multiple times before finding the value, which is inefficient on large data sets.

 
It is never inefficient.

 
  Incorrect. Refer to Section 2 Lesson 6.

 
  2.   Binary searches can be performed on sorted and unsorted data. True or false?  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  3.   Which of the following is the correct lexicographical order for the contents of the int array {17, 1, 1, 83, 50, 28, 29, 3, 71, 22}  Mark for Review
(1) Points
 
 
{71, 1, 3, 28,29, 50, 22, 83, 1, 17}

 
{1, 1, 17, 22, 28, 29, 3, 50, 71, 83} (*)

 
{1, 2, 7, 0, 9, 5, 6, 4, 8, 3}

 
{83, 71, 50, 29, 28, 22, 17, 3, 1, 1}

 
{1, 1, 3, 17, 22, 28, 29, 50, 71, 83}

 
  Incorrect. Refer to Section 2 Lesson 6.

 
  4.   Why might a sequential search be inefficient?  Mark for Review
(1) Points
 
 
It utilizes the "divide and conquer" method, which makes the algorithm more error prone.

 
It requires incrementing through the entire array in the worst case, which is inefficient on large data sets. (*)

 
It involves looping through the array multiple times before finding the value, which is inefficient on large data sets.

 
It is never inefficient.

 
  Incorrect. Refer to Section 2 Lesson 6.

 
  5.   Of the options below, what is the fastest run-time?  Mark for Review
(1) Points
 
 
n^2

 
n

 
n*log(n)

 
log(n) (*)

 
  Incorrect. Refer to Section 2 Lesson 6.

6.   Which searching algorithm involves using a low, middle, and high index value to find the location of a value in a sorted set of data (if it exists)?  Mark for Review
(1) Points
 
 
Sequential Search

 
Merge Sort

 
Selection Sort

 
Binary Search (*)

 
All of the above

 
  Correct

 
  7.   A HashMap can only store String types.  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  8.   Which scenario best describes a stack?  Mark for Review
(1) Points
 
 
A pile of pancakes with which you add some to the top and remove them one by one from the top to the bottom. (*)

 
A row of books that you can take out of only the middle of the books first and work your way outward toward either edge.

 
A line at the grocery store where the first person in the line is the first person to leave.

 
All of the above describe a stack.

 
  Incorrect. Refer to Section 2 Lesson 5.

 
  9.   The Comparable interfaces defines a method called compareTo.  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Correct

 
  10.   When you enqueue an element it  Mark for Review
(1) Points
 
 
adds it to the start of the list

 
removes it from the front of the list

 
adds it to the end of the list (*)

 
removes it from the end of the list

 
  Incorrect. Refer to Section 2 Lesson 5.

11.   Which scenario best describes a queue?  Mark for Review
(1) Points
 
 
A pile of pancakes with which you add some to the top and remove them one by one from the top to the bottom.

 
A row of books that you can take out of only the middle of the books first and work your way outward toward either edge.

 
A line at the grocery store where the first person in the line is the first person to leave. (*)

 
All of the above describe a queue.

 
  Correct

 
  12.   What are maps that link a Key to a Value?  Mark for Review
(1) Points
 
 
ArrayLists

 
HashMaps (*)

 
HashSets

 
Arrays

 
  Incorrect. Refer to Section 2 Lesson 5.

 
  13.   Which of these could be a set? Why?  Mark for Review
(1) Points
 
 
{1, 1, 2, 22, 305, 26} because a set may contain duplicates and all its elements are of the same type.

 
{"Apple", 1, "Carrot", 2} because it records the index of the elements with following integers.

 
{1, 2, 5, 178, 259} because it contains no duplicates and all its elements are of the same type. (*)

 
All of the above are sets because they are collections that can be made to fit any of the choices.

 
  Correct

 
  14.   Which of the following correctly adds "Cabbage" to the ArrayList vegetables?  Mark for Review
(1) Points
 
 
vegetables[0] = "Cabbage";

 
vegetables.add("Cabbage"); (*)

 
vegetables.get("Cabbage");

 
vegetables += "Cabbage";

 
  Incorrect. Refer to Section 2 Lesson 4.

 
  15.   ArrayList and Arrays both require you to define their size before use.  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Incorrect. Refer to Section 2 Lesson 4.

1.
A collection is an interface in the Java API.  Mark for Review
(1) Points












True (*)






False















Incorrect. Refer to Section 2 Lesson 4.











2.
What is wrong with the following declaration of the ArrayList of strings arr?

ArrayList(String) arr = new ArrayList(String)<>;  Mark for Review
(1) Points











(Choose all correct answers)












Only the 1st occurrence of "(String)" should be replaced with ""






The angled brackets "<>" need to be replaced with parenthesis "()" and parenthesis "()"need to be replaced by "<>" (*)






Both occurences of "(String)" should be replaced with "<String>" and the angled brackets "<>" need to be replaced with parenthesis "()" (*)






Nothing, this declaration is correct.















Incorrect. Refer to Section 2 Lesson 4.











3.
ArrayList and Arrays both require you to define their size before use.  Mark for Review
(1) Points












True






False (*)















Correct











4.
Selection sort is a sorting algorithm that involves finding the minimum value in the list, swapping it with the value in the first position, and repeating these steps for the remainder of the list. True or false?  Mark for Review
(1) Points












True (*)






False















Incorrect. Refer to Section 2 Lesson 6.











5.
Selection sort is efficient for large arrays. True or false?  Mark for Review
(1) Points












True






False (*)















Correct

6.   Bubble Sort is a sorting algorithm that involves swapping the smallest value into the first index, finding the next smallest value and swapping it into the next index and so on until the array is sorted. True or false?  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  7.   Which of the following is the correct lexicographical order for the contents of the int array {17, 1, 1, 83, 50, 28, 29, 3, 71, 22}  Mark for Review
(1) Points
 
 
{1, 1, 3, 17, 22, 28, 29, 50, 71, 83}

 
{71, 1, 3, 28,29, 50, 22, 83, 1, 17}

 
{1, 1, 17, 22, 28, 29, 3, 50, 71, 83} (*)

 
{1, 2, 7, 0, 9, 5, 6, 4, 8, 3}

 
{83, 71, 50, 29, 28, 22, 17, 3, 1, 1}

 
  Incorrect. Refer to Section 2 Lesson 6.

 
  8.   A sequential search is an iteration through the array that stops at the index where the desired element is found. True or false?  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 2 Lesson 6.

 
  9.   Which of the following best describes lexicographical order?  Mark for Review
(1) Points
 
 
A simple sorting algorithm that is inefficient on large arrays.

 
A complex sorting algorithm that is efficient on large arrays.

 
The order of indicies after an array has been sorted.

 
An order based on the ASCII value of characters. (*)

 
  Incorrect. Refer to Section 2 Lesson 6.

 
  10.   Which scenario best describes a queue?  Mark for Review
(1) Points
 
 
A pile of pancakes with which you add some to the top and remove them one by one from the top to the bottom.

 
A row of books that you can take out of only the middle of the books first and work your way outward toward either edge.

 
A line at the grocery store where the first person in the line is the first person to leave. (*)

 
All of the above describe a queue.

 
  Correct

11.   FIFO stands for  Mark for Review
(1) Points
 
 
First In First Out (*)

 
Fast Interface Fast Output

 
First Interface First Output

 
Fast In Fast Out

 
  Incorrect. Refer to Section 2 Lesson 5.

 
  12.   Which of the following methods adds a Key-Value map to a HashMap?  Mark for Review
(1) Points
 
 
remove(Key, Value)

 
add(Key, Value)

 
put(Key, Value) (*)

 
get(Key, Value)

 
  Correct

 
  13.   A HashMap can store duplicates.  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct

 
  14.   To allow our classes to have a natural order we could implement the Comparable interface.  Mark for Review
(1) Points
 
 
True (*)

 
False

 
  Incorrect. Refer to Section 2 Lesson 5.

 
  15.   A HashMap can only store String types.  Mark for Review
(1) Points
 
 
True

 
False (*)

 
  Correct


 
  10.   Which of the following are true about deque.  Mark for Review
(1) Points
 
 
It is pronounced "deck" for short.

 
It implements a stack.

 
Allows for insertion or deletion of elements from the first element added or the last one.

 
All of the above. (*)

 
  Incorrect. Refer to Section 2 Lesson 5.

  Why can a LinkList be considered a stack and a queue?  Mark for Review
(1) Points
 
  (Choose all correct answers)
 
 
Because you can add elements to the end of it. (*)

 
Because you can remove elements from the end of it. (*)

 
Because you can remove elements from the beginning of it. (*)

 
Because you can add element to the beginning of it. (*)


0 komentar:

Posting Komentar

luvne.com ayeey.com cicicookies.com mbepp.com kumpulanrumusnya.com.com tipscantiknya.com