data structures

¡Supera tus tareas y exámenes ahora con Quizwiz!

Given the list (-45, 35, -32, 67, -89, 23, -11), what will be the final sorted list?

(-89, -45, -32, -11, 23, 35, 67)

Given the list (20, -35, 50, -52, 65, -53), what is the list after sorting by the 1's digit?

(20, 50, -52, -53, -35, 65)

What is the height of a BST built by inserting nodes in the order 20, 10, 30?

1

What is the correct sequence for inserting an item in a linked list?

1. Create a list node for a new item. 2. Assign a pointer of the new item to point to the next item. 3. Update the pointer of the previous node to point to the new node.

Insertion sort requires at most _____ swaps to sort a list of 20 elements.

190

The upper bound of an algorithm with best case runtime T(N)=3N+16 and worst case runtime T(N)=4N2+10N+5 is _____.

19N2

Given the following list of sorted elements, how many elements of the list will be checked to find 25 using binary search? {12, 13, 15, 20, 23, 24, 25, 36, 40}

2

How many additional recursive partitioning levels are required for a list of 64 elements compared to a list of 8 elements?

3

What is the height of a BST built by inserting nodes in the order 12, 24, 23, 48, 47?

3

Given a list (0, 1, 1, 2, 3, 5, 8, 13, 17), the binary search algorithm calls BinarySearch(list, 0, 8, 3). What is the index of the middle element?

4

Assume a full BST of height 8, how many nodes are in the tree?

511

Given the list (7, 23, 12, 8, 5, 6), what is the order of the elements after the third insertion sort swap?

7, 8, 12, 23, 5, 6

Which of the following lists is sorted?

89, 79, 63, 22

A list of 10 elements is to be sorted using insertion sort algorithm. How many times will the outer loop be executed?

9

Which is an abstract data type (ADT)?

A list

Which abstract data type (ADT) is most suitable to store a list of perishable products such that the product with the nearest expiry date is removed first?

A priority queue

Which of the following is best represented by a graph?

A telephone network

Which is not a characteristic of an NP-complete problem?

All NP-complete problems can be solved efficiently.

Which of the following is correct for a list ADT?

An element can be found and removed from the end of the list.

Which of the following is not an example of sorting a list?

Arranging student records neatly on a desk

A manufacturing plant has many ways to assemble a product. Which algorithm will be useful to find the quickest way?

Dijkstra's shortest path

Which of the following statements is correct?

Every data structure has a specific algorithm to implement a certain operation.

True or false? Most of the time, a C++ recursive algorithm will perform more efficiently (i.e. - run faster) than a C++ iterative algorithm.

False

Which problem below would use a double recursion strategy? Euclid's Highest Common Factor Factorial Compute Sum 1 to N Fibonacci

Fibonacci

Which of the following rules does a valid BST follow? Left subtree keys ≥ node's keys Left subtree keys ≤ node's keys Right subtree keys ≤ node's keys Right subtree keys ≤ left subtree keys

Left subtree keys ≤ node's keys

Which of the following statements is true with reference to searching?

Linear search will compare all elements if the search key is not present.

Which algorithm is best suited for a plagiarism check?

Longest common substring

Which of the following is the fastest algorithm to sort a string?

Merge sort

Which of the following is an example of a recursive function?

MySalaryCalulator(tempSal) { if (tempSal <= 500) return -1 else MySalaryCalculator(tempSal - 500) }

The Big O notation of the algorithm 7+12N+3N2 is _____.

N^2

An algorithm is written to return the first name beginning with "L" in a list of employee names. Which of the following is the algorithm's worst case scenario?

No names in the list begin with "L."

The best case runtime complexity of an algorithm that searches an array of size N is _____.

O(1)

What is the Big O notation for a recursive function with a runtime complexity of T(N)=5N+T(N−1)?

O(N^2)

What is the Big O notation for the following algorithm?

O(N^2)

In a linked list, each node stores a _____ the next node.

Pointer to

For the list {Allen, Barry, Christopher, Daisy, Garry, Sandy, Zac}, what is the second name searched when the list is searched for Garry using binary search?

Sandy

_____ sort is a sorting algorithm that treats the input as two parts, a sorted part and an unsorted part, and repeatedly picks the proper next value to move from the unsorted part to the end of the sorted part.

Selection

Which is not true for a linear search algorithm?

The algorithm starts at the end of the list.

Which of the following statements is correct?

The list ADT supports the printing of the list contents but the queue ADT does not.

Which of the following is the main requirement for a binary search algorithm?

The list must be sorted in ascending order.

In a computational problem for finding the highest salary of an employee in a company, what is the input?

The list of employees' salaries

What happens when a leaf node is removed?

The parent's left or right child node becomes null

True or false? Run-time stack is the name of the structure, created by the operating system, that stores local variable data, function parameter values, and returning function values of a running program.

True

When is a new node inserted as the left child?

When the new node's key is less than the current node and the current node's left child is null

What values are stored in the list numList?

[0, 2, 4, 6, 8]

Which abstract data type (ADT) is suited to check whether a given string is a palindrome?

a deque

Which abstract data type (ADT) is best suited to store the names of all currently available smartphone models?

a set

The process of providing only the essentials and hiding the details is known as _____.

abstraction

An algorithm's _____ is the scenario where the algorithm does the minimum possible number of operations.

best case

Name a type of binary tree which has the maximum number of nodes on every level except the last, and on this last level, the nodes occur exactly from left to right.

complete

Which function best represents the number of operations in the worst-case? for (i = 0; i < N; ++i) { if (numbers[i] % 2 == 1) factor = 2.5 }

f(N)=5N+2

ADTs allow programmers to _____.

focus on higher-level operations as per a program's needs

Given the following code for generating the Fibonacci series for N numbers, which XXX would replace the missing statement? FibonacciNumber(N) { XXX return 0 else if (N == 1) return 1 else return FibonacciNumber(N - 1) + FibonacciNumber(N - 2) }

if (N == 0)

Which XXX will complete the algorithm to separate numberList into two lists (even and odd) using an array? SCREENSHOT OF CODE

if (numberList[i] % 2 == 0)

Which XXX base case completes the algorithm to count the number of occurrences of a value in a list of numbers? SCREENSHOT OF CODE

if (startIndex >= numbersLength) return 0

A recursive function calls _____.

itself

In selection sort, the smallest element is selected and swapped with the _____ unsorted element.

leftmost

A stack abstract data type (ADT) is implemented using a(n) _____ data

linked list

A stack abstract data type (ADT) is implemented using a(n) _____ data structure.

linked list

Given a list (0, 1, 1, 2, 3, 5, 8, 13, 17) the binary search algorithm calls BinarySearch(list, 0, 8, 5). What will the low and high argument values be for the second recursive call?

low = 5, high = 8

find_if()'s notation is find_if(iteratorFirst, iteratorLast, boolFunction). find_if() passes elements to boolFunction _____.

one-by-one

A _______________ traversal would be used if you needed to save the contents of a BST on file with the same shape. This type of traversal would also be used if you wanted to make an exact copy of a BST.

pre-order

Which data type is best suited to store the names and grades of students?

record

A(n) _____ is a function f(N) that is defined in terms of the same function and operates on a value less than N.

recurrence relation

Appending an element in an array involves increasing the array's _____.

size

Which XXX sorts animalVec in ascending order? vector<string> animalVec; animalVec.push_back("bat"); animalVec.push_back("ant"); animalVec.push_back("dog"); animalVec.push_back("goat"); animalVec.push_back("cat"); XXX;

sort(animalVec.begin(), animalVec.end())

Sorting algorithms ______ elements in a list, comparing their values to sort.

swap

In a recursive function, the base case _____ the function.

terminates

During sorting the algorithm swaps _____.

two elements at a time

Which XXX completes the following insertion sort algorithm to sort in descending order? SCREENSHOT OF CODE

while(j > 0 && numbers[j] > numbers[j-1])


Conjuntos de estudio relacionados

Section C Question Set: FIS-Securities Fraud-Practice

View Set

Chapter 5 - Integumentary System

View Set

Seeley's Anatomy & Physiology 11th ed Chapter 10

View Set

MGT 471: Chp 1 reading, What makes Entrepreneurs Entrepreneurial? Sarasvathy

View Set

The 27 Amendments (word for word)

View Set

Legal Environment of Business Exam 4 Mindtap (Ch. 32, 33, 34, 35)

View Set