1 Introduction to Data Structures and Algorithms

Ace your homework & exams now with Quizwiz!

Which of the following is best represented by a graph? A file system on a computer The Undo command in a word processor A work scheduling operation A telephone network

A telephone network can connect with any other networks, same as a node in a graph can connect with any other node using an edge.

Which is not a characteristic of an NP-complete problem? No efficient algorithm has been found to solve an NP-complete problem. An efficient algorithm to solve an NP-complete problem may be possible. If an NP-complete problem has an efficient solution, then all NP-complete problems will have an efficient solution. All NP-complete problems can be solved efficiently.

All NP-complete problems can be solved efficiently. 1.2: NP-complete problems are a set of problems for which no known efficient algorithm exists. NP-complete problems have the following characteristics: No efficient algorithm has been found to solve an NP-complete problem. No one has proven that an efficient algorithm to solve an NP-complete problem is impossible. If an efficient algorithm exists for one NP-complete problem, then all NP-complete problems can be solved efficiently.

A manufacturing plant has many ways to assemble a product. Which algorithm will be useful to find the quickest way? Shortest path Binary search Dijkstra's shortest path Longest common substring

Dijkstra's shortest path 1.2: Dijkstra's shortest path: Dijkstra's shortest path algorithm determines the shortest path from a start vertex to each vertex in a graph.

In a linked list, each node stores a _____ the next node. copy of pointer to child of memory of

pointer to

Which is an abstract data type (ADT)? A list A string A boolean A float

A list 1.4: A list is a common ADT for holding ordered data

Identify the correct sequence for inserting an item in a linked list. Shift higher-indexed items. Create a list node for a new item. Assign a pointer to point to the new item. Shift higher-indexed items. Assign a pointer to point to a new item. Create a list node for the new item. Create a list node for a new item. Assign a pointer of the new item to point to the next item. Update the pointer of the previous node to point to the new node. Create a list node for a new item. Update the pointer of the previous node to point to the new node. Assign a pointer of the new item to point to the next item.

Create a list node for a new item. Assign a pointer of the new item to point to the next item. Update the pointer of the previous node to point to the new node. 1.1.2: To insert new item in a linked list, a list node for the new item is first created. Item B's next pointer is assigned to point to item C. Item A's next pointer is updated to point to item B. No shifting of other items was required.

Which of the following statements is correct? Every data structure has a specific algorithm to implement a certain operation. Algorithms cannot utilize data structures to store and organize data. The algorithm to append an item in an array is the same as appending an item to a linked list. Data structures define only how data is organized and stored.

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

Which algorithm is best suited for a plagiarism check? Navigation Binary search Shortest path Longest common substring

Longest common substring 1.2: Longest common substring problem: A longest common substring algorithm determines the longest common substring that exists in two input strings.

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 deque A linked list A queue A priority queue

Priority Queue a queue where each item has a priority, and items with higher priority are closer to the front of the queue than items with lower priority.

In a computational problem for finding the highest salary of an employee in a company, what is the input? The list of employees' salaries The number of employees The highest salary The computation of the highest salary

The list of employees' salaries we need list of employees salary to find the highest salary by comparing each one of them. We don't need number of employees because we can get that number by finding the length of list. Also we don't need the highest salary and computation of the highest salary.

What values are stored in the list numList? numberList() { for (i = 0; i < 10; i++) { if (i % 2 == 0) { numList[i] = i } } } [1, 2, 3, 4, 5] [0, 2, 4, 6, 8] [2, 4, 6, 8, 10] [1, 3, 5, 7, 9]

[0, 2, 4, 6, 8]

Which XXX will complete the algorithm to separate numberList into two lists (even and odd) using an array? MathematicalFunction(numberList) { Create evenNumberList array Create oddNumberList array for (i = 0; i < numberList⇢length; ++i) { XXX { ArrayAppend(evenNumberList, numberList[i]) } else { ArrayAppend(oddNumberList,numberList[i]) } SortAscending(evenNumberList) SortAscending(oddNumberList) } for (i = 0; i < evenNumberList⇢length; ++i) { Display evenNumberList[i] } for (i = 0; i < oddNumberList⇢length; ++i) { Display oddNumberList[i] } } if (numberList[i] % 1 == 1) if (numberList[i] % 2 == 1) if (numberList[i] % 1 == 0) if (numberList[i] % 2 == 0)

if (numberList[i] % 2 == 0) this will help separate even numbers in a list and else will have the odd numbers in the list.

A stack abstract data type (ADT) is implemented using a(n) _____ data structure. array linked list heap binary search tree

linked list 1.4.1: CHART Stack A stack is an ADT in which items are only inserted on or removed from the top of a stack. Linked list

Which data type is best suited to store the names and grades of students? array graph record stack

record a structure which is used to store more than one information(variable) of some data so, we can use a record(struct) to store both name and grade of a student

Appending an element in an array involves increasing the array's _____. data type size value item

size 1.3.1: when we append a value to the array then the size of the array increases.


Related study sets

economics unit 3 #1: supply and demand, it's the law

View Set

An Occurrence at Owl Creek Bridge

View Set

10th Grade L.A. Literary Terms FINAL

View Set

Unit 5: Lesson 1: Early Astronomy Assessment Questions

View Set

Geometry Lesson 1.1 Vocabulary, Geometry Lesson 1.2 Vocabulary, Geometry Lesson 1.3 Vocabulary, Geometry Lesson 1.4 Vocabulary, Geometry Lesson 1.5 Vocabulary

View Set

human growth and development unit 4 test: socioemotional development in middle and late childhood review ANSWERS

View Set

Modelos Históricos del Sistema Solar

View Set

Chapter 25: The Cold War and the Fair Deal, 1945-1952

View Set