CSD201 - Abstract Data Types
D
Which of the following is a correct way to declare a multidimensional array in Java? a) int[][] arr; b) int arr[][]; c) int []arr[]; d) All of the mentioned
B
Which of these best describes an array? a) A data structure that shows a hierarchical behavior b) Container of objects of similar types c) Container of objects of mixed types d) All of the mentioned
D
Which of the following concepts make extensive use of arrays? a) Binary trees b) Scheduling of processes c) Caching d) Spatial locality
A
What is the result of the following operation Top (Push (S, X)) a) X b) Null c) S d) None
B
What would be the asymptotic time complexity to add an element in the linked list? a) O(1) b) O(n) c) O(n2) d) None of the mentioned
D
Which of the following is not a disadvantage to the usage of array? a) Fixed size b) You know the size of the array prior to allocation c) Insertion based on position d) Accessing elements at specified positions
D
Which of the following is not an inherent application of stack? a) Reversing a string b) Evaluation of postfix expression c) Implementation of recursion d) Job scheduling
D
Entries in a stack are "ordered". What is the meaning of this statement? a) A collection of stacks is sortable. b) Stack entries may be compared with the '<' operation. c) The entries are stored in a linked list. d) There is a Sequential entry that is one by one.
B
In Breadth First Search of Graph, which of the following data structure is used? a) Stack b) Queue c) Linked list d) None of the mentioned
C
In linked list each node contain minimum of two fields. One field is data field to store the data second field is? a) Pointer to character b) Pointer to integer c) Pointer to node d) Node
B
Process of inserting an element in stack is called ____________ a) Create b) Push c) Evaluation d) Pop
B
The following C function takes a single-linked list of integers as a parameter and rearranges the elements of the list. The function is called with the list containing the integers 1, 2, 3, 4, 5, 6, 7 in the given order. What will be the contents of the list after the function completes execution? struct node { int value; struct node *next; }; void rearrange(struct node *list) { struct node *p, * q; int temp; if ((!list) || !list->next) return; p = list; q = list->next; while(q) { temp = p->value; p->value = q->value; q->value = temp; p = q->next; q = p?p->next:0; } } a) 1, 2, 3, 4, 5, 6, 7 b) 2, 1, 4, 3, 6, 5, 7 c) 1, 3, 2, 5, 4, 7, 6 d) 2, 3, 4, 5, 6, 7, 1
C
The prefix form of an infix expression p + q - r * t is? a) + pq - *rt b) - +pqr * t c) - +pq * rt d) - + * pqrt
D
The process of accessing data stored in a serial access memory is similar to manipulating data on a ________ a) Heap b) Binary Tree c) Array d) Stack
B
The result of evaluating the postfix expression 5, 4, 6, +, *, 4, 9, 3, /, +, * is? a) 600 b) 350 c) 650 d) 588
D
What are the advantages of arrays? a) Easier to store elements of same data type b) Used to implement other data structures like stack and queue c) Convenient way to represent matrices as a 2D array d) All of the mentioned
B
What data structure would you mostly likely see in a non recursive implementation of a recursive algorithm? a) Linked List b) Stack c) Queue d) Tree
D
Here is an infix expression: 4 + 3*(6*3-12). Suppose that we are using the usual stack algorithm to convert the expression from infix to postfix notation. The maximum number of symbols that will appear on the stack AT ONE TIME during the conversion of this expression? a) 1 b) 2 c) 3 d) 4
C
How do you initialize an array in C? a) int arr[3] = (1,2,3); b) int arr(3) = {1,2,3}; c) int arr[3] = {1,2,3}; d) int arr(3) = (1,2,3);
C
How do you instantiate an array in Java? a) int arr[] = new int(3); b) int arr[]; c) int arr[] = new int[3]; d) int arr() = new int(3);
A
If the elements "A", "B", "C" and "D" are placed in a queue and are deleted one at a time, in what order will they be removed? a) ABCD b) DCBA c) DCAB d) ABCD
C
The concatenation of two list can performed in O(1) time. Which of the following variation of linked list can be used? a) Singly linked list b) Doubly linked list c) Circular doubly linked list d) Array implementation of list
C
A data structure in which elements can be inserted or deleted at/from both the ends but not in the middle is? a) Queue b) Circular queue c) Dequeue d) Priority queue
B
In Linked List implementation, a node carries information regarding a) Data b) Link c) Data and Link d) None of the mentioned
A
In a stack, if a user tries to remove an element from empty stack it is called _________ a) Underflow b) Empty collection c) Overflow d) Garbage Collection
A
The data structure required to check whether an expression contains balanced parenthesis is? a) Stack b) Queue c) Array d) Tree
B
The postfix form of A*B+C/D is? a) *AB/CD+ b) AB*CD/+ c) A*BC+/D d) ABCD+/*
C
The type of expression in which operator succeeds its operands is? a) Infix Expression b) Prefix Expression c) Postfix Expression d) None of the mentioned
B
What does the following function do for a given Linked List with first node as head? void fun1(struct node* head) { if(head == NULL) return; fun1(head->next); printf("%d ", head->data); } a) Prints all nodes of linked lists b) Prints all nodes of linked list in reverse order c) Prints alternate nodes of Linked List d) Prints alternate nodes in reverse order
A
1. The following function reverse() is supposed to reverse a singly linked list. There is one line missing at the end of the function. /* Link list node */ struct node { int data; struct node* next; }; /* head_ref is a double pointer which points to head (or start) pointer of linked list */ static void reverse(struct node** head_ref) { struct node* prev = NULL; struct node* current = *head_ref; struct node* next; while (current != NULL) { next = current->next; current->next = prev; prev = current; current = next; } /*ADD A STATEMENT HERE*/ } What should be added in place of "/*ADD A STATEMENT HERE*/", so that the function correctly reverses a linked list. a) *head_ref = prev; b) *head_ref = current; c) *head_ref = next; d) *head_ref = NULL;
A
A linear collection of data elements where the linear node is given by means of pointer is called? a) Linked list b) Node list c) Primitive list d) None of the mentioned
A
A linear list of elements in which deletion can be done from one end (front) and insertion can take place only at the other end (rear) is known as a ? a) Queue b) Stack c) Tree d) Linked list
A
A normal queue, if implemented using an array of size MAX_SIZE, gets full when a) Rear = MAX_SIZE - 1 b) Front = (rear + 1)mod MAX_SIZE c) Front = rear + 1 d) Rear = front
A
Assume that the operators +,-, X are left associative and ^ is right associative. The order of precedence (from highest to lowest) is ^, X, +, -. The postfix expression for the infix expression a + b X c - d ^ e ^ f is a) abc X+ def ^^ - b) abc X+ de^f^ - c) ab+c Xd - e ^f^ d) -+aXbc^ ^def
D
Assuming int is of 4bytes, what is the size of int arr[15];? a) 15 b) 19 c) 11 d) 60
B
Consider an implementation of unsorted singly linked list. Suppose it has its representation with a head pointer only. Given the representation, which of the following operation can be implemented in O(1) time? i) Insertion at the front of the linked list ii) Insertion at the end of the linked list iii) Deletion of the front node of the linked list iv) Deletion of the last node of the linked list a) I and II b) I and III c) I, II and III d) I, II and IV
A
Given pointer to a node X in a singly linked list. Only one pointer is given, pointer to head node is not given, can we delete the node X from given linked list? a) Possible if X is not last node b) Possible if size of linked list is even c) Possible if size of linked list is odd d) Possible if X is not first node
D
In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is a) log 2 n b) n⁄2 c) log 2 n - 1 d) n
D
In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is a) log2 n b) n⁄2 c) log2 n - 1 d) n
C
Linked list data structure offers considerable saving in a) Computational Time b) Space Utilization c) Space Utilization and Computational Time d) None of the mentioned
A
Linked list is considered as an example of ___________ type of memory allocation. a) Dynamic b) Static c) Compile time d) None of the mentioned
D
Linked lists are not suitable to for the implementation of? a) Insertion sort b) Radix sort c) Polynomial manipulation d) Binary search
C
Queues serve major role in a) Simulation of recursion b) Simulation of arbitrary linked list c) Simulation of limited resource allocation d) All of the mentioned
D
The following C function takes a simply-linked list as input argument. It modifies the list by moving the last element to the front of the list and returns the modified list. Some part of the code is left blank. Choose the correct alternative to replace the blank line. typedef struct node { int value; struct node *next; }Node; Node *move_to_front(Node *head) { Node *p, *q; if ((head == NULL: || (head->next == NULL)) return head; q = NULL; p = head; while (p-> next !=NULL) { q = p; p = p->next; } _______________________________ return head; } a) q = NULL; p->next = head; head = p; b) q->next = NULL; head = p; p->next = head; c) head = p; p->next = q; q->next = NULL; d) q->next = NULL; p->next = head; head = p;
D
What is the time complexity of inserting at the end in dynamic arrays? a) O(1) b) O(n) c) O(logn) d) Either O(1) or O(n)
D
What is the value of the postfix expression 6 3 2 4 + - *: a) Something between -5 and -15 b) Something between 5 and -5 c) Something between 5 and 15 d) Something between 15 and 100
D
What kind of linked list is best to answer question like "What is the item at position n?" a) Singly linked list b) Doubly linked list c) Circular linked list d) Array implementation of linked list
B
When does the ArrayIndexOutOfBoundsException occur? a) Compile-time b) Run-time c) Not an error d) None of the mentioned
D
Which data structure is needed to convert infix notation to postfix notation? a) Branch b) Tree c) Queue d) Stack
B
Which data structure is used for implementing recursion? a) Queue b) Stack c) Array d) List
D
Which of the following applications may use a stack? a) A parentheses balancing program. b) Tracking of local variables at run time. c) Compiler Syntax Analyzer. d) All of the mentioned
B
Which of the following is not the type of queue? a) Ordinary queue b) Single ended queue c) Circular queue d) Priority queue
D
Which of the following points is/are true about Linked List data structure when it is compared with array a) Arrays have better cache locality that can make them better in terms of performance b) It is easy to insert and delete elements in Linked List c) Random access is not allowed in a typical implementation of Linked Lists d) All of the mentioned
D
Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity? a) Insertion Sort b) Quick Sort c) Heap Sort d) Merge Sort
C
Which of the following statement(s) about stack data structure is/are NOT correct? a) Linked List are used for implementing Stacks b) Top of the Stack always contain the new node c) Stack is the FIFO data structure d) Null link is present in the last node at the bottom of the stack
C
What would be the asymptotic time complexity to add a node at the end of singly linked list, if the pointer is initially pointing to the head of the list? a) O(1) b) O(n) c) θ(n) d) θ(1)
B
What would be the asymptotic time complexity to find an element in the linked list? a) O(1) b) O(n) c) O(n2) d) None of the mentioned
A
What would be the asymptotic time complexity to insert an element at the second position in the linked list? a) O(1) b) O(n) c) O(n2) d) None of the mentioned
A
A queue is a ? a) FIFO (First In First Out) list b) LIFO (Last In First Out) list c) Ordered array d) Linear tree
A
Consider the following definition in c programming language struct node { int data; struct node * next; } typedef struct node NODE; NODE *ptr; Which of the following c code is used to create new node? a) ptr = (NODE*)malloc(sizeof(NODE)); b) ptr = (NODE*)malloc(NODE); c) ptr = (NODE*)malloc(sizeof(NODE*)); d) ptr = (NODE)malloc(sizeof(NODE));
A
Consider the following operation performed on a stack of size 5. Push(1); Pop(); Push(2); Push(3); Pop(); Push(4); Pop(); Pop(); Push(5); After the completion of all operation, the number of elements present in stack are a) 1 b) 2 c) 3 d) 4
C
Consider the usual algorithm for determining whether a sequence of parentheses is balanced. The maximum number of parentheses that appear on the stack AT ANY ONE TIME when the algorithm analyzes: (()(())(())) are: a) 1 b) 2 c) 3 d) 4 or more
A
Convert the following Infix expression to Postfix form using a stack x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal. a) xyz*+pq*r+s*+ b) xyz*+pq*r+s+* c) xyz+*pq*r+s*+ d) None of the mentioned
A
Convert the following infix expressions into its equivalent postfix expressions (A + B ⋀D)/(E - F)+G a) (A B D ⋀ + E F - / G +) b) (A B D +⋀ E F - / G +) c) (A B D ⋀ + E F/- G +) d) None of the mentioned
B
If the elements "A", "B", "C" and "D" are placed in a stack and are deleted one at a time, what is the order of removal? a) ABCD b) DCBA c) DCAB d) ABDC
D
Process of removing an element from stack is called __________ a) Create b) Push c) Evaluation d) Pod
A
Pushing an element into stack already having five elements and stack size of 5 , then stack becomes a) Overflow b) Crash c) Underflow d) User flow
C
The data structure required for Breadth First Traversal on a graph is? a) Stack b) Array c) Queue d) Tree
A
The postfix form of the expression (A+ B)*(C*D- E)*F / G is? a) AB+ CD*E - FG /** b) AB + CD* E - F **G / c) AB + CD* E - *F *G / d) AB + CDE * - * F *G /
C
The prefix form of A-B/ (C * D ^ E) is? a) -/*^ACBDE b) -ABCD*^DE c) -A/B*C^DE d) -A/BC*^DE
D
What are the disadvantages of arrays? a) We must know before hand how many elements will be there in the array b) There are chances of wastage of memory space if elements inserted in an array are lesser than than the allocated size c) Insertion and deletion becomes tedious d) All of the mentioned
D
What is the output of following function for start pointing to first node of following linked list? 1->2->3->4->5->6 void fun(struct node* start) { if(start == NULL) return; printf("%d ", start->data); if(start->next != NULL ) fun(start->next->next); printf("%d ", start->data); } a) 1 4 6 6 4 1 b) 1 3 5 1 3 5 c) 1 2 3 5 d) 1 3 5 5 3 1
A
What is the output of the following piece of code? public class array { public static void main(String args[]) { int []arr = {1,2,3,4,5}; System.out.println(arr[2]); System.out.println(arr[4]); } } a) 3 and 5 b) 5 and 3 c) 2 and 4 d) 4 and 2
C
What is the output of the following piece of code? public class array { public static void main(String args[]) { int []arr = {1,2,3,4,5}; System.out.println(arr[5]); } } a) 4 b) 5 c) ArrayIndexOutOfBoundsException d) InavlidInputException
C
You are given pointers to first and last nodes of a singly linked list, which of the following operations are dependent on the length of the linked list? a) Delete the first element b) Insert a new element as a first element c) Delete the last element of the list d) Add a new element at the end of the list