Summary

This document is a past paper for a Data Structures and Algorithms (DSA) exam. It includes multiple-choice questions, covering a range of topics in data structures and algorithms.

Full Transcript

11/2/24, 10:40 PM Questions Q1 How does the scope of a static local variable compare to other local variables? Lost when function ends Retains value across calls Same as any local variable Ends when block ends Q2...

11/2/24, 10:40 PM Questions Q1 How does the scope of a static local variable compare to other local variables? Lost when function ends Retains value across calls Same as any local variable Ends when block ends Q2 What does the following pseudo code demonstrate in terms of datatype selection? colors = ["Red", "Green", "Blue"] Integer Array String Array Boolean Array Float Array Q3 How many return values can a function have? One Multiple Zero Depends on context Q4 What is the output of this loop? for (i = 0; i < 5; i++) { if (i == 3) { break; } print(i); } 012 01234 0123 None Q5 What does the following pseudo code describe in the context of memory management? 127.0.0.1:5500/ay/index.html 1/22 11/2/24, 10:40 PM Questions If requestedMemory 7->8->9->10->11 void printx(struct node* head) { if(!head) return ; printf(“%d ”,head->data); if(head->next) { printx(head->next->next); printf(“%d ”,head->data); } } 11 10 9 8 7 6 6 8 10 10 8 6 6 8 10 11 8 6 6 8 10 6 8 10 Q32 From the following options, select the type of linked list that is described by the following points. 127.0.0.1:5500/ay/index.html 11/22 11/2/24, 10:40 PM Questions Each node has two links. One node points to the previous node, or a null value or an empty list in case it is the first node. One node points to the next, or a null value or empty list in case it is the last node. Singly linked list Multi linked list Doubly linked list Circularly linked list Q33 What will the below code help to do? int solve(Queue *Queue) { Stack st; while (!isEmpty(Queue)) { push(&st, deQueue(Queue)); } while (!isEmpty(&st)) { enQueue(Queue, pop(&st)); } } Removes the last from Queue. Keeps the queue the same as it was before the call. Makes the queue empty. Reverse the Queue. Q34 If a stack of N elements is implemented with only one queue, one pop operation is equal to how many enqueue and dequeue operations in general? N-1 enqueue, N dequeue 1 enqueue, N-1dequeue 1 enqueue, 1 dequeue N-1 enqueue, 1 dequeue Q35 You are given a graph of 5 nodes. How will you detect whether the graph is also a tree? 127.0.0.1:5500/ay/index.html 12/22 11/2/24, 10:40 PM Questions if the number of nodes is less than 8 if there are not one or more cycles in the graph. if the graph is a directed graph. if the graph has 0 or more incoming nodes. Q36 Which of the following traversals is sufficient to construct BST from given traversals 1) Inorder 2) Preorder 3) Postorder 1 and 3 2 and 3 Either 2 or 3 is sufficient Any one of the given three traversals is sufficient Q37 Which type of algorithm uses a priority queue? DFS BFS Dijkstra's Algorithm Kruskal's Algorithm Q38 Consider the following statements: 1. A Breadth-first search is conducted using a stack. 2. A Depth-first search is conducted using a queue. Which of these statements, if any, are true? 1 only 2 only Both 1 & 2 Neither 1 nor 2 Q39 There are two data structures, one an array and another a singly linked list. Both stores same set of elements. Let A indicate time taken to search in an array, and B indicate to search in a linked list. 127.0.0.1:5500/ay/index.html 13/22 11/2/24, 10:40 PM Questions Which of the following is true on a typical modern computer. A>B A

Use Quizgecko on...
Browser
Browser