0

Data Structures and Algorithms

Description: test your DS and C knowledge
Number of Questions: 15
Created by:
Tags: data structures Data Structure Algorithm Arrays and Pointers
Attempted 0/15 Correct 0 Score 0

Which of the following data structures is used to implement predictive text or auto complete dictionary, such as found on a mobile telephone?

  1. Bloom filter

  2. Trie

  3. Hash Map

  4. Stack

  5. None of the above


Correct Option: B
Explanation:

Yes, trie data structure is the most efficient one to implement auto complete dictionary.

Which of the following is a characteristic of bloom filter?

  1. False positive matches are possible, but false negatives are not possible.

  2. False negative matches are possible, but false positives are not possible.

  3. Bloom filter takes large amount of space than hash table.

  4. Look ups in bloom filters are much slower than look ups in hash table.

  5. None of the above


Correct Option: A
Explanation:

Yes, bloom filter's main characteristic is that there is a chance of false positive but no false negatives.

Which of the following statements are true?

  1. Linked list has more storage over head than array, considering both are of same size.
  2. Linked list's size is fixed whereas array's size can be varied dynamically.
  3. The list elements cannot be inserted or removed from the linked list.
  1. Only 1 and 2

  2. Only 1

  3. Only 2 and 3

  4. Only 2

  5. 1, 2 and 3


Correct Option: B
Explanation:

Statement 1 is true, whereas statement 2 is false as linked list size can be varied dynamically where as array size cannot. Statement 3 is also false as it is very easy to insert or remove elements from the linked list.

Which of the following statements is/are true?

  1. The time complexity for searching an element in binary search tree is O(log n).
  2. The time complexity for searching an element in binary tree is O(n).
  3. The time complexity for searching an element in binary tree and binary search tree cannot be determined.
  1. Both 1 and 2

  2. Only 1

  3. Only 2

  4. Only 2 and 3

  5. 1, 2 and 3


Correct Option: D
Explanation:

Statements 1 and 2 are true because the time complexity for searching an element in binary search tree is O(log n) and the time complexity for searching an element in binary tree is O(n). Statement 3 is false as time complexity for searching an element in binary tree and binary search tree can be determined.

Given four algorithms A, B, C, D with time complexities as follows: A-O(n) B-O(log log n) C-O(log n) D-O(1) where n > 1 Select the option, which gives the algorithms in increasing order of their time complexities.

  1. C B A D

  2. B C D A

  3. A D B C

  4. A D C B

  5. None of these


Correct Option: B
Explanation:

yes of the given time complexities the one with time O(log log n) is smallest because logarithm of a number is significantly small, here we are applying another logarithm which makes it much smaller, the next smaller will be O(log n) followed by O(n) and O(1) which makes it B C D A

Which of the following searching methods takes a time complexity of O(1) to search an element?

  1. Linear search

  2. Binary search

  3. Hash based search (Hashing)

  4. Tree based search

  5. None of the above


Correct Option: C
Explanation:

yes, hashing or hash based search is used to find the element in O(1). Hashing generates a unique code which is used to look for an element in the data structure

Inorder traversal of Binary Search Tree gives which of the following?

  1. Descending order of inserted elements

  2. Random order of inserted elements

  3. Ascending order of inserted elements

  4. The order in which the elements are inserted

  5. None of the above


Correct Option: C
Explanation:

yes in order traversal of binary search tree gives ascending order of inserted elements. the in order pattern is as followsleft->root->right. So when we traverse it goes to the last element in the left sub tree and display it and then its root and its right sibling. this pattern is applied recursively.

A tree data structure has 100 nodes. What is the number of nodes in this tree having no ancestor?

  1. 50

  2. 1

  3. 0

  4. 55

  5. None of these


Correct Option: B
Explanation:

Yes, this is  true as the node which has no ancestors is the root node because root node itself is the ancestor of all the remaining nodes in the tree.

Last in first out property is associated with which of the following data structures?

  1. Linked list

  2. Queue

  3. Stack

  4. Tree

  5. None of these


Correct Option: C
Explanation:

yes, Stack is a data structure which has a characteristic feature of Last in First Out

Which of the following statements is/are true?

  1. Quick sort algorithm and bubble sort algorithm takes O(n2) in worst case.
  2. Quick sort and merge sort takes O(n2) in worst case.
  1. Only 1

  2. Only 2

  3. Both 1 and 2

  4. Neither 1 or 2

  5. None of the above


Correct Option: A
Explanation:

yes quick sort in worst case behaves as bubble sort whose time complexity is O(n2)

merge sort even in the worst case has time complexity of O(nlog n), so statement 2 is false

In which of the following applications is a tree data structure best used?

  1. Symbol table construction

  2. Spell checker

  3. Auto complete feature

  4. Implementing recursion

  5. None of these


Correct Option: A
Explanation:

yes, to implement a symbol table a tree data structure is necessary.A symbol- table mechanism must allow us to add new entries and find existing entries efficiently so a tree data structure is best suited

Which of the following statements is/are true? Statement 1: Data structures are solely used for visualizing the data Statement 2: Data strcuture is programming language dependent

  1. Both statement 1 and statement 2 are true.

  2. Only statement 1 is true.

  3. Only statement 2 is true.

  4. Neither statement 1 nor statement 2 are true.

  5. None of the above


Correct Option: D
Explanation:

yes, both statement 1 and statement 2 are false because data structure is not used for visualization of data but for storing data and data structure is not programming language dependent.data structure is a way of storing data and the concept remains the same even if it is implemented in different languages

Which of the following data structures can be described as a connected graph with no cycles?

  1. Linked list

  2. Tree

  3. Queue

  4. Stack

  5. None of the above


Correct Option: B
Explanation:

yes, if there is a graph and there are no cycles in it, then it forms a generic Tree Data structure

Which of the following data structures supports insertion or deletion of elements either from the front (head) or back (tail)?

  1. Queue

  2. Stack

  3. Dequeue

  4. Hash map

  5. None of these


Correct Option: C
Explanation:

yes dequeue supports insertion or deletion of elements from head or back.dequeue stands for double ended queue

Which of the following is a lossless data compression algorithm?

  1. Run length encoding

  2. JPEG encoding

  3. Block truncation coding

  4. Fractal compression

  5. None of the above


Correct Option: A
Explanation:

yes Run-length encoding performs lossless data compression

- Hide questions