COMP-2450 Data Structures Final (All test questions)

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

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

false

ADTs allow programmers to _____.

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

A recursive function calls _____.

itself

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

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

pointer to

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

If a stack is implemented as a linked list, then a push will be a(n) _____ operation.

prepend

Which of the following statements is correct?

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

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

The list of employees' salaries

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

Assume the following set equations: s4 = s1 U s2 s5 = s4 \ s3 What are the contents of s5 if the initial contents of s1, s2 and s3 are: s1 = {1, 5, 10, 15, 20} s2 = {3, 4, 5, 20} s3 = {15, 1, 22, 3, 4, 6}

5, 10, 20

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

511

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

A deque

Identify the statement that is true of linked list traversal.

A doubly linked list's reverse traversal starts with the list's tail node.

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 abstract data type (ADT) is best suited to store the names of all currently available smartphone models?

A set

Which of the following is best represented by a graph?

A telephone network

Identify the correct way of denoting the union of sets A and B.

A ∪ B

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.

The union, intersection and difference operations for sets are all commutative. That is, s1 union s2 = s2 union s1, s1 intersection s2 = s2 intersection s1, and s1 difference s2 = s2 difference s1.

False

Which problem below would use a double recursion strategy?

Fibonacci

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

3

Set X = {34, 45, 56, 67, 78}. Function F = number + 5. Identify the output of the function SetMap(X, F).

39, 50, 61, 72, 83

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

Which statement enables the use of a set within a program?

#include <set>

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

1

Identify the correct sequence for inserting an item in a linked list.

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

The decimal number 247 converted to base 5 is ____________.

1442

Set A = {12, 24, 26, 38, 42} and Set B = {10, 20, 26, 30, 42}. Identify A ∩ B.

26, 42

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

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.

Which of the following should be a dynamic set?

Guest list in a hotel

Which algorithm is best suited for a plagiarism check?

Longest common substring

Given the doubly-linked list students (Tom, Sam), what will be the second node in the list after the following operations? ListInsertAfter(students, list⇢tail, node Hal) ListInsertAfter(students, list⇢head, node Pam)

Pam

What happens when a leaf node is removed?

The parent's left or right child node becomes null

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

Identify the correct statement about dynamic sets.

You can count the number of elements of a dynamic set.

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

abstraction

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

record

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

size

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

terminates

In a queue, a dequeue operation always removes _____ element.

the front

Identify the valid set that can be constructed from a collection of numbers 10, 11, 20, 22, 33, 39, 43, 11, 20.

{10, 11, 20, 22, 33, 39, 43}

Which of the following is not a valid set?

{11, 22, 33, 11}

Which of the below sets are equivalent?

{12, 10, 25} and {10, 25, 12}


Conjuntos de estudio relacionados

Parts of Speech - Nouns: Singular and Plural

View Set

Chapter 19: Documenting and Reporting

View Set

Chapter 10 Food Safety Management Set

View Set

AP Psychology - Unit 2 Progress Check MCQ

View Set

CSC 415 Operating System Principles Chapter 1

View Set

Ch.21 Statistical Process Control

View Set

Computer Science Ultimate Study Guide

View Set