Computer Knowledge

Data Structures and Algorithms

1,518 Questions

Data Structures and Algorithms form the core of computer science, focusing on arrays, linked lists, trees, and sorting mechanisms. These concepts are essential for solving complex computational problems efficiently. Test takers preparing for technical and administrative IT exams will find these questions highly relevant.

Array OperationsLinked List ApplicationsSorting AlgorithmsTree Data StructuresMultilevel IndexingAlgorithm Time Complexity

Data Structures and Algorithms Questions

Multiple choice
  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

This is the correct choice because there are 3 constructors of HashMap class. These are:   HashMap(): creates a Map with default initial capacity and load factor HashMap(int initialCap, float load): creates a Map with default specified initial capacity and load factor HashMap(m : Map): creates a Map with existing Map

Multiple choice
  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is the correct choice because there are 4 constructors of HashTable class in Java collections framework. These constructors are: 1) Hashtable(): constructs a new, empty hashtable with a default initial capacity (11) and load factor (0.75) 2) Hashtable(int initialCapacity): constructs a new, empty hashtable with the specified initial capacity and default load factor (0.75) 3) Hashtable(int initialCapacity, float loadFactor): constructs a new, empty hashtable with the specified initial capacity and the specified load factor 4) Hashtable(Map t): constructs a new hashtable with the same mappings as the given map

Multiple choice
  1. 6

  2. 5

  3. 4

  4. 3

  5. 2

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

This is the correct answer. There are four constructors of TreeMap. These are:

TreeMap(): It creates an empty Map. TreeMap(Comparator comp): The second form constructs an empty tree-based map that will be sorted by using the Comparator comp. TreeMap(Map m): The third form initialises a tree map with the entries from m, which will be sorted by using the natural order of the keys. TreeMap(SortedMap sm): The fourth form initialises a tree map with the entries from sm, which will be sorted in the same order as sm.

Multiple choice
  1. Only 1 and 2

  2. Only 1

  3. Only 2 and 3

  4. Only 2

  5. 1, 2 and 3

Reveal answer Fill a bubble to check yourself
B Correct answer
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.

Multiple choice
  1. Both 1 and 2

  2. Only 1

  3. Only 2

  4. Only 2 and 3

  5. 1, 2 and 3

Reveal answer Fill a bubble to check yourself
D Correct answer
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.

Multiple choice
  1. C B A D

  2. B C D A

  3. A D B C

  4. A D C B

  5. None of these

Reveal answer Fill a bubble to check yourself
B Correct answer
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

Multiple choice
  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

Reveal answer Fill a bubble to check yourself
C Correct answer
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.

Multiple choice
  1. Symbol table construction

  2. Spell checker

  3. Auto complete feature

  4. Implementing recursion

  5. None of these

Reveal answer Fill a bubble to check yourself
A Correct answer
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