Docsity

1 Introduction to Data Structures and Algorithms, Exams of Data Structures and Algorithms

Toggle sidebar
bg1
1 Introduction to Data
Structures and Algorithms
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 - ANSDijkstra'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.
A stack abstract data type (ADT) is implemented using a(n) _____ data
structure.
array
linked list
heap
binary search tree - ANSlinked 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.
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download 1 Introduction to Data Structures and Algorithms and more Exams Data Structures and Algorithms in PDF only on Docsity!

1 Introduction to Data

Structures and Algorithms

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 - ANSDijkstra'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. A stack abstract data type (ADT) is implemented using a(n) _____ data structure. array linked list heap binary search tree - ANSlinked 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 Appending an element in an array involves increasing the array's _____. data type size value item - ANSsize 1.3.1: when we append a value to the array then the size of the array increases. 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.

pointer to child of memory of - ANSpointer to 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] - ANS[0, 2, 4, 6, 8] 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 - ANSPriority 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. Which algorithm is best suited for a plagiarism check? Navigation Binary search Shortest path Longest common substring - ANSLongest 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 data type is best suited to store the names and grades of students? array graph record stack - ANSrecord 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 Which is an abstract data type (ADT)? A list

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 - ANSA 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 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. - ANSEvery data structure has a specific algorithm to implement a certain operation. 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) - ANSif (numberList[i] % 2 == 0)