Computer Science 201: Data Structures & Algorithms

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Which of the following pseudocodes is appropriate to compute area of a triangle? - Enter base length, B | Enter height, H | Compute the area = 1/2 * B * H - Display area - Enter the base length B and height H and compute area - Display area - Enter base length, B - Compute the area=2*B*H - Compute the area using the formula 1/2 * Base * Height - Display the area

- Enter base length, B | Enter height, H | Compute the area = 1/2 * B * H - Display area

What is an example of multi-line comment? * / The beginning of a multi-line * / the end of the comment // The beginning of a multi-line the end of the comment // /* The beginning of a multi-line the end of the comment */ * / The beginning of a multi-line the end of the comment * /

/* The beginning of a multi-line the end of the comment */

If a list contains three objects, what is the index number of the last object? 2 3 0 1

2

Given a second hash function of I(k) = (1 + k%7) , in which position in the table below would the key 53 be stored using the double hashing technique? [0][1][2][3][4][5][6][7][8][9] [E][E][E][3][E][E][E][E][E][E] 4 6 8 3

8 We calculate the base address H(53) = 53%10 = 3 Since position 3 is occupied, we need to resolve the collision by computing the alternative location using double hashing with second hash equation as: I(k) = (1 + k%7) The full equation to use when a collision occurs the first time: (1*I(k) + base address)%(table length) Position for 53 = (1*I(53) + 3)%10 = ((1+53%7) + 3)%10 = ((1+4) +3)%10 = 8%10 = 8

How does using a debugger in an integrated development environment benefit an individual who is writing code? It is best not to use a debugger, but instead to be thorough and read through all of the lines of code to find the bugs. A debugger can assist with generating test case scenarios which can then be used to test the code to find the bugs. A debugger can automatically fix the broken code for the individual once the bugs have been identified. A debugger walks through code in a systemic and automatic manner to find bugs, making the process less time consuming.

A debugger walks through code in a systemic and automatic manner to find bugs, making the process less time consuming.

Why is it necessary to analyze an algorithm? To write a program for it. To check the time and space it consumes. All of the above To check the correctness of an algorithm

All of the above

A Java statement can be thought of as which one of the following? An expression An instruction A prompt A loop

An instruction

What type of data can a priority queue contain? Integers Any type of data Arrays Strings

Any type of data

Which of the following sets are implemented classes of the List interface? ArrayList, LinkedList, Stack, and Vector ArrayList, DynamicLinkedList, Stack, and Sort ArrayList, LinkedList, Stack, and Sort ArrayList, RoleResolvedList, Add, and Role

ArrayList, LinkedList, Stack, and Vector There are 10 implemented classes, including ArrayList, LinkedList, Stack, and Vector.

Which of the following Java code items correctly performs the binary search method from the Arrays class? Arrays.binarySearch(myList, Math.min(j, size), searcher); Arrays.binarySearch(myList, (j/2), Math.min(j, size), searcher, i/2, myList); Arrays.binarySearch(searcher); Arrays.binarySearch(myList, (j/2), Math.min(j, size), searcher);

Arrays.binarySearch(myList, (j/2), Math.min(j, size), searcher); The method can take 2 or 4 parameters. The correct answer sends the array (myList), starting at index /2 (j/2), and goes to the smallest value of j or the size of the array. It looks in that range for the value (searcher)

int marker = 10; What type of statement is the following? Integer Void Control Assignment

Assignment

Given the following Java code that performs a sequential search, what is missing? public static double sequentialSearch(int[] arr, int searchKey) { int arraySize = arr.length; for(int i = 0; i < arraySize; i++) { } return -1; } A) This code will compile as written. B) if(arr[i] == searchKey) { return i; } C) return i; D) if(searchKey == searchKey) { return i; }

B) if(arr[i] == searchKey) { return i; }

In which of the following data tree structures does a parent node have more than two child nodes? Heap Hash B-tree Binary tree

B-tree

Which of the following is NOT a type of binary tree traversal? Backorder traversal Inorder traversal Preorder traversal Postorder traversal

Backorder traversal Preorder, postorder and inorder traversals are valid types of binary tree transversals. Backorder is not a type of binary tree traversal.

_____ are the most efficient type of tree data structures. Hierarchical trees Balanced trees Sorted trees Binary trees

Binary trees

When performing an exponential search in Java, what is the first thing you should do? Check to see if the element is first in the list. Perform a recursive search to find the element. Check if the element is in the middle of the list. Perform a binary search.

Check to see if the element is first in the list.

Which of the following is a benefit of using the Java Collections Framework? Code portability More robust codebase More readable code Coding shortcuts

Code portability Writing code using the Java Collections Framework capitalizes on common behaviors for the entire collection.

_____ occurs when there is an attempt to store a value in an occupied space in a hash table. Collision Delay Clustering Hashing

Collision

Which interface must we implement in order to compare elements in a priority queue? PriorityQueue Comparable Driver Comparator

Comparable The Comparable interface permits us to compare instances of elements in a priority queue.

Which interface requires the compareTo method to be overridden? Comparable Driver PriorityQueue Comparator

Comparable When we implement the Comparable interface, we are required to provide an @Override the abstract method compareTo.

What is the compareTo method used for? Select the most complete answer. Compares new elements Compares the first and last elements Compares two queues Compares two elements in the queue

Compares new elements The compareTo method is used to compare new elements as they are added to the priority queue. This determines their priority.

Contrapositive and contradiction fall under which category of algorithm analysis? Loop Variants Induction Contra Attack Asymptotic

Contra Attack

Which method is used to prove a mathematical statement true, by assuming the negation of it to also be true? Manual analysis Induction Contrapositive Contradiction

Contrapositive A contrapositive method first proves the negative of a given statement true, and then concludes that the original statement is also true.

What is the main characteristic of binary trees? Each parent only has two children. Each node is connected twice. Search time can be reduced. Each root only has two nodes.

Each parent only has two children.

Which of the following location states will be treated the same when doing an INSERT operation into the hash table in open addressing? None of the states will be treated the same in open addressing Occupied and Deleted Empty and Deleted Occupied and Empty

Empty and Deleted When doing an INSERT operation, both Empty and Deleted spaces in the table will have values inserted into them. Deleted spaces will be treated differently from Empty spaces when doing data retrieval only.

Which major application uses B-tree data structure? Designing heap sort algorithm Writing routing algorithms Database building and indexing Priority Queuing

Database building and indexing B-tree is used majorly in building a database and its indexing.

If a program needed to create a copy of an array with new references to an object, what type of copy would be performed? Narrow copy Empty copy Deep copy Shallow copy

Deep copy

What happens if an element is not found in a sequential search? Every item in the list was evaluated. The program crashes. An error is displayed in the output. A value of 0 is returned.

Every item in the list was evaluated.

What is the main property of a binary tree? Every leaf node must have exactly two children. Every node can have a maximum of 0, 1 or 2 children. Every node must have at least 1 child. Every node should have exactly two children.

Every node can have a maximum of 0, 1 or 2 children. The main property of a binary tree is that each node can have either 0, 1 or 2 children.

When performing an exponential search in Java, what is the order of operations? Find the range for the element. Then complete a binary search. Perform a binary search. Then split the array in thirds. Complete a binary search. Then find the range for the element. Find the range for the element. Then perform a reverse logarithmic search.

Find the range for the element. Then complete a binary search.

Which of the following is NOT a typical component of an Integrated Development Environment? Debugger Grammar checking Autocompletion Syntax checking

Grammar checking

What determines if a value being stored in a tree needs to go to the right or to the left side of the root? If the value being stored is less or greater than the value in the root. If there is an existent root in the tree or not. If the tree being used is a binary tree or not. If all the children in the tree are in the same level.

If the value being stored is less or greater than the value in the root.

Huffman code binary trees are used in which of the following? Image and video compression 3D video games Cryptography Job scheduling queues

Image and video compression

Which of the open addressing methods involves the simplest calculation for collision resolution? Quadratic Linear Chaining Double hashing

Linear Linear probing is the simplest collision resolution technique, because we simply add the constant 1 to the current position until we get an empty location. Quadratic and double hashing techniques both involve additional equations for calculating the alternative location. Chaining is not an open addressing technique.

What are the two types of heap data structure? Min-heap and Max-heap Median-heap and Min-heap Median-heap and Full-heap Max-heap and Median-heap

Min-heap and Max-heap Heaps can be min-neap (where the root node has the lowest value) or max-heap (where the root node has the highest value).

The compiler is giving an error on the following statement. Why? float hoursWorked Missing brackets Missing a value Missing a variable Missing semicolon

Missing semicolon

What is the default sort order for priority queues? Natural order Null Numeric Alphabetic

Natural order Priority queues use a natural order to determine priority.

In a singly linked list, the tail node points to what? The head Null The node before the tail 0

Null

A while loop can evaluate _____ condition(s). Only one Exactly two Zero One or more

One or more

In Big O notation, what is the significance of O(n)? Performance will increase exponentially. Performance increases linearly. Performance decreases at a logarithmic rate. There is no performance impact.

Performance increases linearly.

Which two structures does a positional list combine? Queue, array Queue, stack Stack, array Index, array

Queue, stack A queue lets you add only to the end of the list. A stack lets you only add to the top. A positional list provides the opportunity to perform either or both.

Which of the following is an important property of heap data structure? The right child of any node must always be greater than its left child. Every node has a maximum of 3 children in heap data structure. Heap follows binary search tree principles. The nodes must be inserted from left to right.

The right child of any node must always be greater than its left child. Heap data structure does not follow binary search tree principle and thus there is no need for a node to have lesser value at the left child and greater value at the right child. The maximum number of children for any node on heap is either 0, 1 or 2.

Which of the following is NOT a type of binary tree? Recursive binary tree Perfect binary tree Complete binary tree Full binary tree

Recursive binary tree There are three types of binary trees described in the lesson. These are full, complete and perfect binary trees.

What is the name of the initial node of a tree data structure? Bunch Root Branch Leave

Root

In max heap type, which node has the element with the greatest value? First child node Last node of right sub tree Root node Last child node

Root node

Gwen is an IT programmer for a small, non profit company. She's been assigned to write some new code for her company's payroll department to assist with the roll-out of a new pay for performance system. The new code will affect employees' pay grades, salaries, and bonuses. Gwen has written pseudo-code and the actual code. What should be her next step in the process? Test and debug the code Release the code to the production environment Test the code with real-world users Train end users on the changes to the payroll program

Test and debug the code

Given an array of 2.5 billion elements, what is the average case for a sequential search? The element is not found. The element is found at n/2. The element is found at n. The list is too large. There is no best case.

The element is found at n/2.

How does the IDE component, known as syntax highlighting, aid developers with writing program code? The tool highlights misspelled words. The tool automatically corrects common typos while typing. The tool makes it easier to recognize the various elements of code . The tool automatically corrects text formatting while typing.

The tool makes it easier to recognize the various elements of code Explanation Syntax highlighting includes displaying code using different colors to indicate the different types of elements in code.

Which of the following statements is NOT correct? None of these statements are incorrect. The value of every parent node is greater than or equal to that of their child or node in min-heap. The value of every parent node is lesser than that of their children in min heap. Heap is a binary tree.

The value of every parent node is greater than or equal to that of their child or node in min-heap. In min-heap the value of every parent is less than or equal to that of their children with the root node having the minimum element value.

Which of the following is a property of max-heap? The value of the root element is the smallest of all other nodes in max-heap. The value of the root element is the greatest of all other nodes in max-heap. The value of level 0 left child element is the greatest of all other nodes in max-heap. The value of a child element is greatest of all other nodes in max-heap.

The value of the root element is the greatest of all other nodes in max-heap. In a max-heap, the value of the root element must be greater than all the other nodes.

A recursive algorithm has the following expression for its time complexity: T(n) = 2n. Considering this, mark the answer that is undoubtedly correct. This algorithm has a double linear time complexity. This algorithm has a linear time complexity. This algorithm has a linear time complexity and a linear space complexity. This algorithm has a double linear complexity.

This algorithm has a linear time complexity.

Consider the following Java code. Which part of an exponential search is it performing? while (j < size && array[j] <= key) { j = j * 2; } This code is finding the range of the key value. This code will not compile and is in error. This code performs the binary search. This is a recursive function.

This code is finding the range of the key value. This code is looking for the range of the key value. It is the first step in the exponential search. Once it exits the while loop, the binary search can then be performed.

In the Tower of Hanoi recursive method, why do we need calls to the method twice? solvePuzzle(n-1, begin, end, temp); solvePuzzle(n-1, temp, begin, end); This will prevent the program from crashing This is an error and the program can run with only one line To move a disc from start to the middle, then move it from the middle to end The code changes the last peg to the first peg by moving all pegs over from the third

To move a disc from start to the middle, then move it from the middle to end

A while loop runs code as long as the condition(s) is/are: False Positive True Negative

True

How many forms of the add method can be used with lists? Three Two One Four

Two The add method can be used with and without passing an index value.

How is a single line comment created in Java? Two backward slashes at the beginning indicate that the line is a comment. Two forward slashes at the beginning indicate that the line is a comment. A forward slash followed by two asterisks at the beginning indicate that the line is a comment. A forward slash followed by an asterisk at the beginning indicate that the line is a comment.

Two forward slashes at the beginning indicate that the line is a comment.

Which of the following binary trees is a binary search tree?

Which of the following binary trees is a binary search tree? number 1

When compared to an array, why is a linked list less efficient? All elements are indexed. You need to traverse each node. You can access any node's index. Pointers cannot be reset.

You need to traverse each node.

If you only want to clone a portion of an array in Java, which method do you use? cloneArray copyto arraycopy clone

arraycopy

One of the important considerations when writing pseudocode is to _____. specify a programming language write everything in a paragraph write only one statement per line write only a portion of the program that is important

write only one statement per line

If you are performing a sequential search in Java, the data _____. does not need to be sorted must be Boolean must be an integer must be sorted

does not need to be sorted

Which keyword is used to create a PriorityQueue instance? new create queue add

new We use the 'new' keyword to create the priority queue as in the following example: PriorityQueue<String> myPriorityQueue = new PriorityQueue<>();

Select the correct Java code that completes the method for inserting an element into a positional list. Node newNode = new Node(info); Node currentNode = head; while(--index > 0) { currentNode = currentNode.next; } No method exists for inserting an element into a positional list. newNode.previous = newNode.previous; node.previous = node.next; newNode = node; node = newNode; newNode.next = currentNode.next; currentNode.next = newNode;

newNode.next = currentNode.next; currentNode.next = newNode; This code moves the existing node forward, and slides in the new node just before it.

An element within a positional list in Java is also called a(n) _____. head tail root node

node Elements are called nodes. A node can be a head (at the start of the list), or a tail (at the end of the list)

Which method is a combination of the peek and remove methods? offer clear comparator poll

poll

Which method retrieves and removes the highest priority item of a priority queue? clear poll remove retrieve

poll The poll method will retrieve the item with the highest priority and remove it.

An important use of heap data structure is _____. indexing databases priority queue building databases storing routing tables

priority queue Since heaps are very useful in the data structures that require an element to be removed with highest or lowest priority, one of its major application areas is designing priority queues.

In Java, a _____ copy would copy only the double data types of an array. null shallow deep empty

shallow

Which List algorithm is used for arranging the List elements in a random order? shuffle swap randomize reverse

shuffle The shuffle algorithm puts the List elements in random order.

In algorithm analysis, space complexity describes _____. the total time taken by the algorithm the total memory space consumed None of the above. the correct output for an algorithm

the total memory space consumed Space complexity calculates total memory space consumed an an algorithm.

Which is the correct syntax for a while loop? while 1=0 { minute++; } while (total_panic < 1) { minute++; } while int panic { minute--; } while if i=7 then { minute++ }

while (total_panic < 1) { minute++; }

What is the difference between 'merge' and 'meld' operations of the heap? 'merge' joins or combines two heaps into one heap and destroys the original heap, 'meld' joins or combines two heaps into one heap and preserves the original heaps. 'merge' joins or combines two heaps into one heap and also preserves the original heaps, 'meld' also combines two heaps into one heap but destroys the original heaps. 'merge' splits one heap into two heaps. 'meld' splits one heap into two heaps.

'merge' joins or combines two heaps into one heap and also preserves the original heaps, 'meld' also combines two heaps into one heap but destroys the original heaps. Both operations combine two heaps into one heap but 'merge' preserves the original heaps while 'meld' destroys the original heaps.

Which JVM option is used to define the maximum size of heap memory? -Xss -Xmz -Xmx -Xms

-Xmx -Xmx JVM option is used to define the maximum size of heap memory.

What is an example of a documentation comment? /* This is the beginning and this is the end */ // This is the beginning and this is the end *// / This is the beginning and this is the end **/ /** This is the beginning and this is the end */

/** This is the beginning and this is the end */

A shop has a number of printers each with a different serial number. Some of the printers are on sale. What gets printed out after the following code is executed: costPrinter.put ('HP101', '$195'); costPrinter.put('HP203', '$204')' costPrinter.put('HP101', $159'); System.out.println(costPrinter.size()): Null Error 2 3

2

Suppose that a dating service is determining couples that would make a good match. In the graph shown, two sets of clients are represented with vertices, and the edges between the vertices indicate that the clients make a good match. Based on the graph, how many possible matches are there for Erin?

3

Suppose we just performed Dijkstra's algorithm on the graph shown to find the shortest path from vertex A to vertex C, so all of the vertices have been visited as indicated with the X ' s, including the starting vertex of A. Based on the graph and all of its final marks, what is the length of the shortest path from vertex A to vertex C?

3

What is the position where key 75 would be inserted into the table below using the quadratic probing method? [0][1][2][3][4][5] [6] [7] [8] [9] [E][E][E][3][E][5][25][E][E][35] 6 4 0 2

4 We compute the base address as: H(75) = 75%10 = 5 Since position 5 is occupied, we use the quadratic function H(k) = (probe number 2+base address)%10 We would use probe number as 1 in this equation since this will be the first computation for inserting 75. H(75) = (1 2+ 5)%10 = (1 + 5)%10 = 6%10 = 6 Since position 6 is already occupied, we recompute using probe number as 2: H(75) = (2 2+ 5)%10 = (4 + 5)%10 = 9%10 = 9 Since position 9 is occupied, we recompute using the next probe number as 3: H(75) = (3 2+ 5)%10 = (9 + 5)%10 = 14%10 = 4 We would store 75 and position 4.

Which of the following trees has been correctly updated by inserting node 68?

68 is added and the left node 85 makes the tree unbalanced. A left rotation around 85 and a swap with 55 making 68 a right child of 55 and the tree is balanced.

Why is cloning multi-dimensional arrays in Java not available using the clone method? A Java multi-dimensional array is an array of objects Java doesn't support pointers A Java multi-dimensional array is an array of primitives Only the copyArray or arraycopy methods work in Java

A Java multi-dimensional array is an array of objects Because a multi-dimensional array is an array of arrays, it means it's an array of objects. We are not able to create a deep copy of an array of objects using clone or arraycopy methods.

Which of these statements about cache memory is not true? CPUs have cache hits and cache misses. All of these are true. A bigger CPU cache improves speed. The information in a CPU cache is a duplicate of information stored elsewhere.

A bigger CPU cache improves speed. A smaller CPU cache actually improves speed, while a large one is not as helpful in terms of speed.

Which graph in discrete mathematics has a path of edges between every pair of vertices in the graph? A bipartite graph A disconnected graph A directed graph A connected graph

A connected graph In a connected graph, there is a path of edges between every pair of vertices in the graph.

What is the difference between a directed and an undirected graph? A directed graph can contain multiple edges and loops, but an undirected graph cannot. A directed graph can contain weights on the edges, but an undirected graph cannot. There is no difference between directed and undirected graphs. A directed graph uses arrows to indicate one-way relationships, but an undirected graph does not.

A directed graph uses arrows to indicate one-way relationships, but an undirected graph does not. In a directed graph, we use arrows on edges to indicate that the relationship indicated by the edge only goes from one vertex to the other, not the other way around. In an undirected graph, the relationship represented by an edge goes both ways between any pair of vertices with an edge between them.

What is a multi-level cache? The use of different types of caches by different computer components A technique to separate useful information from redundant information Improving the speed of a CPU by using parallel processing A series of connected CPU caches used to maximize fast access to information

A series of connected CPU caches used to maximize fast access to information Present day CPUs use multiple caches, like L1, L2 and L3. L1 is the smallest and fastest. If a CPU cannot find the information it needs, it goes on to the larger but slower L2, etc.

What is a cache? A copy of your data for backup purposes A small but very fast type of computer memory A data storage format A collection of old computer systems

A small but very fast type of computer memory A cache is a type of memory used to hold frequently accessed data. Various types of caches are used in computers, including a web cache and a CPU cache.

What is natural order? Chronological First-In A sort order such as numeric or alphabetic First-Out

A sort order such as numeric or alphabetic The default order of priority queues is referred to as natural order. That simply means that if the elements are numbers, they will be numerically ordered, and if they are strings, they will be alphabetized.

What is a pseudocode? Simple programming language. A text editor. A way of writing programming code in English. A structured method which can be compiled.

A way of writing programming code in English.

Which of the following does NOT describe a step in Dijkstra's algorithm? Always replace a vertex's mark with the new calculated distance (even if it is larger than a previous mark). Identify all of the vertices that are connected by an edge to your current vertex, and calculate their distance to the ending vertex by adding their current mark to the weight of the connecting edge. Start at the ending vertex and mark it with a 0 and label it as your current vertex by putting a circle around it. Once you've marked all of the vertices that are connected by an edge to your current vertex, label the current vertex as visited and put an X through it.

Always replace a vertex's mark with the new calculated distance (even if it is larger than a previous mark).

Which of the following search trees is balanced?

Answer 1 Answer 2 is incorrect because 40 cannot be on the left of 25. The left node is supposed to be a smaller number than 25. Answer 3 is incorrect because the second level node on the extreme right has more than three key values. This creates an overflow. Answer 4 is incorrect because the root node value makes the tree unbalanced. It needs to be between 20 and 40.

What is meant by the O(log(n)) notation? Performance is impacted at a exponential rate. Performance starts out low, then spikes dramatically as n increases. As the number of nodes increases, performance levels out. As the number of elements decreases, performance increases rapidly.

As the number of nodes increases, performance levels out. Since searching binary trees is a divide and conquer approach, the initial search has the biggest performance hit. As you continue to reduce the tree by halves, performance evens out.

B-Trees differ from Binary Search Trees (BSTs) in that _____. B-Trees offer a much slower response time to search operations B-trees can have any N number of nodes and N-1 keys values where N exceeds 2 unlike BSTs B-Trees search the nodal structure sequentially B-trees can have any N number of nodes and N/2 keys values where N exceeds 2 unlike BSTs

B-trees can have any N number of nodes and N-1 keys values where N exceeds 2 unlike BSTs B-trees can have any N number of nodes and N-1 keys values where N exceeds 2, unlike BSTs

What is a Binary Search Tree (BST)? BSTs are Boolean trees made of digital movable branches BSTs are Boolean trees made of digital movable nodes and leaves BSTs are a collection of trees, branches, and leaves BSTs are searchable collections of elements characterized by a nodal tree structure.

BSTs are searchable collections of elements characterized by a nodal tree structure.

What is a Binary Search Tree (BST)? BSTs are a collection of trees, branches, and leaves BSTs are searchable collections of elements characterized by a nodal tree structure. BSTs are Boolean trees made of digital movable branches BSTs are Boolean trees made of digital movable nodes and leaves

BSTs are searchable collections of elements characterized by a nodal tree structure.

Using the Big-O Notation, the best and worse case scenario for the Selection Sort algorithm is represented by _____ Best case:O(n^2) Worst Case:O (n log n) Best case:O(log n) Worst Case:O(1) Best case:O (n log n) Worst Case: O(n^2) Best case: O(n^2) Worst Case: O(n^2)

Best case: O(n^2) Worst Case: O(n^2) The Selection Sort best and worst case scenarios both follow the time complexity format: O(n^2) as the sorting operation involve two nested loops.

Which of the following algorithms requires the data lists or database to be in a numbered or indexed format to work efficiently? Binary search Tree Search Full text search Linear search

Binary search Read Answer Explanation The binary search works most efficiently in a sorted database.

A splay tree is best described as what type of data structure? Binary search tree Positional list Circular list Multi-dimensional array

Binary search tree Read Answer Explanation A splay tree is a type of binary search tree, which has branches splayed in different directions. For larger structures, this improves performance over binary search trees.

Which of the following data tree structures has a parent node that can't have more than two child nodes? Heap Both Binary tree and Heap B-tree Binary tree

Both Binary tree and Heap

if (i == 10) System.out.printIn("10") i += 10; Examine the following code. What is missing on the ''if statement''? Brackets/braces A semicolon An ''else statement'' An ''end if'' statement

Brackets/braces

Which of the following is the most appropriate example of a doubly linked list? Browsing history Train Operating system tasks Hash tables

Browsing history Explanation Browsing history can be a doubly-linked list in that the nodes are connected front-and-back, pointing forward and backward.

Which of the following best describes the function of the Java code below? char[] r2 = {'r', '2', '-', 'd', '2'}; String r2d2 = new String(r2); Creating a StringBuilder object for the new character array Creating a character array that appends the String object Creating a new String object from the character array Replacing the String object with a character array

Creating a new String object from the character array Read Answer Explanation The character array r2 is being used as the value for the new String object r2d2.

Which type of graph is this? A{}B Cyclic graph Acyclic graph Both a cyclic and acyclic graph None of these answers are correct

Cyclic graph It is a cyclic graph, as node A can be traversed to itself through path {(A,B),(B,A)} and also node B can be traversed to itself through path {(B,A),(A,B)}.

Which type of graph is the following? A{ Loop graph Acyclic graph Cyclic graph Not a valid graph

Cyclic graph The above is a cyclic graph, as node A can be traversed to itself by edge {(A,A)}.

A Huffman's tree has the following data: 20, *, 10 with frequencies 8, 9, 5. When the data is sorted, what will be the last data and its frequency? Data *, Frequency 9 Data: 10, Frequency 5 Data: 20, Frequency 8 Data: *, Frequency 5

Data *, Frequency 9 Read Answer Explanation When sorted, the data and values will be in ascending order of frequency. Here. The highest frequency is 9, and the data associated with the highest frequency is * (this would be the sum of the previous least frequency nodes).

What are tries in Java? Data structure Search routines Data type Blocks of code

Data structure Explanation Data structures are used to organize and store data. The trie data structure, pronounced 'try,' is a digital tree that uses keys to navigate the structure.

Which of the following is true with splay tree rotations? Rotations are only allowed for normalized trees. There are only two possible rotations. Each rotation moves the node once. Each rotation moves the root node twice.

Each rotation moves the node once. Read Answer Explanation With splay tree rotations, a node is moved once and there are at most two rotations. The operations available are zig, zig-zag, and zig-zig.

What are the main characteristics of a good Hash Function? Adaptable size and uniform distribution Use of positive indexes and open addressing Easy to compute and proper randomization Easy to compute and uniform distribution

Easy to compute and uniform distribution

What will be the result of the following code? int j = 0; while (j < 1000) { j = j - 1; }

Endless loop

What is the requirement for an internal sort? Enough disk space. A computer that is fast enough. A Quick Sort program Enough memory to hold all the data.

Enough memory to hold all the data.

Given the following Java code, what is the value of the String variable i10? String i9 = "Enter"; String i10 = i9; i9 = "Exit"; System.out.println(i10); Enter Undefined 0 Exit

Enter Read Answer Explanation Even though i10 was set to equal i9, changing i9 does not impact the value of i10.

In the graph shown, the vertices represent cities, and the edges represent flights between those cities. The weights of the edges represent the cost of the flights, in hundreds of dollars. Based on this, what two cities are the cheapest to fly between, and what is the cost? Flight: City A and City D Cost: $300 Flight: City D and City C Cost: $300 Flight: City A and City E Cost: $200 Flight: City D and City B Cost: $600

Flight: City A and City E Cost: $200 By looking at the edge weights (or the cost of the flights), we see that the smallest weight is 2, so this represents the cost of the cheapest flight, which is $200. This weight is on the edge between cities A and E, so the flight is between cities A and E.

What are the key things to consider when it comes to using Hash Tables? Hash Function and Open Addressing Open Hashing and Close Hashing Hashing and Collision Resolution Hashing and Open Addressing

Hashing and Collision Resolution Hashing will determine how the keys are created for the values and Collision Resolution will help deal with a hash function assigning the same key to multiple values

How does Huffman's code accomplish data compression without data loss? Highest frequency occurrences have smallest variable code so data size is smaller Lowest frequency occurrences have largest fixed code so data size is smaller Highest frequency occurrences have smallest variable codes so data size is larger Lowest frequency occurrences have smallest fixed code so data size is larger

Highest frequency occurrences have smallest variable code so data size is smaller Read Answer Explanation Huffman's code helps with data compression without data loss by making sure that highest frequency occurrences have smallest variable code. This makes the total data size smaller because lesser space is taken by the most commonly occurring values.

Which of the following is a characteristic specific to the red-black tree? All child nodes must be red. The root node can hold any number of child nodes. If a node is red, then its child nodes are black. Each node may have N number of children where N=4.

If a node is red, then its child nodes are black. With red-black trees, nodes are either red or black in color. If a node is red, all child leaves are black.

Assume the following graph described in python code: graph = {'A': [('B', 2), ('C', 3)], 'B': [('A', 2), ('C', 2), ('D', 8)], 'C': [('A', 3), ('B', 2), ('D', 4)], 'D': [('B', 8), ('C', 4)]} After a Dijkstra execution, which are the values of the dist array? (Let A be the starting node.)

If you run the algorithm step-by-step, you get the values 0, 2, 3 and 7.

After a zig-zig operation performed on the tree below, which of the following trees will remain?

In a zig-zig operation, the node moves up through the tree and winds up being the parent in a single-node line.

A while loop is considered _____ if you don't know when the condition will be true Indefinite Passive Infinite Positive

Indefinite

Which of the following is true of Robin Hood hashing? It allows a key to be moved once it is established Keys cannot be moved/altered once established Key-values can be duplicated and replicated in the table The hash table can never have any open slots

It allows a key to be moved once it is established Robin Hood lets you move keys as needed to ensure the shortest distance between keys and key-value pairs.

Which of the following is TRUE about pseudocode? It cannot be modified. It cannot be compiled. It can be compiled in any language you use. It is harder to write than making flowcharts.

It cannot be compiled.

Which of the following best describes an abstract data type (ADT)? It does not require knowledge of how operations are carried out. Knowledge of the data and underlying code is required. Knowledge of Java's ADT library and insertion methods is required. Java does not support ADT.

It does not require knowledge of how operations are carried out. An abstract data type (ADT) does not require that you know the underlying code, or how the data is structured. It provides the access and methods.

Why is the Quick Sort considered one of the most efficient sorting algorithms? Its performance only degrades if the list is sorted. Its both quick and efficient It has an average performance of O(n^2) It has an average performance of O(n log n)

It has an average performance of O(n log n)

Which statement is NOT an advantage of pseudocode? It is written easily in a word processing application. It is standardized. It is easy to modify. It can be used with structured programming languages.

It is standardized.

What is the result of executing the program shown? import java.util.Arrays; public class Main { public static void main(String args) { String classList = {"John", "Jean","James"}; String graduatesList = {"John", "Jean", "James"}; if(Array.equals(classList, graduatesList)) { System.out.println("All the students in this class are graduating"); } else { System.out.println("Some of the students are not graduating."); } } } It prints out 'Some of the students are not graduating' It prints out 'All the students in this class are graduating' It prints out to the console 'Error: The 2 arrays are String arrays that can not be compared' It throws an error on the line where the 2 arrays are being compared because the s is missing on Array.equals

It prints out 'All the students in this class are graduating' The Method is called Arrays.equals and it loops through each of the string elements of the 2 arrays to compare them (The elements) using the equals method, which for this case would prove that the 2 arrays are equivalent since they all contain the same elements but it will throw an error since the Method is spelled wrong.

What is a web cache? A backup copy of a website for security purposes It stores sensitive information in a secret location on the Internet. A multi-player online treasure hunt It stores frequently visited webpages on a local computer so they load faster.

It stores frequently visited webpages on a local computer so they load faster. A web cache stores a copy of webpage files locally. When you visit that page again, loading the files from the local computer will be faster.

Set < Integer > counts = new TressSet() counts.add(9343): counts.add(847); Based on the following Set, which of the following correctly iterates over all items in the Set?

Iterator < Integer > itr = counts.iterator(); while (itr.hasNext( )) { itr.next( ); }

Which of the following has highest memory requirement? Heap Class Stack JVM

JVM JVM requires highest memory requirement as it is the superset of the heap, stack, and class.

What does JDK stand for? Java Developers Kit Java Developers Environment Junior Developers Kit Java Development Kit

Java Development Kit

The concept of prefix and suffix is used in which of the following algorithms? Advanced Brute force Brute Force KMP Boyer-Moore

KMP The concept of prefix and suffix is used to compute the lps array of KMP.

What is the structure used for storing data in a Hash Table? Indexing Index-bit Hash-value Key-value

Key-value

What type of structure uses data stored inside a tree node? Hash-code Primary key Hash-map Key-value

Key-value

Which of the following is unnecessary in a Robin Hood hashing methodology? Empty elements Open addressing Key-value pairs Linked lists

Linked lists Robin Hood hashing is an open addressing method for avoiding collisions, but you don't need a linked list as you would in a chaining methodology. Key-values still exist, and there will be empty spots in the table.

What best describes the ratio of probe counts in Robin Hood hashing versus traditional open addressing algorithms? Lower Higher Zero Equal

Lower In fact there are often only about 6 probe counts versus 72! Even if you get no results, there is still far less traversing/probing of the table.

Which algorithm is used by garbage collector for detecting unused objects? Cleanup algorithm Space management algorithm Sweep algorithm Mark and sweep algorithm

Mark and sweep algorithm Read Answer Explanation Garbage collecter uses Mark and sweep algorithm for detecting unused objects.

The algorithm which sorts elements in an array by the use of the divide and conquer paradigm is the _____. Selection Sort Algorithm Marble Sort Algorithm Merge Sort Algorithm Bubble Sort Algorithm

Merge Sort Algorithm Read Answer Explanation Merge Sort Algorithm involves the dividing the array into multiple sub-arrays. Each sub-array is then sorted and then brought back together into a sorted array. This method is often referred to as the divide and conquer paradigm.

Which algorithms have multiple child nodes (more than 2)? Multiway Tree and 2-3-4 trees The Splay Tree and Multiway Tree The AVL Tree and 2-3-4 Trees Binary Search Tree and The Splay Tree

Multiway Tree and 2-3-4 trees

Graphs come under which category of data structures? None Non-linear Both Linear

Non-linear Graphs come under the category of non-linear data structures, as the data elements are organized non-sequentially and multiple data elements can be reached from a single data element.

Which Big O Notation applies to a binary search tree that is balanced? O(log2MlogMN) O(n) O(log(n)) O(n2)

O(log(n)) Read Answer Explanation O(log(n)) applies to most search trees, unless they are not balanced. In that case, you revert back to O(n)

The worst case time complexity of the Boyer-Moore Algorithm is: O(mn) O(m+n) O(mlogn) O(n^2)

O(mn) The worst case time complexity of Boyer-Moore is O(mn)

The average case performance of selection sort is: O(n2) O(n log n) O(n) O(2n)

O(n2)

What is Bubble sort performance? O(nn) O(1) O(n2) O(n)

O(n2)

Which exception is thrown when Java is out of memory? MemoryError OutOfMemoryError MemoryOutOfBoundsException MemoryFullException

OutOfMemoryError

Moore Algorithm? P: ababababa, S:ab. P: ababababa, S:hhaksnamauwna. P: ababababa, S:abihodnakduak. P: ababababa, S:abababababababababababa.

P: ababababa, S:abababababababababababa. Read Answer Explanation The worst case occurs when all the characters of the pattern are same as all the characters of the string. For example, P: ababababa, S:abababababababababababa.

The following graph contains a negative edge. For this reason, the Dijkstra Algorithm will not compute the correct shortest path in one case. In which path would this error occur? (Let A be the source node) Path: D to C Path: A to C Path: A to D Path: A to B

Path: A to C The Dijkstra output would be as follows: The actual shortest path from A to C is A -> C with a cost of 1. The shortest path in this case with a negative edge is from A to C is: A -> D -> B -> C with cost -200 which would produce the error.

In relation to a binary search, what does the notation O(log n) indicate about performance? Performance is worse at the beginning, then evens out. Performance gets exponentially worse as n increases. There is no performance impact to the system. Performance is worse at the beginning and worsens toward n.

Performance is worse at the beginning, then evens out. Because binary searches incrementally split the data set in half, the first iteration brings the heaviest load. The data set then shrinks and evens out as you approach n.

In the diagram below key 64 needs to be added. The best position will be position _____.

Position D. Key 64 is greater than the root node 40 so its position will be on the right of node 40. 64 is less than 78 so its position will be left of 78. It is greater than 50 so its correct position is the right of node 50.

What is the main difference between RAM and secondary memory? RAM is the primary storage in a computer system that becomes secondary memory when external data sorting is executed. RAM holds all data sets to be accessed by the computer. Secondary memory holds all the system's backup data. RAM is Remote Access Memory which has fast access times, and secondary memory is the computer's main memory. RAM is the primary storage in a computer system, otherwise known as main memory. Secondary memory is typically hard disk storage with much more capacity.

RAM is the primary storage in a computer system, otherwise known as main memory. Secondary memory is typically hard disk storage with much more capacity.

In Robin Hood hashing, the 'rich' elements are best described as what? Rich elements are those with more than one address assigned A rich element has more than one key and/or key-value pair Remember the poor elements are those closest to the key; the rich ones are further away. Remember the rich elements are those closest to the key; the poorer ones are further away.

Remember the rich elements are those closest to the key; the poorer ones are further away. The idea is to move the elements further away from their key so that the traversal is shorter.

What does the remove method do in regard to priority queues? Remove the lowest priority element in the queue. Remove the first-in element in the queue. Remove the highest priority element in the queue. Remove the last-in element in the queue.

Remove the highest priority element in the queue.

Assume the following graph described in python code: graph = {'A': [('B', 2), ('C', 3)], 'B': [('A', 2), ('C', 2), ('D', 8)], 'C': [('A', 3), ('B', 2), ('D', 4)], 'D': (['B', 8), ('C', 4)} After a Dijkstra execution, which are the values of the pred array? (Let A be the starting node.) none of these answers are correct

Running the algorithm step-by-step will result in -, A, A & C in the pred array.

Which of the following is a benefit of Robin Hood hashing? Next open address is always filled Probe counts increase exponentially Empty slots are always used Searches can be ended early

Searches can be ended early

Which of the following is true of Robin Hood hashing? The hash table can never have any open slots Keys cannot be moved/altered once established Searches can be ended early Key-values can be duplicated and replicated in the table

Searches can be ended early Once there is a 'hit', the search can stop; there's no need to keep going in the Robin Hood hashing method.

Consider a situation where the minimum number of swap operation is required. Which sorting algorithm is best for this use-case? Selection Sort Heap Sort Insertion Sort Merge Sort

Selection Sort

In which of the following sort algorithms does the arrangement of elements not affect its performance? Selection Sort algorithm Insertion Sort algorithm Bubble Sort algorithm Manage Sort algorithm

Selection Sort algorithm The arrangement of elements does not affect its performance of the Selection Sort algorithm

A graph is said to be _____ if the number of edges is closer to the minimal number of edges. Complete Incomplete Sparse Dense

Sparse A dense graph has a number of edges closer to the maximal number of edges, while a sparse graph has a number of edges closer to the minimal number of edges.

Which memory holds the references to objects stored in heap? Garbage collector Code memory JRE Stack memory

Stack memory Stack memory holds the references to objects stored in heap.

What is the operation called that is performed by selection sort to move numbers from the unsorted section to the sorted section of an array? Sorting Selection Merging Swapping

Swapping

The Map busInfo contains bus numbers and the first stop the bus halts at after it leaves the bus depot. The following code was implemented: busInfo.put ('206', 'Maple Street'); busInfo.put ('206', 'Green Town'); What happens after the two lines of code are executed? The Map data type busInfo() has one key-value pair: 206-Green Town The Map data type busInfo() runs into an error since '206' is repeated twice The Map data type busInfo() has two key-value pairs: Maple Street-206 and Green Town-206 The Map data type busInfo() has two key-value pairs: 206-Maple Street and 206-Green Town

The Map data type busInfo() has one key-value pair: 206-Green Town

Which of the following illustrations have all their correct balance factors correctly displayed (in red)?

The balance factor measures the difference in height between the left and right child nodes with respect to a particular node. In the correct answer: For the top node 12, follow it down to the bottom, 3 (on the left) - 3 (on the right) = 0 For node 4, 0 (on the left) - 2 (on the right) = -2 For node 32, 1 (on the right) - 2 (on the left) = -1.

What is a bad character rule? The character that does not match with the pattern string is a bad character. When the mismatch is encountered the pattern is shifted until the next mismatch. When there is a match. The character that does not match with the pattern string is a bad character. When the mismatch is encountered the pattern is shifted until the mismatch is a match or until the pattern crosses the mismatched character The character that matches with the second occurrence in the pattern string is a bad character. When the mismatch is encountered the pattern is shifted until the mismatch is a match or until the pattern crosses the mismatched character

The character that does not match with the pattern string is a bad character. When the mismatch is encountered the pattern is shifted until the mismatch is a match or until the pattern crosses the mismatched character The character that does not match with the pattern string is a bad character. When the mismatch is encountered the pattern is shifted until the mismatch is a match or until the pattern crosses the mismatched character.

Key 61 needs to be inserted into the following 2-3-4 tree. What would the correct result be? The insertion will be successful as key 61 already exists. The insertion will not happen. There will be a search hit on key 61 as it already exists. The insert operation would be successful as the are multiple blank nodes for the insertion to be completed. The insertion will be unsuccessful. The root node has reached its maximum capacity of child nodes.

The insertion will not happen. There will be a search hit on key 61 as it already exists. The insertion will be successful as key 61 already exists. When an insertion process happens, the key in question is first searched for. If there is a search miss and the rules of the tree are adhered to, then the insertion is carried out. If a search hit is encountered, the insertion will fail.

Consider the following code. What is true of the String object after the last line of code? StringBuilder newString = new StringBuilder("Jane Eyre"); newString.reverse(); The original object is changed to eryE enaJ It still exists in original form; a new object is created A new object with a value of eryE enaJ has been created It has been deleted completely and is now no longer available

The original object is changed to eryE enaJ Read Answer Explanation Strings are immutable, except if you use StringBuilder, which lets you create mutable (changeable) String objects.

When it comes to an insertion sort, what does the following really mean? O(N2) The processing time for an algorithm is constant The processing time for an algorithm is linear The processing time for an algorithm is proportional to the square of the data set The processing time for an algorithm is proportional to system resources

The processing time for an algorithm is proportional to the square of the data set

Why does an insertion sort take additional system resources to process? The repeated loops through the array actually reduce processing time The Java compiler is limited in its ability Usually, insertion sorts are fast only when they have limited elements The repeated loops through the array increase processing time

The repeated loops through the array increase processing time

What is the shortest path problem? The shortest path problem arises when we want to find a path between vertices that only visits exactly four vertices. The shortest path problem arises when we want to find the longest distance from one vertex to another vertex in a weighted graph. The shortest path problem arises when we are trying to find the shortest distance from one vertex to another vertex in a weighted graph. The shortest path problem arises when we want to find a path that passes through each vertex in a weighted graph at least twice.

The shortest path problem arises when we are trying to find the shortest distance from one vertex to another vertex in a weighted graph.

In the nested loop for the insertion sort, why do we decrement? This is an error; sorting should increment To get to the last element in the array The sort orders from end to beginning The sort needs to go past the last element

The sort orders from end to beginning

Which of the following is TRUE about checking if two arrays of the same set of elements are equivalent using the comparison operator (==) ? None of these answers are correct. The two arrays are references to 2 different objects in memory hence not equivalent Equivalency check using the comparison operator compares the first array's element to the corresponding element in the second array leading to the two being equivalent The two arrays are found to be equivalent given the fact that they contain the same set of elements

The two arrays are references to 2 different objects in memory hence not equivalent

In a Huffman's tree there are 3 pieces of data 12, 17, 19 with frequencies 4, 6 and 8 respectively. Which two pieces of data will be combined first? The two lowest frequencies 4 and 6 will be combined first The lowest value and lowest frequency 12 and 4 will be combined first The two lowest data values 12 and 17 will be combined first The lowest value and highest frequency 12 and 8 will be combined first

The two lowest frequencies 4 and 6 will be combined first Read Answer Explanation In building a Huffman tree, the two lowest frequencies 4 and 6 will be combined first.

Which of the following statements is NOT true? The lines between points in a graph are called edges. The points in a graph are called vertices. A graph is a collection of points and lines between those points. There are only three types of graphs in discrete mathematics.

There are only three types of graphs in discrete mathematics. There are many different types of graphs in discrete mathematics.

What is unique about compressed tries? They compress redundant node chains. They are unique to search engines. They use index keys. They are used to search strings.

They compress redundant node chains. Read Answer Explanation Compressed tries compress redundant node chains from standard tries.

Which of the following describes a loop? This edge connects point B to point D. This edge connects points A and B. This edge connects point A to point D. This edge connects point C to point C. This edge connects point A to point C.

This edge connects point C to point C.

What is the purpose of a CPU cache? To duplicate information from main memory in case the computer crashes To perform calculations faster To store frequently used information so the CPU can access it faster To cool down the CPU unit when it overheats

To store frequently used information so the CPU can access it faster Answer Explanation A CPU cache stores frequently used information so the CPU can access it faster. The same information is also stored elsewhere, but it would take longer to find.

The Map data type carPlates contains license plate numbers and car make and model in the state of New York. One of the cars in the Map data type is a Toyota Camry with license plate 12015, and another is a Honda Accord with license plate 50064. When the following code is executed, what gets printed out? System.out.println (carPlates.containsValue('Toyota Camry')):

True

The edges in directed graphs are _____? Unidirectional Depends Bidirectional None

Unidirectional Watch Correct Answer Read Answer Explanation The edges in directed graphs are unidirectional. Directed graphs have a one way relationship between two nodes and the edge can be traversed in a single direction only.

Huffman's code uses _____ encoding Both Variable and Fixed Variable Fixed for lower Frequencies Fixed

Variable Read Answer Explanation Huffman's code uses only Variable encoding. Characters with highest frequencies are assigned codes with smallest bits.

Which characteristic causes the poor turnaround times for searching operations in separate chaining? Very long link chains Redundant storage spaces Poor hash function Large volume data input values

Very long link chains The biggest advantage of separate chaining is its collision avoidance capabilities. This means that many data items may be hashed with the same keys creating long link chains. But, this adversely affects the turnaround time for searching operations.

What do we use Dijkstra's algorithm for? We use Dijkstra's algorithm to find the number of edges there are in a given graph. We use Dijkstra's algorithm to find the shortest path between two vertices on a weighted graph. We use Dijkstra's algorithm to find the number of vertices there are in a given graph. We use Dijkstra's algorithm to find the path between two vertices, on a weighted graph, that passes through every single vertex in the graph at least once.

We use Dijkstra's algorithm to find the shortest path between two vertices on a weighted graph.

What is a collision in Hash Tables? When the hash table runs out of space When two values are being inserted at the same time When the hash table has to use linked lists When the hash function assigns a key that has already been assigned

When the hash function assigns a key that has already been assigned

When selecting a collision resolution method for Hash Tables, when are linked lists better than open addressing? When using modular hashing When the storage utilization is above 80% It is never better When the storage utilization is below 50%

When the storage utilization is above 80%

Which of the following is a scenario where string searching can be used? While sorting data in descending order, for example, sorting in databases While sorting data in ascending order, for example, sorting in databases While searching for patterns in a string, such as in a search engines While load balancing, in servers

While searching for patterns in a string, such as in a search engines Read Answer Explanation Every search string that you enter in a search engine is treated as a substring and the search engine uses the algorithms of string searching to give you back the results. In a nutshell, when you enter a string, the search engine searches the vast amount of data on the internet and gives you the results.

Based on the code below, what is the most relevant operation being performed? if (node == node.parent.leftChild) { rightRotate(node); leftRotate(node); } else { leftRotate(node); rightRotate(node); } Creating a new node in a binary search tree. Reversing a rotation of a splay tree. Upward and left rotation of a splay tree. Zig-zag rotation of a splay tree.

Zig-zag rotation of a splay tree.

Using linear probing, which table correctly shows how the sequence of keys 51, 67, and 86 be stored in the table below? [0] [1] [2][3][4][5][6][7][8][9] [E][11][31][E][E][E][E][E][E][E]

[0][1][2][3][4][5][6][7][8][9] [E][11][31][51][E][E][86][67][E][E] To insert 51, we first compute the base address as: H(51) = 51%10 = 1 Since position 1 is occupied, we need to compute the alternation location as (1+current position)%10 In this case we compute (1 + 1)%10 = 2%10 = 2. Position 2 is also occupied, so we compute the next position using (1+2)%10 = 3. Since position 3 is empty, we store 51 in that position. The keys 67 and 86 do not cause collisions when we compute the base addresses, so we can store the keys at the base address. To insert key 67 we compute the base address as 67%10 = 7 Similarly, the base address for 86 is computed as 86%10 = 6

Multiway search trees are not binary search trees because _____. they are self-balancing trees a node can contain more than one child node they are color coded trees a node can contain more than 2 child nodes

a node can contain more than 2 child nodes Binary means 2. Binary search trees can contain a maximum of two child nodes, whereas Multiway search trees can contain more than 2 child nodes.

A Sort Map is _____. a searchable collection of maps an element with left and right nodes a searchable collection of elements a node with a minimum of 2 children

a searchable collection of elements

A Sort Map is _____. a searchable collection of elements a searchable collection of maps a node with a minimum of 2 children an element with left and right nodes

a searchable collection of elements

What is a search algorithm? a tool used to dynamically grow a tree based database A search algorithm is a program used to search algorithms, their tools and characteristics a set of tools that used for index nodes and numbers a set of codes or program that uses search keys and input strings to search directory database or web page.

a set of codes or program that uses search keys and input strings to search directory database or web page. A search algorithm has search keys or strings as input and uses its codes and procedures to search the relevant text, directories, databases or web pages and extract the required results.

The Dijkstra algorithm only finds the shortest path between: 4 nodes of a weighted graph. The Dijkstra algorithm is not used to find a shortest path. 2 nodes of a weighted graph. a vertex (source node) to every other vertex of a graph.

a vertex (source node) to every other vertex of a graph.

The Dijkstra algorithm will fail if: a weight in the path being computed is over two digits. a weight in the path being computed is a positive number. a weight in the path being computed is a negative number. The Dijkstra algorithm cannot fail.

a weight in the path being computed is a negative number. The Dijkstra algorithm will fail if a weight in the path being computed is a negative number.

How can a trie receive data? via a constructor an add() method when initialized at compile time

an add() method To add a string to a Trie, you write an add() method that converts the input to Character Array.

Internal memory sorting algorithms include _____. bubble sort, insertion sort and merge sort bubble merge, internal insertion and merge sort mail merge, insertion sort and merge sort bubble merge, internal insertion and bubble sort

bubble sort, insertion sort and merge sort

Consider the following string: String a1 = "LeRoy"; Which of the following will correctly create a character array from this string? a1 = toCharArray(); char array = new CharArray(); char[] newa1 = a1.toCharArray(); toCharArray().a1

char[] newa1 = a1.toCharArray(); Read Answer Explanation This code takes each character from the String a1 and creates a new data structure (character array)

Which method can we use to sort a priority queue by multiple elements? compareTo sort multiSort comparator

compareTo The compareTo method can be used to sort priority queues by one, two, or more elements.

A basic search operation using a B-Tree involves _____. comparing the search key starting at the root node and traversing the child nodes to locate the key comparing the last key starting at the root node and traversing the child nodes to locate the key comparing the last child node with the root node to search the key traversing the child nodes to delete the root node

comparing the search key starting at the root node and traversing the child nodes to locate the key Answer Explanation A basic search operation using a B-Tree involves comparing the search key starting at the root node and traversing the child nodes to locate the key

Internal memory sorting is defined as _____. data sorting done within secondary memory primary data sorting done in secondary memory data sorting, which is done within main memory secondary sorting done within RAM

data sorting, which is done within main memory

If you are performing a sequential search in Java, the data _____. must be sorted must be Boolean does not need to be sorted must be an integer

does not need to be sorted

.Bubble sort uses a _____ for-loop structure. double single triple quadruple

double

Which of the following is a correctly written Java statement? double conversions = 15.34; for(int i =0; i<15;i++) while(f<3); new String - "joey"

double conversions = 15.34;

Which of the following Java statements will make a clone of an array? double[] rates = oldRates.clone(); oldRates.arraycopy() = new rates[] double[] rates = new oldRates[].clone(); double[] rates = oldRates.arraycopy();

double[] rates = oldRates.clone();

External memory sorting is defined as_____. sorting data items within main memory and saving them to external memory executing sorting processes on large sizes of data sets while they are still being held in external memory merging external chunks of data into a single array processing chunks of data that are brought from external memory into main memory and sorted

executing sorting processes on large sizes of data sets while they are still being held in external memory

The last names of students in a class of 15, are all unique. The last names and the number of siblings they have, are saved in a TreeMap. Which method will you use to find the first value, alphabetically, of the last name? lastEntry floorKey firstEntry ceilingKey

firstEntry In this case, the last names will be automatically saved in alphabetical oder. The firstEntry() method will retrieve the last name starting with A in ascending order.

Which method does the List interface inherit from the Iterable interface? removeIf forEach stream parallelStream

forEach The List interface only inherits one method from the Iterable interface, and that is the forEach method.

Following a test, all students who qualified for a prize were entered in a database. Later it was found that student ID 035 was disqualified. The teacher would like to find out the ID for the student just after 035 who is next qualified. What method can they use from the TreeMap to retrieve this information? floorKey(key) higherKey(key) ceilingKey(key) lowerKey(key)

higherKey(key) Read Answer Explanation ExplanationThe heigherKey(key) retireves the least key that is the next higher in the map. In this case higherKey(035) will find the next higher ID after ID 035.

What is the test for the end condition in the following recursive piece of code? public void quicksort( int left, int right ) { int i, last; if (left >= right ) return; swap( left, (left + right)/2 ); last = left; for ( i = left+1; i <= right; i++ ) if ( data[i] < data[left] ) swap( ++last, i ); swap( left, last ); quicksort( left, last-1 ); quicksort( last+1, right ); } // quicksort return; quicksort( left, last-1 ); if ( data[i] < data[left] ) if (left >= right )

if (left >= right )

In Java, strings are _____, meaning they cannot be changed once they are created. immutable complex changeable simple

immutable Explanation Immutable means that it cannot be changed. Any modifications or other methods operate on completely new instances of the original String object.

A code editor that is used to check syntax, format, run, and test code is known as a/an _____. integrated development environment test environment artificial intelligence system integrated developer extension

integrated development environment

In loop variants, the relationship between the variables _____. is none of the above is different before and after the loop cannot be determined is the same before and after the loops

is the same before and after the loops The relationship of the variables immediately before and after a loop must hold true.

What is the advantage of selection sort? It required additional memory for operation. it requires no additional memory for operation. It is faster and requires fewer iterations. It is highly scalable.

it requires no additional memory for operation.

The Splay Tree algorithm differs from AVL in that _____. Its data structure cycles the nodes sequentially with decrease efficiency. Its data structure has the ability to self-balance allowing the least frequent accessed nodes to be nearer the root increasing efficiency. Its data structure has the ability to rotate allowing the most frequent accessed nodes to be nearer the root increasing efficiency. Its data structure cycles the unbalanced nodes sequentially with decrease efficiency.

its data structure has the ability to rotate allowing the most frequent accessed nodes to be nearer the root increasing efficiency Read Answer Explanation Splay Trees have the additional advantage of moving frequently accessed nodes closer to the root of the tree making them much more efficient over time.

Which package does the List interface belong to? java.String java.lang java.ArrayList java.util

java.util The List interface belongs to the java.util package.

Which package does the sort method belong to? java.util.ArrayList java.util.List java.util.Collections java.util.LinedList

java.util.Collections In order to sort our list, we will use the sort method that belongs to the Collections class. So, we must import the java.util.Collections package.

To create a list, which of these packages must be imported? java.util.Dictionary java.util.Collections java.util.LinedList java.util.List

java.util.List In order to work on a list, we need to first create one. We must import both the java.util.ArrayList and java.util.List packages.

How are trie nodes linked? indexes ordered lists arrays keys

keys Trie nodes use keys, a character linking to the node at the next higher level in the tree.

One of the most fundamental rules in a balanced BST nodal structure's representation is _____. three nodes can share one child a root node should have three children keys on the right of a node should be larger than the node and keys on the left side of a node should be less than that node keys on the left of a node should be larger than the node and keys on the right side of a node should be less than that node

keys on the right of a node should be larger than the node and keys on the left side of a node should be less than that node

One of the most fundamental rules in a balanced BST nodal structure's representation is _____. keys on the left of a node should be larger than the node and keys on the right side of a node should be less than that node three nodes can share one child a root node should have three children keys on the right of a node should be larger than the node and keys on the left side of a node should be less than that node

keys on the right of a node should be larger than the node and keys on the left side of a node should be less than that node

The pet names in a dog training camp of 10 dogs is unique. The pet names and the home address they live in are saved in a TreeMap. You would like to know which alphabet is the last in order. Which method will you use to find the highest value of the dogs name? floorkey lastEntry ceilingKey firstEntry

lastEntry The pet names will be automatically saved in alphabetical order. The lastEntry() method will retrieve the last dogs name.

Student ID 021 recently left the school. The teacher would like to know what the active ID is for the student just before student ID 021. She uses a TreeMap to save student IDs and names. What method can she use from the TreeMap to retrieve this information? lowerKey(key) floorKey(key) higherKey(key) ceilingKey(key)

lowerKey(key) Read Answer Explanation ExplanationThe lowerKey (Key) will retrieve the next lowest value. In this case lowerKey(021) will retrieve the next lowest value to find the ID just before 021.

In a Java merge sort, the unsorted array is recursively divided into subarrays until the subarray size is _____. two four one zero

one

Separate chaining is NOT affected by _____. table size or memory space available poor hash function or large input data poor hash function or memory space available index key values or memory space available

poor hash function or large input data index key values or memory space available Separate chaining is less vulnerable to issues with poor hash functions and factors that affect input loading.

When determining the largest sum, the greedy algorithm will _____. Review the immediate options and select the largest number from the options present at each step, to yield the largest sum. Review all possibilities and select the largest number from the optimal path to yield the largest sum. Review all possibilities and select the path that will yield the largest sum. Review all options and select numbers that will yield the largest possible value at the end.

review the immediate options and select the largest number from the options present at each step, to yield the largest sum. The greedy algorithm does not see the whole picture. If the end result is to determine the largest sum, the greedy algorithm will select the largest numbers from the immediate options available instead of evaluating all the possible options at each step.

AVL trees are characterized by _____. self-balancing properties, binary nodes and balance factor between-1 and 1 self-balancing properties, binary nodes and balance factor between -2 and 1 multi-way search properties, binary nodes and balance factor >3 automatic deletion properties, multi-way search properties and, binary nodes

self-balancing properties, binary nodes and balance factor between-1 and 1 AVL trees are self-balancing binary trees with a balance factor between -1 and 1.

Which method is used to retrieve the number of elements in a list? count size max length

size

What are the types of tries? primary and secondary standard and compressed lists and dictionaries strings and characters

standard and compressed Read Answer Explanation There are two types of tries in Java are standard and compressed.

The Big-O Notation is the _____. standard by which the performance of algorithmic functions is measured method by which sort algorithms are developed standard by which the number of recursions in the algorithmic functions is measured performance indicator for sub arrays

standard by which the performance of algorithmic functions is measured Read Answer Explanation The Big-O Notation is the standard by which the performance of algorithmic functions is measured

There are 30 students in a class with student IDs from 001 to 030. What method can be used to retrieve the IDs of students from 20 through 30 if the data is stored in a Map ADT? studentMap.ceiling(20, 30); studentMap.ceiling(20, 31); studentMap.subMap(20, 30); studentMap.subMap(20, 31);

studentMap.subMap(20, 31); The submap method will retrieve values starting from the lowest key (fromKey - inclusive), to the highest key (toKey - exclusive). Since the first and last student IDs to be retrieved are 20 and 30 respectively, inorder not to miss the last student ID (30), you have to specify 31 as the toKey.

The balance factor is defined as _____. the imbalance condition caused by an insertion operation the imbalance condition caused by a deletion operation the difference in nodal height between the left and right child nodes on a branch the difference in nodal rotation between the left and right child nodes on a pivot

the difference in nodal height between the left and right child nodes on a branch The balance factor measures the difference in height between the left and right child node with respect to a particular node.

Separate chaining is defined as _____. -The method by which linked lists of values are built in association with each location within the hash table where a collision occurs. -The method by which hashed links are built within data input values where the volume of the input data is unknown -The method of separating data input sets into unique storage spaces avoiding collisions -The method of separating index keys of the data input values avoiding collisions

the method by which linked lists of values are built in association with each location within the hash table where a collision occurs. Separate chaining is defined as a method by which linked lists of values are built in association with each location within the hash table where a collision occurs.

An overflow occurs when _____. the number of child nodes is less than the number of associated key values the number of child nodes is more than the number of associated keys values the number of keys within the node equals the number at the root node the number of keys within a node exceeds the maximum number allowed

the number of keys within a node exceeds the maximum number allowed An overflow occurs in a node when the number of key values within that node exceeds the maximum number allowed.

External Searching describes _____. the process of accessing data across a computer network accessing main memory from the internet searching data over the internet the process of accessing a task or sorting data from an external storage source which is outside main memory

the process of accessing a task or sorting data from an external storage source which is outside main memory The process of accessing a task or sorting data from external storage (outside main memory) is known as External Searching

A sorting algorithm is defined as _____. The process of reordering a group of items into a specified order. The process of performing algorithmic functions The process of memory accessing components of an algorithmic function The process of splitting an array into multiple sub-arrays for access into memory

the process of reordering a group of items into a specified order. A sorting algorithm is used to reorder a group of items into a specified order.

Multi-way merging describes _____. the process of repeatedly merging and sorting pairs of data chunks within main memory until a single block of merged sorted data is achieved the process of merging data from secondary memory to main memory and from main memory back to secondary memory the process of merging data from main memory to secondary memory and from secondary memory back to main memory the process of repeatedly merging and sorting pairs of data chunks and cyclically sending them back to memory until a single block of merged sorted data is achieved

the process of repeatedly merging and sorting pairs of data chunks within main memory until a single block of merged sorted data is achieved the process of repeatedly merging and sorting pairs of data chunks and cyclically sending them back to memory until a single block of merged sorted data is achieved

A typical characteristic of a B-tree is _____. the root node could be a leaf or a node pointing to a minimum of two children data in each node is sorted using the common keys for searching sequentially the order of the B-tree 'N' indicates the maximum number of root nodes a child can point to it is a self-balancing nodal structure with all leaf nodes at the any level

the root node could be a leaf or a node pointing to a minimum of two children A typical characteristic of a B-tree is the root node could be a leaf or a node pointing to a minimum of two children.

One of the main features of B-trees which also helps optimize speed is _____. the use of indexing its self-balancing characteristics storing data in nodes the use of many child nodes

the use of indexing Indexing uses data pointers to manage records from files and databases that are stored outside of main memory.

Separate chaining is best used in situations where _____ input loading is at its optimal the input data is small and the hash function is good the volume of the input data and the frequency of hash keys generation and re-assignment are unknown the volume of data to number of table cells is 1:1

the volume of the input data and the frequency of hash keys generation and re-assignment are unknown Separate chaining is best used in situations where the volume of the input data and the frequency with which the hash keys are generated and re-assigned are not known.

AVL implementations can be less efficient in situations where _____. there are frequent data lookup queries frequent left and right node balancing there are frequent deletion operations the balance factors are greater than -1

there are frequent deletion operations

Bubble sort compares _____ elements of an array at a time. all four three five two

two

Data collision occurs in a hash table when _____ two different table cells hash to the same index key in a hash table two different keys are stored to the same hash value in a table two different values hash to the same index key in a hash table the hash function is overloaded with data

two different values hash to the same index key in a hash table Data collision occurs in a hash table when two different values hash to the same index key in the table.

Suppose we are using Dijkstra's algorithm to find the shortest path from A to D in the graph shown. The first step is to mark the ending vertex, D, with a 0, label it as current and put a circle around it as shown. In the next step, we identify E and C as vertices that are connected by an edge to the current vertex. What would we mark vertex E and vertex C with, and what vertex would be the next current vertex in the algorithm?

vertex E = 7 vertex C = 5 next current vertex = C

Given an unsorted array {28, 32, 4, 15, 12, 45, 25, 33, 22, 56, 47, 11, 6}, what is the correct subarray after 3 recursive calls to merge sort? {28, 32} {4, 12, 15} {28, 32, 4, 15} {12, 45, 25}

{28, 32}

What is the best case complexity of merge sort? O(n) Ω(n log n) θ(n log n) O(n2)

Ω(n log n)


संबंधित स्टडी सेट्स